Skip to content

Commit

Permalink
fix: stop using cloneObject in assign
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jun 24, 2024
1 parent a21ce62 commit 79f2cad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,10 @@ export const assign = <X extends Record<string | symbol | number, any>>(
override: X
): X => {
if (!initial || !override) return initial ?? override ?? {}
const merged = cloneObject(initial)
const proto = Object.getPrototypeOf(initial)
const merged = proto
? { ...initial }
: Object.assign(Object.create(proto), initial)
for (const key in override) {
if (hasOwnProperty(override, key)) {
merged[key] = isPlainObject(initial[key])
Expand Down

0 comments on commit 79f2cad

Please sign in to comment.