diff --git a/snippets/chainAsync.md b/snippets/chainAsync.md index bc6ca1b37..2ad3efee3 100644 --- a/snippets/chainAsync.md +++ b/snippets/chainAsync.md @@ -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(); }; diff --git a/test/chainAsync.test.js b/test/chainAsync.test.js index 44da9fef4..4a01542c5 100644 --- a/test/chainAsync.test.js +++ b/test/chainAsync.test.js @@ -28,7 +28,7 @@ test('Last function does not receive "next" argument', () => { next(); }, next => { - expect(next).toBe(null); + expect(next).toBe(undefined); } ]); });