| 2441 | * extension when `o` is. |
| 2442 | */ |
| 2443 | const copyWithout = (o: object, names: ReadonlyArray<PropertyKey>): object => { |
| 2444 | const descriptors: Record<PropertyKey, PropertyDescriptor> = Object |
| 2445 | .getOwnPropertyDescriptors(o) |
| 2446 | for (const name of names) delete descriptors[name] |
| 2447 | const out = Object.create(Object.getPrototypeOf(o), descriptors) |
| 2448 | if (Object.isFrozen(o)) Object.freeze(out) |
| 2449 | else if (Object.isSealed(o)) Object.seal(out) |
| 2450 | else if (!Object.isExtensible(o)) Object.preventExtensions(out) |
| 2451 | return out |
| 2452 | } |
| 2453 | |
| 2454 | /** |
| 2455 | * Drops every optional property that is `undefined` from args that are a |