array-unique-x
v1.0.5
Published
Method for filtering unique items in primitive or object arrays
Downloads
3
Maintainers
Readme
Installation
Just run the following command on the console:
npm install --save array-unique-x
Usage
array-unique-x works both for primitive arrays and obejct arrays. Example:
const unique = require('array-unique-x');
let ids = [1001, 1005, 1003, 1005];
unique(ids);
// Returns [1001, 1005, 1003]
let students = [
{ name: "Hirohiko", code: 102 },
{ name: "Jean Pierre", code: 205 },
{ name: "Avdol", code: 340 },
{ name: "Araki", code: 102 }
];
unique(students, "code");
/* Returns [
{ name: 'Hirohiko', code: 102 },
{ name: 'Jean Pierre', code: 205 },
{ name: 'Avdol', code: 340 }
]
*/