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 7af13ea commit 5e6bfd3
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 5e6bfd3

Please sign in to comment.