Simplify intersectionBy

This commit is contained in:
Siarhei
2018-09-04 17:00:12 +04:00
parent 0080c70330
commit 3c8e4ef4b9
2 changed files with 2 additions and 2 deletions

View File

@ -6,7 +6,7 @@ Create a `Set` by applying `fn` to all elements in `b`, then use `Array.filter()
```js
const intersectionBy = (a, b, fn) => {
const s = new Set(b.map(x => fn(x)));
const s = new Set(b.map(fn));
return a.filter(x => s.has(fn(x)));
};
```

View File

@ -1,5 +1,5 @@
const intersectionBy = (a, b, fn) => {
const s = new Set(b.map(x => fn(x)));
const s = new Set(b.map(fn));
return a.filter(x => s.has(fn(x)));
};
module.exports = intersectionBy;