Skip to content

Instantly share code, notes, and snippets.

@beaucharman
Last active August 15, 2017 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beaucharman/8b5376e352e002c291d9c117092fdb95 to your computer and use it in GitHub Desktop.
Save beaucharman/8b5376e352e002c291d9c117092fdb95 to your computer and use it in GitHub Desktop.
deepArrayMerge.js
// const { unionBy, isArray, merge, find } = _
const deepArrayMerge = (initial, replacement, key) => unionBy(initial, replacement, key)
.map(item => merge({}, item, find(isArray(replacement) ? replacement : [replacement], { [key]: item[key] })))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment