https://github.com/afeiship/next-intersection
Simple intersection implement.
https://github.com/afeiship/next-intersection
intersection next
Last synced: 11 months ago
JSON representation
Simple intersection implement.
- Host: GitHub
- URL: https://github.com/afeiship/next-intersection
- Owner: afeiship
- License: mit
- Created: 2020-07-30T04:56:40.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-20T09:32:31.000Z (over 5 years ago)
- Last Synced: 2025-03-17T22:55:54.510Z (11 months ago)
- Topics: intersection, next
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-intersection
> Simple intersection implement.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-intersection
```
## usage
```js
import '@jswork/next-intersection';
const a1 = [1, 2, 3];
const a2 = [2, 3, 4];
nx.intersection(a1, a2)
// [2, 3]
const a1 = [
{ id: 1, value: 'aa' },
{ id: 2, value: 'bb' },
{ id: 3, value: 'cc' }
];
const a2 = [
{ id: 3, value: 'cc' },
{ id: 4, value: 'dd' }
];
const ids = a2.map(item => item.id);
const res = nx.intersection(a1, a2, (_, value) => {
return ids.includes(value.id);
});
// [ { id: 3, value: 'cc' } ]
```
## resources
- https://stackoverflow.com/questions/1885557/simplest-code-for-array-intersection-in-javascript
## license
Code released under [the MIT license](https://github.com/afeiship/next-intersection/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-intersection
[version-url]: https://npmjs.org/package/@jswork/next-intersection
[license-image]: https://img.shields.io/npm/l/@jswork/next-intersection
[license-url]: https://github.com/afeiship/next-intersection/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-intersection
[size-url]: https://github.com/afeiship/next-intersection/blob/master/dist/next-intersection.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-intersection
[download-url]: https://www.npmjs.com/package/@jswork/next-intersection