@@ -1,4 +1,4 @@
|
|||||||
import { Array, Option, Predicate } from "effect"
|
import { Array, Option, Predicate, Schema } from "effect"
|
||||||
|
|
||||||
|
|
||||||
export type Key = string | number | symbol
|
export type Key = string | number | symbol
|
||||||
@@ -65,25 +65,28 @@ export const immutableSet = <T, const P extends Paths<T>>(
|
|||||||
: Option.none()
|
: Option.none()
|
||||||
|
|
||||||
if (typeof parent === "object")
|
if (typeof parent === "object")
|
||||||
return Object.assign(
|
return Option.some(
|
||||||
Object.create(Object.getPrototypeOf(parent)),
|
Object.assign(
|
||||||
{ ...parent, [key.value]: child.value },
|
Object.create(Object.getPrototypeOf(parent)),
|
||||||
|
{ ...parent, [key.value]: child.value },
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return Option.none()
|
return Option.none()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Person extends Schema.Class<Person>("Person")({
|
||||||
|
name: Schema.String,
|
||||||
|
}) {}
|
||||||
|
|
||||||
const persons = [
|
const persons = [
|
||||||
{ name: "Monsieur Poulet" },
|
Person.make({ name: "Monsieur Poulet" }),
|
||||||
{ name: "El Chanclador" },
|
Person.make({ name: "El Chanclador" }),
|
||||||
{ name: "AAAYAYAYAYAAY" },
|
Person.make({ name: "AAAYAYAYAYAAY" }),
|
||||||
]
|
]
|
||||||
console.log(persons)
|
|
||||||
|
|
||||||
const res = get(persons, [1, "name"])
|
const res = get(persons, [1, "name"])
|
||||||
console.log(res)
|
|
||||||
|
|
||||||
const persons2 = Option.getOrThrow(immutableSet(persons, [1, "name"], "El Risitas"))
|
const persons2 = Option.getOrThrow(immutableSet(persons, [1, "name"], "El Risitas"))
|
||||||
console.log(persons2)
|
console.log(persons2)
|
||||||
console.log(get(persons2, [1, "name"]))
|
console.log(get(persons2, [1, "name"]))
|
||||||
|
|||||||
Reference in New Issue
Block a user