From 5e6bfd3e70ca355fee9bd7b9da5913290c639ea5 Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 24 Jun 2024 03:21:34 -0400 Subject: [PATCH] fix: stop using `cloneObject` in assign --- src/object.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/object.ts b/src/object.ts index b5a416c8..1e09f701 100644 --- a/src/object.ts +++ b/src/object.ts @@ -283,7 +283,10 @@ export const assign = >( 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])