6 lines
164 B
JavaScript
6 lines
164 B
JavaScript
const unionBy = (a, b, fn) => {
|
|
const s = new Set(a.map(fn));
|
|
return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))]));
|
|
};
|
|
module.exports = unionBy;
|