wwa-array-unique

1.0.1 • Public • Published

nodejs-array-unique

Build Status

Another implementation of jonschlinkert/array-unique, which is faster on larger arrays

Install

Install with npm:

npm install --save wwa-array-unique

Usage

const unique = require('wwa-array-unique');

let arr = ['a', 'b', 'c', 'c'];
console.log(unique(arr)) //=> ['a', 'b', 'c']
console.log(arr)         //=> ['a', 'b', 'c']

/* The above modifies the input array. To prevent that: */
const unique = require("array-unique").immutable;

let arr = ['a', 'b', 'c', 'c'];
console.log(unique(arr)) //=> ['a', 'b', 'c']
console.log(arr)         //=> ['a', 'b', 'c', 'c']

Benchmarks

Table values are number of operations per second. Unlike the original version, my implementation of immutable is faster than unique.

NodeJS 6

array-unique (mutable) wwa-array-unique (mutable) array-unique (immutable) wwa-array-unique (immutable)
10 2,764,501 315,991 2,239,566 1,119,888
20 888,532 202,232 726,592 590,641
100 65,662 68,415 53,382 208,231
1,000 67,716 71,174 53,714 202,922
10,000 3,025 26,326 2,519 48,769

NodeJS 8

array-unique (mutable) wwa-array-unique (mutable) array-unique (immutable) wwa-array-unique (immutable)
10 2,013,162 1,569,884 1,616,899 2,259,815
20 1,026,325 887,556 774,410 1,168,428
100 80,493 177,247 58,954 198,410
1,000 76,875 165,295 58,541 192,993
10,000 3,760 36,623 2,866 46,911

NodeJS 11

array-unique (mutable) wwa-array-unique (mutable) array-unique (immutable) wwa-array-unique (immutable)
10 7,346,026 1,902,676 5,013,364 4,984,386
20 1,230,241 996,985 1,132,996 1,595,666
100 60,376 189,206 59,443 222,805
1,000 56,450 208,546 56,999 240,402
10,000 2,830 38,446 2,726 49,699

Readme

Keywords

none

Package Sidebar

Install

npm i wwa-array-unique

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

5.97 kB

Total Files

4

Last publish

Collaborators

  • wwa