forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use default messages from
en
as fallback if messages are missi…
…ng in another locale (nodejs#7054) * fix: Use default messages from `en` as fallback if messages are missing in another locale * chore: Remove `deepmerge` dependency in favor of a more optimized custom function * chore: Revert changes to lockfile
- Loading branch information
Showing
2 changed files
with
33 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export default function deepMerge<Obj1 extends object, Obj2 extends object>( | ||
obj1: Obj1, | ||
obj2: Obj2 | ||
): Obj1 & Obj2 { | ||
const result = { ...obj1 } as Obj1 & Obj2; | ||
|
||
for (const key in obj2) { | ||
if (Object.prototype.hasOwnProperty.call(obj2, key)) { | ||
if (typeof obj2[key] === 'object' && obj2[key] !== null) { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
result[key] = deepMerge(result[key] as any, obj2[key] as any); | ||
} else { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
result[key] = obj2[key] as any; | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} |