Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
This library is 20-30 times faster and more performant (scales better) than array-union, which just uses [].concat.apply([], arguments)
.
See the benchmarks.
#1: five-arrays
array-union x 243,091 ops/sec ±0.43% (100 runs sampled)
arr-union x 7,141,833 ops/sec ±0.33% (101 runs sampled)
#2: ten-arrays
array-union x 118,600 ops/sec ±0.38% (99 runs sampled)
arr-union x 2,112,268 ops/sec ±0.36% (98 runs sampled)
#3: two-arrays
array-union x 318,757 ops/sec ±0.39% (99 runs sampled)
arr-union x 10,145,772 ops/sec ±0.23% (100 runs sampled)
Install with npm
$ npm i arr-union --save
var union = require('arr-union');
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']
Returns only unique elements:
union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']
- arr-diff: Returns an array with only the unique values from the first array, by excluding all… more
- arr-flatten: Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
- arr-filter: Faster alternative to javascript's native filter method.
- arr-map: Faster, node.js focused alternative to JavaScript's native array map.
- arr-pluck: Retrieves the value of a specified property from all elements in the collection.
- arr-reduce: Fast array reduce that also loops over sparse elements.
- array-unique: Return an array free of duplicate values. Fastest ES5 implementation.
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on July 04, 2015.