Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lordfirespeed committed Nov 1, 2024
1 parent a82c9cc commit fbf8b66
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/adapters/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export function deepMerge(target: any, ...sources: any[]) {
return deepMerge(target, ...sources);
}

export function isMergeableObject(item: any) {
return item && typeof item === "object" && !Array.isArray(item);
export function isMergeableObject(item: unknown): item is Record<string, unknown> {
if (!item) return false
if (typeof item !== "object") return false
// ES6 class instances, Maps, Sets, Arrays, etc. are not considered records
if (Object.getPrototypeOf(item) === Object.prototype) return true
// Some library/Node.js functions return records with null prototype
if (Object.getPrototypeOf(item) === null) return true
return false
}

0 comments on commit fbf8b66

Please sign in to comment.