https://github.com/callmecavs/array-intersect
Array intersection, simplified.
https://github.com/callmecavs/array-intersect
array intersection
Last synced: 9 months ago
JSON representation
Array intersection, simplified.
- Host: GitHub
- URL: https://github.com/callmecavs/array-intersect
- Owner: callmecavs
- Created: 2018-08-06T00:25:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-06T01:03:48.000Z (over 7 years ago)
- Last Synced: 2024-05-29T23:36:05.149Z (over 1 year ago)
- Topics: array, intersection
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# array-intersect
[](https://travis-ci.org/callmecavs/array-intersect) [](https://www.npmjs.com/package/array-intersect) [](https://www.npmjs.com/package/array-intersect) [](http://standardjs.com/)
## Install
```sh
$ npm i array-intersect --save
```
## Use
Pass any number of arrays as arguments.
Expects that:
* Array items are unique (deduped)
* Array items are [primitive types](https://developer.mozilla.org/en-US/docs/Glossary/Primitive)
```javascript
import intersect from 'array-intersect'
const simple = intersect(
[1, 2, 3],
[2, 3, 4]
)
const complex = intersect(
[0, 1, 2, 3],
[1, 2, 3, 4],
[2, 3, 4, 5]
)
console.log(simple) // [2, 3]
console.log(complex) // [2, 3]
```
## Browser Support
Requires support for [ES5 Array Methods](https://caniuse.com/#feat=es5).
## License
[MIT](https://opensource.org/licenses/MIT). © 2018 Michael Cavalea