Creates and makes an array without duplicates. Even with array of objects with a specified matcher.
npm install make-unique
Creates and makes an array without duplicates. Even with array of objects with a specified matcher.
If no matcher specified, it will use Set if Set is available in V8.
``sh`
$ npm install make-unique --save
`js
let unique = require('make-unique')
unique([1, 2, 3, 1]) // [1, 2, 3]
`
- array Array the input arrayfunction(a, b)
- matcher if matcher returns true, then it will treat a equals to b.
Cleans an array of objects with a specified filter to tell unique how to determine if two items are the 'same'
`js
unique([
{a: 1},
{a: 2},
{a: 1}
], (a, b) => {
// if a and b contain the same .a, they are the 'same'``
return a.a === b.a
})
// [
// {a: 1},
// {a: 2}
// ]
MIT