Addressed comments by @skatcat31

This commit is contained in:
RobertAKARobin
2018-12-12 09:23:55 -06:00
parent 881ce6bb04
commit 0668b1abde
2 changed files with 4 additions and 3 deletions

View File

@ -6,10 +6,11 @@ Loop through an array of functions containing asynchronous events, calling `next
```js
const chainAsync = fns => {
let curr = 0, last = fns[fns.length - 1];
let curr = 0;
const last = fns[fns.length - 1];
const next = () => {
const fn = fns[curr++]
fn(fn === last ? null : next)
fn === last ? fn(undefined) : fn(next);
}
next();
};

View File

@ -28,7 +28,7 @@ test('Last function does not receive "next" argument', () => {
next();
},
next => {
expect(next).toBe(null);
expect(next).toBe(undefined);
}
]);
});