Skip to content

Instantly share code, notes, and snippets.

@dinocarl
Created July 18, 2024 16:58
Show Gist options
  • Save dinocarl/772a6b73e0ce88335eaa900d7e7977df to your computer and use it in GitHub Desktop.
Save dinocarl/772a6b73e0ce88335eaa900d7e7977df to your computer and use it in GitHub Desktop.
Simplistic recursive merge fn for JS
const recMerge = (objA, objB) => Object.entries(objB).reduce(
(acc, [key, val]) => Object.assign(
{},
objA,
{ [key]: is(Object, val) ? recMerge(objA[key], val) : val }
),
{}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment