diff options
author | Raphael Kabo <mail@raphaelkabo.com> | 2025-05-28 18:32:47 +0100 |
---|---|---|
committer | Raphael Kabo <mail@raphaelkabo.com> | 2025-05-28 18:32:47 +0100 |
commit | a6f8ec770d06ce33042ed3f222cba786897e0233 (patch) | |
tree | a060e72668de41fcbeae5e891ee86b096b096f26 /src/util/object.ts | |
parent | 08fa2f616c90e59066d0308097c65c424b5b4a88 (diff) | |
parent | fd637b405c8784a07dabd54b10fda98ad9f4a4ad (diff) |
Merge remote-tracking branch 'origin/main' into clearer-editing-mode
Diffstat (limited to 'src/util/object.ts')
-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; -} |