Filters an Object or Map by testing entry uniqueness with a callback.
This module is an alias of unique-map-by
, which supports both Maps and Objects.
npm install unique-object-by --save
const uniqueObjectBy = require('unique-object-by')
const obj = {
1: {name: 'John'},
2: {name: 'John'},
3: {name: 'Stephen'},
}
const u = uniqueObjectBy(obj, (key, value) => value.name)
u[1] // {name: 'John'}
u[2] // undefined
u[3] // {name: 'Stephen'}
For more details, see the documentation for the unique-map-by
module.