Addressed comments by @skatcat31
This commit is contained in:
@ -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();
|
||||
};
|
||||
|
||||
@ -28,7 +28,7 @@ test('Last function does not receive "next" argument', () => {
|
||||
next();
|
||||
},
|
||||
next => {
|
||||
expect(next).toBe(null);
|
||||
expect(next).toBe(undefined);
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user