arr-difference
v1.0.2
Published
return difference of array
Downloads
4
Readme
arr-difference
Returns an array with the values from the first array(not need to be unique values), by excluding all values from additional arrays using strict equality for comparisons.
Install
Install with npm:
$ npm install --save arr-difference
Usage
Returns the difference between the first array and additional arrays.
var diff = require('arr-difference');
var array = ['a', 'b', 'c', 'd', 'a'];
var subArray = ['b', 'c', 'a'];
console.log(diff(array, subArray))
//=> ['a', 'd']
diff([1,2,3,1], [1,2]) => [1,3]
diff([1,2,3,1], [1,2,1,1]) => [3]
diff([1,2,3,1], [1,2], [3]) => [1]
diff([1,2,3,1], [1], [2], [3]) => [1]
// when params is not an Array
diff({}, {}) should equal []
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Contributors
| Commits | Contributor | | --- | --- | | 2 | chankwen |
Running tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Author
chankwen
License
Copyright © 2017, chankwen. Released under the MIT License.