-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pompurin404
committed
Aug 17, 2024
1 parent
17e681e
commit d9b9977
Showing
5 changed files
with
28 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function isObject(item: any): boolean { | ||
return item && typeof item === 'object' && !Array.isArray(item) | ||
} | ||
|
||
export function deepMerge<T extends object>(target: T, other: Partial<T>): T { | ||
for (const key in other) { | ||
if (isObject(other[key])) { | ||
if (!target[key]) Object.assign(target, { [key]: {} }) | ||
deepMerge(target[key] as object, other[key] as object) | ||
} else { | ||
Object.assign(target, { [key]: other[key] }) | ||
} | ||
} | ||
return target as T | ||
} |