Simplify intersectionBy

This commit is contained in:
Siarhei
2018-09-04 17:00:12 +04:00
parent ef33238858
commit a14d808c18
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 ```js
const intersectionBy = (a, b, fn) => { 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))); return a.filter(x => s.has(fn(x)));
}; };
``` ```

View File

@ -1,5 +1,5 @@
const intersectionBy = (a, b, fn) => { 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))); return a.filter(x => s.has(fn(x)));
}; };
module.exports = intersectionBy; module.exports = intersectionBy;