Travis build: 788 [ci skip]

This commit is contained in:
Travis CI
2018-01-01 15:11:09 +00:00
parent a0d4e6322c
commit 2e3e5b2d1a
4 changed files with 74 additions and 1 deletions

View File

@ -271,6 +271,15 @@
</details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`reducedFilter`](#reducedfilter)
</details>
---
## 🔌 Adapter
@ -4243,6 +4252,7 @@ Use the spread operator (`...`) to check if the provided argument is iterable in
const isArrayLike = val =>
try {return [...val], true; }
catch (e) { return false; }
@ -4703,6 +4713,45 @@ yesNo('Foo', true); // true
<br>[⬆ Back to top](#table-of-contents)
---
## _Uncategorized_
### reducedFilter
Filter an array of objects based on a condition while also filtering out unspecified keys.
Use `Array.filter()` to filter the array based on the predicate `fn` so that it returns the objects for which the condition returned a truthy value.
On the filtered array, use `Array.map()` to return the new object using `Array.reduce()` to filter out the keys which were not supplied as the `keys` argument.
```js
const reducedFilter = (data, keys, fn) =>
data.filter(fn).map(el =>
keys.reduce((acc, key) => {
acc[key] = el[key];
return acc;
}, {})
);
```
```js
const data = [
{
id: 1,
name: 'john',
age: 24
},
{
id: 2,
name: 'mike',
age: 50
}
];
reducedFilter(data, ['id', 'name'], item => item.age > 24); // [{ id: 2, name: 'mike'}]
```
<br>[⬆ back to top](#table-of-contents)
## Collaborators

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@ Use the spread operator (`...`) to check if the provided argument is iterable in
const isArrayLike = val =>
try {return [...val], true; }
catch (e) { return false; }

View File

@ -115,6 +115,7 @@ randomIntegerInRange:math
randomNumberInRange:math
readFileLines:node
redirect:browser
reducedFilter:uncategorized
remove:array
repeatString:string
reverseString:string