Skip to content

Commit

Permalink
fix: use isPlainObject internally
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jun 24, 2024
1 parent 3bb4873 commit 97f6ee6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/object.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -278,7 +284,7 @@ export const assign = <X extends Record<string | symbol | number, any>>(
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]
}
Expand All @@ -297,7 +303,7 @@ export const assign = <X extends Record<string | symbol | number, any>>(
export const keys = <TValue extends object>(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])
)
Expand Down

0 comments on commit 97f6ee6

Please sign in to comment.