1.0.0 • Published 5 years ago
unique-by-property v1.0.0
A function filtering an array of objects by a single property, returning an array of objects uniquely identified by that property's value.
Require the module as follows:
const unique = require('unique-by-property')
Example
unique (arr, 'id', (res) => {
console.log(res)
})
It will print: [ { id: 1, firstName: 'John', lastName: 'Mason' },
{ id: 2, firstName: 'Matt', lastName: 'Milton' },
{ id: 3, firstName: 'Andrew', lastName: 'Ivory' },
{ id: 4, firstName: 'Ralph', lastName: 'Hughes' },
{ id: 6, firstName: 'Reese', lastName: 'Fielding' } ]
1.0.0
5 years ago