From 97f6ee6aa859213a3f9753f8858fa72f2f368cad 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 082c21bc8..e92770734 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 @@ -278,7 +284,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] } @@ -297,7 +303,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]) )