diff options
author | INOUE Daisuke <inoue.daisuke@gmail.com> | 2025-05-03 22:38:45 +0900 |
---|---|---|
committer | INOUE Daisuke <inoue.daisuke@gmail.com> | 2025-05-03 22:38:45 +0900 |
commit | 861fff32a70c5631e3061fe3d68fbe83c9d9bc3b (patch) | |
tree | 6d677e86b42c78de3d72c78286db0481873123d5 /src/util | |
parent | d901c09ff606d9298fbefd7ecefb6dd3bfe22ac2 (diff) | |
parent | 69f75005303d634b9208c23068655385734f4d3a (diff) |
Merge branch 'main' into feature/localization-again
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/object.ts | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/util/object.ts b/src/util/object.ts deleted file mode 100644 index 1ecc89b..0000000 --- a/src/util/object.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Simple object check. - */ -export function isObject(item: any) { - return item && typeof item === "object" && !Array.isArray(item); -} - -/** - * Deep merge two objects. - */ -export function deepMerge<T>( - target: Record<any, any>, - ...sources: Record<any, any>[] -): T { - if (!sources.length) return target; - const source = sources.shift(); - - if (isObject(target) && isObject(source)) { - for (const key in source) { - if (isObject(source[key])) { - if (!target[key]) Object.assign(target, { [key]: {} }); - deepMerge(target[key], source[key]); - } else { - Object.assign(target, { [key]: source[key] }); - } - } - } - - return deepMerge(target, ...sources) as T; -} |