Merge branch 'master' into compact-whitespace

This commit is contained in:
Angelos Chalaris
2018-12-15 15:01:27 +02:00
committed by GitHub
18 changed files with 2086 additions and 2024 deletions

View File

@ -7,7 +7,11 @@ Loop through an array of functions containing asynchronous events, calling `next
```js
const chainAsync = fns => {
let curr = 0;
const next = () => fns[curr++](next);
const last = fns[fns.length - 1];
const next = () => {
const fn = fns[curr++];
fn === last ? fn() : fn(next);
};
next();
};
```
@ -20,6 +24,10 @@ chainAsync([
},
next => {
console.log('1 second');
setTimeout(next, 1000);
},
() => {
console.log('2 second');
}
]);
```

View File

@ -11,6 +11,7 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr
```
```js
const sum = pipeAsyncFunctions(
x => x + 1,
x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),

View File

@ -6,6 +6,7 @@ Use `Array.prototype.filter()` to find array elements that return truthy values
The `func` is invoked with three arguments (`value, index, array`).
```js
const remove = (arr, func) =>
Array.isArray(arr)
? arr.filter(func).reduce((acc, val) => {