From 3b0de716065c23293b093c6e49a395dd7181402e Mon Sep 17 00:00:00 2001 From: Siarhei Date: Wed, 10 Oct 2018 16:47:58 +0400 Subject: [PATCH] Simplify unionBy --- snippets/unionBy.md | 2 +- test/unionBy/unionBy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/unionBy.md b/snippets/unionBy.md index 3680c6d1c..91c9e6662 100644 --- a/snippets/unionBy.md +++ b/snippets/unionBy.md @@ -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)))])); }; ``` diff --git a/test/unionBy/unionBy.js b/test/unionBy/unionBy.js index 86d52180c..e03f9998b 100644 --- a/test/unionBy/unionBy.js +++ b/test/unionBy/unionBy.js @@ -1,5 +1,5 @@ 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)))])); }; module.exports = unionBy;