Socket
Socket
Sign inDemoInstall

arr-union

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

9

index.js

@@ -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._
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc