Simplify unionBy

This commit is contained in:
Siarhei
2018-10-10 16:47:58 +04:00
parent e7b3518fe4
commit 8d558bf6fa
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ Return the last set converted to an array.
```js
const unionBy = (a, b, fn) => {
const s = new Set(a.map(v => fn(v)));
const s = new Set(a.map(fn));
return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))]));
};
```