From c908876d7b5fdd380cac5f764b532249179d70a5 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Thu, 4 Jul 2019 20:26:55 +0000 Subject: [PATCH] Travis build: 1272 --- README.md | 13 +++++++------ docs/function.html | 1 + docs/index.html | 6 +++--- docs/object.html | 4 ++-- snippets/checkProp.md | 1 + 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c9d595d3d..3f8db9a45 100644 --- a/README.md +++ b/README.md @@ -984,9 +984,9 @@ chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]] ### compact -Removes falsey values from an array. +Removes falsy values from an array. -Use `Array.prototype.filter()` to filter out falsey values (`false`, `null`, `0`, `""`, `undefined`, and `NaN`). +Use `Array.prototype.filter()` to filter out falsy values (`false`, `null`, `0`, `""`, `undefined`, and `NaN`). ```js const compact = arr => arr.filter(Boolean); @@ -1340,7 +1340,7 @@ filterNonUniqueBy( Returns the last element for which the provided function returns a truthy value. -Use `Array.prototype.filter()` to remove elements for which `fn` returns falsey values, `Array.prototype.pop()` to get the last one. +Use `Array.prototype.filter()` to remove elements for which `fn` returns falsy values, `Array.prototype.pop()` to get the last one. ```js const findLast = (arr, fn) => arr.filter(fn).pop(); @@ -1362,7 +1362,7 @@ findLast([1, 2, 3, 4], n => n % 2 === 1); // 3 Returns the index of the last element for which the provided function returns a truthy value. Use `Array.prototype.map()` to map each element to an array with its index and value. -Use `Array.prototype.filter()` to remove elements for which `fn` returns falsey values, `Array.prototype.pop()` to get the last one. +Use `Array.prototype.filter()` to remove elements for which `fn` returns falsy values, `Array.prototype.pop()` to get the last one. ```js const findLastIndex = (arr, fn) => @@ -4732,6 +4732,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true @@ -7593,7 +7594,7 @@ omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 } ### omitBy -Creates an object composed of the properties the given function returns falsey for. The function is invoked with two arguments: (value, key). +Creates an object composed of the properties the given function returns falsy for. The function is invoked with two arguments: (value, key). Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a truthy value. Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs. @@ -7675,7 +7676,7 @@ pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 } Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key). -Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsey value. +Use `Object.keys(obj)` and `Array.prototype.filter()`to remove the keys for which `fn` returns a falsy value. Use `Array.prototype.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs. ```js diff --git a/docs/function.html b/docs/function.html index 71d58398e..c2a440243 100644 --- a/docs/function.html +++ b/docs/function.html @@ -150,6 +150,7 @@ console.log< + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/docs/index.html b/docs/index.html index 8028b8275..ba1644b7c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -120,7 +120,7 @@ arr.slice(i * size, i * size + size) );
chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]]
-

compact

Removes falsey values from an array.

Use Array.prototype.filter() to filter out falsey values (false, null, 0, "", undefined, and NaN).

const compact = arr => arr.filter(Boolean);
+

compact

Removes falsy values from an array.

Use Array.prototype.filter() to filter out falsy values (false, null, 0, "", undefined, and NaN).

const compact = arr => arr.filter(Boolean);
 
compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a', 's', 34 ]
 

countBy

Groups the elements of an array based on the given function and returns the count of elements in each group.

Use Array.prototype.map() to map the values of an array to a function or property name. Use Array.prototype.reduce() to create an object, where the keys are produced from the mapped results.

const countBy = (arr, fn) =>
   arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => {
@@ -183,9 +183,9 @@
   ],
   (a, b) => a.id == b.id
 ); // [ { id: 2, value: 'c' } ]
-

findLast

Returns the last element for which the provided function returns a truthy value.

Use Array.prototype.filter() to remove elements for which fn returns falsey values, Array.prototype.pop() to get the last one.

const findLast = (arr, fn) => arr.filter(fn).pop();
+

findLast

Returns the last element for which the provided function returns a truthy value.

Use Array.prototype.filter() to remove elements for which fn returns falsy values, Array.prototype.pop() to get the last one.

const findLast = (arr, fn) => arr.filter(fn).pop();
 
findLast([1, 2, 3, 4], n => n % 2 === 1); // 3
-

findLastIndex

Returns the index of the last element for which the provided function returns a truthy value.

Use Array.prototype.map() to map each element to an array with its index and value. Use Array.prototype.filter() to remove elements for which fn returns falsey values, Array.prototype.pop() to get the last one.

const findLastIndex = (arr, fn) =>
+

findLastIndex

Returns the index of the last element for which the provided function returns a truthy value.

Use Array.prototype.map() to map each element to an array with its index and value. Use Array.prototype.filter() to remove elements for which fn returns falsy values, Array.prototype.pop() to get the last one.

const findLastIndex = (arr, fn) =>
   arr
     .map((val, i) => [i, val])
     .filter(([i, val]) => fn(val, i, arr))
diff --git a/docs/object.html b/docs/object.html
index 243a0d0c1..a74236aa9 100644
--- a/docs/object.html
+++ b/docs/object.html
@@ -361,7 +361,7 @@ Foo.prototypefilter(k => !arr.includes(k))
     .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
 
omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 }
-

omitBy

Creates an object composed of the properties the given function returns falsey for. The function is invoked with two arguments: (value, key).

Use Object.keys(obj) and Array.prototype.filter()to remove the keys for which fn returns a truthy value. Use Array.prototype.reduce() to convert the filtered keys back to an object with the corresponding key-value pairs.

const omitBy = (obj, fn) =>
+

omitBy

Creates an object composed of the properties the given function returns falsy for. The function is invoked with two arguments: (value, key).

Use Object.keys(obj) and Array.prototype.filter()to remove the keys for which fn returns a truthy value. Use Array.prototype.reduce() to convert the filtered keys back to an object with the corresponding key-value pairs.

const omitBy = (obj, fn) =>
   Object.keys(obj)
     .filter(k => !fn(obj[k], k))
     .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
@@ -382,7 +382,7 @@ Foo.prototype

pick

Picks the key-value pairs corresponding to the given keys from an object.

Use Array.prototype.reduce() to convert the filtered/picked keys back to an object with the corresponding key-value pairs if the key exists in the object.

const pick = (obj, arr) =>
   arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
 
pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 }
-

pickBy

Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key).

Use Object.keys(obj) and Array.prototype.filter()to remove the keys for which fn returns a falsey value. Use Array.prototype.reduce() to convert the filtered keys back to an object with the corresponding key-value pairs.

const pickBy = (obj, fn) =>
+

pickBy

Creates an object composed of the properties the given function returns truthy for. The function is invoked with two arguments: (value, key).

Use Object.keys(obj) and Array.prototype.filter()to remove the keys for which fn returns a falsy value. Use Array.prototype.reduce() to convert the filtered keys back to an object with the corresponding key-value pairs.

const pickBy = (obj, fn) =>
   Object.keys(obj)
     .filter(k => fn(obj[k], k))
     .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
diff --git a/snippets/checkProp.md b/snippets/checkProp.md
index 4644eb666..ef740e3e8 100644
--- a/snippets/checkProp.md
+++ b/snippets/checkProp.md
@@ -15,6 +15,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
 
 
 
+
 const lengthIs4 = checkProp(l => l === 4, 'length');
 lengthIs4([]); // false
 lengthIs4([1,2,3,4]); // true