Skip to content

Instantly share code, notes, and snippets.

@lovubuntu
Created October 24, 2018 17:41
Show Gist options
  • Save lovubuntu/c76f82c5c78c8cb139fd902ed52f692c to your computer and use it in GitHub Desktop.
Save lovubuntu/c76f82c5c78c8cb139fd902ed52f692c to your computer and use it in GitHub Desktop.
Using method chaining in lodash
let _ = require('lodash');
const finalList = _.chain(oldSelectedList)
.unionWith(newlySelectedList, (o, n) => o.id === n.id)
.intersectionWith(newlySelectedList, (u, n) => u.id === n.id)
.value();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment