just-unique
TypeScript icon, indicating that this package has built-in type declarations

4.2.0 • Public • Published

just-unique

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-unique
yarn add just-unique

Dedupes an array

import unique from 'just-unique';

unique([1, 2, 3, 2, 3, 4, 3, 2, 1, 3]); // [1, 2, 3, 4]

var a = {a: 3};
var b = {b: 4};
var c = {c: 5};
unique([a, a, b, c, b]); // [a, b, c]

unique([1, '1', 2, '2', 3, 2]); // [1, '1', 2, '2', 3]

// declaring sorted array for performance
unique([1, 1, '1', 2, 2, 5, '5', '5'], true); // [1, '1', 2, 5, '6']

// declaring strings array for performance
unique(['a', 'c', 'b', 'c', 'a'], false, true); // ['a', 'b', 'c']

Package Sidebar

Install

npm i just-unique

Weekly Downloads

33,352

Version

4.2.0

License

MIT

Unpacked Size

7.89 kB

Total Files

9

Last publish

Collaborators

  • angus-c