arr-union
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -11,5 +11,2 @@ /*! | ||
module.exports = function union(arr) { | ||
if (!Array.isArray(arr)) { | ||
throw new Error('arr-union expects an array as the first argument.'); | ||
} | ||
var len = arguments.length; | ||
@@ -19,3 +16,3 @@ var res = [], i = 0; | ||
while (len--) { | ||
var arg = arguments[i++]; | ||
var arg = arrayify(arguments[i++]); | ||
@@ -32,1 +29,5 @@ for (var j = 0; j < arg.length; j++) { | ||
}; | ||
function arrayify(val) { | ||
return Array.isArray(val) ? val : [val]; | ||
} |
{ | ||
"name": "arr-union", | ||
"description": "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"homepage": "https://github.com/jonschlinkert/arr-union", | ||
@@ -17,6 +17,3 @@ "author": { | ||
}, | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/arr-union/blob/master/LICENSE" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
@@ -39,9 +36,13 @@ "index.js" | ||
"mocha": "^2.2.1", | ||
"should": "^5.2.0" | ||
"should": "^5.2.0", | ||
"verb": "^0.8.6" | ||
}, | ||
"keywords": [ | ||
"add", | ||
"append", | ||
"array", | ||
"arrays", | ||
"combine", | ||
"concat", | ||
"javascript", | ||
"js", | ||
"extend", | ||
"union", | ||
@@ -48,0 +49,0 @@ "uniq", |
@@ -1,29 +0,31 @@ | ||
# arr-union [![NPM version](https://badge.fury.io/js/arr-union.svg)](http://badge.fury.io/js/arr-union) [![Build Status](https://travis-ci.org/jonschlinkert/arr-union.svg)](https://travis-ci.org/jonschlinkert/arr-union) | ||
# arr-union [![NPM version](https://badge.fury.io/js/arr-union.svg)](http://badge.fury.io/js/arr-union) [![Build Status](https://travis-ci.org/jonschlinkert/arr-union.svg)](https://travis-ci.org/jonschlinkert/arr-union) | ||
> Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons. | ||
You can do this with just `[].concat.apply([], arguments)`, like [array-union](https://github.com/sindresorhus/array-union) but this implementation is much faster and more peformant. | ||
This library is **15-20 times faster** and more performant (scales better) than [array-union](https://github.com/sindresorhus/array-union), which just uses `[].concat.apply([], arguments)`. | ||
For the most common use cases, this library is **20 times faster** than array-union. | ||
## Benchmarks | ||
See the [benchmarks](./benchmark). | ||
```bash | ||
#1: five-arrays.js | ||
array-union.js x 289,891 ops/sec ±0.70% (97 runs sampled) | ||
current.js x 5,429,077 ops/sec ±0.81% (93 runs sampled) | ||
array-union.js x 245,487 ops/sec ±0.99% (96 runs sampled) | ||
current.js x 5,267,661 ops/sec ±0.63% (98 runs sampled) | ||
#2: ten-arrays.js | ||
array-union.js x 161,132 ops/sec ±0.72% (98 runs sampled) | ||
current.js x 1,725,939 ops/sec ±0.61% (97 runs sampled) | ||
array-union.js x 134,784 ops/sec ±0.51% (94 runs sampled) | ||
current.js x 1,919,143 ops/sec ±0.45% (100 runs sampled) | ||
#3: two-arrays.js | ||
array-union.js x 376,238 ops/sec ±0.83% (95 runs sampled) | ||
current.js x 6,817,593 ops/sec ±0.63% (94 runs sampled) | ||
array-union.js x 308,374 ops/sec ±0.75% (96 runs sampled) | ||
current.js x 7,361,915 ops/sec ±0.67% (95 runs sampled) | ||
``` | ||
See the [benchmarks](./benchmark). | ||
## Install | ||
## Install with [npm](npmjs.org) | ||
Install with [npm](https://www.npmjs.com/) | ||
```bash | ||
npm i arr-union --save | ||
```sh | ||
$ npm i arr-union --save | ||
``` | ||
@@ -34,3 +36,3 @@ | ||
```js | ||
var last = require('array-last'); | ||
var union = require('arr-union'); | ||
@@ -49,3 +51,4 @@ union(['a'], ['b', 'c'], ['d', 'e', 'f']); | ||
## Other array utilities | ||
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons. | ||
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://github.com/jonschlinkert/arr-diff) | ||
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | ||
@@ -59,24 +62,27 @@ * [arr-filter](https://github.com/jonschlinkert/arr-filter): Faster alternative to javascript's native filter method. | ||
## Running tests | ||
Install dev dependencies. | ||
```bash | ||
npm i -d && npm test | ||
Install dev dependencies: | ||
```sh | ||
$ npm i -d && npm test | ||
``` | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues) | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues/new) | ||
## Author | ||
**Jon Schlinkert** | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 25, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 15, 2015._ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Nonpermissive License
License(Experimental) A package's licensing information has fine-grained problems
Found 1 instance in 1 package
0
86
0
5661
8