diff options
author | Alex Early <alexander.early@gmail.com> | 2018-07-01 17:12:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-01 17:12:06 -0700 |
commit | 53f613039af68353371c2953446fa8084b3fc86b (patch) | |
tree | bd6d4e25cc30c6321c7b0810d86e1049b43764eb /lib/eachOf.js | |
parent | 2a135a422f5da6ab6c8d242b2428828bb51eb1f8 (diff) | |
download | async-53f613039af68353371c2953446fa8084b3fc86b.tar.gz |
feat: Canceling flows (#1542)
* cancelable foreach
* cancelable waterfall
* cancellable auto
* fix lint
* fix tests
* cancelable whilst/until/during/forever
* fix waterfall test. It WILL get there
* docs
* auto should not start other tasks once canceled
* simplify waterfall, add test for arrays
* simplify eachOf
* cancelable retry
* cancelable eachOf for arrays
* revert test tweak
Diffstat (limited to 'lib/eachOf.js')
-rw-r--r-- | lib/eachOf.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/eachOf.js b/lib/eachOf.js index bb9edfa..5dbeb81 100644 --- a/lib/eachOf.js +++ b/lib/eachOf.js @@ -12,12 +12,17 @@ function eachOfArrayLike(coll, iteratee, callback) { callback = once(callback || noop); var index = 0, completed = 0, - length = coll.length; + length = coll.length, + canceled = false; if (length === 0) { callback(null); } function iteratorCallback(err, value) { + if (err === false) { + canceled = true + } + if (canceled === true) return if (err) { callback(err); } else if ((++completed === length) || value === breakLoop) { |