Skip to content

Instantly share code, notes, and snippets.

View gdibble's full-sized avatar
🤩
Optimistic

Gabriel Dibble gdibble

🤩
Optimistic
View GitHub Profile
@gdibble
gdibble / intersectionObj.js
Created May 12, 2017 22:41
Lodash mixin to find similar property values in an array of objects
/**
* intersectionObj
* Pass an array of objects to find the similar objects
* You may also pass a single prop as a string, or an array of props to ignore
* Returns an array of the items which intersected
*
* Usage example:
* var arr = [ { id:1, b:2, c:3 }, { id:2, b:3, c:4 }, { id:3, b:2, c:3 } ];
* _.intersectionObj(arr, 'id');
* » [ { id:1, b:2, c:3 }, { id:3, b:2, c:3 } ]