Fix chainAsync() throwing an error

This commit is contained in:
Oscar Shrimpton
2018-01-30 19:30:03 +00:00
parent bfa016cef1
commit ecefcc40af

View File

@ -4,10 +4,12 @@ Chains asynchronous functions.
Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed. Loop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed.
The tenerary function checks the next function exists before calling it, otherwise it will exit.
```js ```js
const chainAsync = fns => { const chainAsync = fns => {
let curr = 0; let curr = 0;
const next = () => fns[curr++](next); const next = () => fns[++curr] ? fns[curr](next) : false;
next(); next();
}; };
``` ```