1.0.0 • Published 4 years ago

@feizheng/next-intersection v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

next-intersection

Simple intersection implement.

version license size download

installation

npm install -S @feizheng/next-intersection

usage

import '@feizheng/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

license

Code released under the MIT license.