@reffuse/extension-query 0.1.4 #15

Merged
Thilawyn merged 340 commits from next into master 2025-05-26 04:15:01 +02:00
Showing only changes of commit 1de976aaa8 - Show all commits

View File

@@ -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"]))