From 5452241fba9a7c3477af97fd4d75f24ceaed5c9e Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 24 Jun 2024 02:36:09 -0400 Subject: [PATCH] fix: use isPlainObject internally --- src/object.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/object.ts b/src/object.ts index deff64e28..534426335 100644 --- a/src/object.ts +++ b/src/object.ts @@ -1,6 +1,12 @@ import { objectify } from './array' import { toInt } from './number' -import { isArray, isIntString, isObject, isPrimitive } from './typed' +import { + isArray, + isIntString, + isObject, + isPlainObject, + isPrimitive +} from './typed' const hasOwnProperty = /* @__PURE__ */ Function.prototype.call.bind( Object.prototype.hasOwnProperty @@ -280,7 +286,7 @@ export const assign = >( const merged = { ...initial } for (const key in override) { if (hasOwnProperty(override, key)) { - merged[key] = isObject(initial[key]) + merged[key] = isPlainObject(initial[key]) ? assign(initial[key], override[key]) : override[key] } @@ -299,7 +305,7 @@ export const assign = >( export const keys = (value: TValue): string[] => { if (!value) return [] const getKeys = (nested: any, paths: string[]): string[] => { - if (isObject(nested)) { + if (isPlainObject(nested)) { return Object.entries(nested).flatMap(([k, v]) => getKeys(v, [...paths, k]) )