SearchPaths work
All checks were successful
Lint / lint (push) Successful in 13s

This commit is contained in:
Julien Valverdé
2025-04-23 07:06:32 +02:00
parent 459f548c10
commit df851cf9ee

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([
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()
}