unrepeatable
v0.1.1
Published
``` const {mergeAndUnique, uniqueBy, unique} = require("./unique"); unique([1,3,1,2]) ```
Downloads
2
Readme
Make array unique!
High performance
const {mergeAndUnique, uniqueBy, unique} = require("./unique");
unique([1,3,1,2])
const duplicatedArray = [
{
"id": 1,
"name": "test"
},
{
"id": 2,
"name": "test"
},
{
"id": 2,
"name": "test"
}
];
uniqueBy(duplicatedArray, 'id');
const commonArray = [
{
"id": 1,
"name": "test"
},
{
"id": 2,
"name": "test"
}
];
const duplicatedArray = [
{
"id": 1,
"name": "test"
}
];
mergeAndUnique(duplicatedArray, commonArray, 'id', wasUnique = true/false); // 'wasUnique' it's about commonArray
commonArray.length.should.be.eql(2);