0.1.11 #14

Merged
Thilawyn merged 318 commits from next into master 2025-05-19 14:01:41 +02:00
Showing only changes of commit df851cf9ee - Show all commits

View File

@@ -55,16 +55,20 @@ export const immutableSet = <T, const P extends Paths<T>>(
if (Option.isNone(child))
return child
if (Array.isArray(parent) && typeof key.value === "number") {
return Option.some([
...parent.slice(0, key.value),
child.value,
...parent.slice(key.value + 1),
] as T)
}
if (Array.isArray(parent))
return typeof key.value === "number"
? Option.some([
...parent.slice(0, key.value),
child.value,
...parent.slice(key.value + 1),
] as T)
: Option.none()
if (typeof parent === "object")
return Option.some({ ...parent, [key.value]: child.value })
return Object.assign(
Object.create(Object.getPrototypeOf(parent)),
{ ...parent, [key.value]: child.value },
)
return Option.none()
}