From 0668b1abdeeda52896e7f0bfa99b429a17eb2b0f Mon Sep 17 00:00:00 2001 From: RobertAKARobin Date: Wed, 12 Dec 2018 09:23:55 -0600 Subject: [PATCH] Addressed comments by @skatcat31 --- snippets/chainAsync.md | 5 +++-- test/chainAsync.test.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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); } ]); });