From 6c32830cea9c689e094fea4955e125cd0e9a9946 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Thu, 2 Aug 2018 09:04:54 +0000 Subject: [PATCH] Travis build: 163 --- README.md | 2 +- docs/array.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd725c7b0..7cc730a2b 100644 --- a/README.md +++ b/README.md @@ -1280,7 +1280,7 @@ The comparator function takes four arguments: the values of the two elements bei ```js const filterNonUniqueBy = (arr, fn) => - arr.filter((v, i) => arr.every((x, j) => (i == j) == fn(v, x, i, j))); + arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); ```
diff --git a/docs/array.html b/docs/array.html index 2d75e14e6..710eef937 100644 --- a/docs/array.html +++ b/docs/array.html @@ -149,7 +149,7 @@

filterNonUnique

Filters out the non-unique values in an array.

Use Array.filter() for an array containing only the unique values.

const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));
 
filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5]
 

filterNonUniqueBy

Filters out the non-unique values in an array, based on a provided comparator function.

Use Array.filter() and Array.every() for an array containing only the unique values, based on the comparator function, fn. The comparator function takes four arguments: the values of the two elements being compared and their indexes.

const filterNonUniqueBy = (arr, fn) =>
-  arr.filter((v, i) => arr.every((x, j) => (i == j) == fn(v, x, i, j)));
+  arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j)));
 
filterNonUniqueBy(
   [
     { id: 0, value: 'a' },