diff options
-rw-r--r-- | lib/doDuring.js | 3 | ||||
-rw-r--r-- | lib/doWhilst.js | 4 | ||||
-rw-r--r-- | lib/during.js | 3 | ||||
-rw-r--r-- | lib/whilst.js | 4 |
4 files changed, 10 insertions, 4 deletions
diff --git a/lib/doDuring.js b/lib/doDuring.js index 14a5ae1..c536f30 100644 --- a/lib/doDuring.js +++ b/lib/doDuring.js @@ -1,5 +1,6 @@ import noop from 'lodash/noop'; import rest from 'lodash/rest'; +import onlyOnce from './internal/onlyOnce'; /** * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in @@ -23,7 +24,7 @@ import rest from 'lodash/rest'; * will be passed an error if one occured, otherwise `null`. */ export default function doDuring(fn, test, callback) { - callback = callback || noop; + callback = onlyOnce(callback || noop); var next = rest(function(err, args) { if (err) return callback(err); diff --git a/lib/doWhilst.js b/lib/doWhilst.js index 163c6a9..ee8f12a 100644 --- a/lib/doWhilst.js +++ b/lib/doWhilst.js @@ -1,6 +1,8 @@ import noop from 'lodash/noop'; import rest from 'lodash/rest'; +import onlyOnce from './internal/onlyOnce'; + /** * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in * the order of operations, the arguments `test` and `iteratee` are switched. @@ -25,7 +27,7 @@ import rest from 'lodash/rest'; * `iteratee`'s callback. Invoked with (err, [results]); */ export default function doWhilst(iteratee, test, callback) { - callback = callback || noop; + callback = onlyOnce(callback || noop); var next = rest(function(err, args) { if (err) return callback(err); if (test.apply(this, args)) return iteratee(next); diff --git a/lib/during.js b/lib/during.js index e25d90a..549ad44 100644 --- a/lib/during.js +++ b/lib/during.js @@ -1,4 +1,5 @@ import noop from 'lodash/noop'; +import onlyOnce from './internal/onlyOnce'; /** * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that @@ -38,7 +39,7 @@ import noop from 'lodash/noop'; * ); */ export default function during(test, fn, callback) { - callback = callback || noop; + callback = onlyOnce(callback || noop); function next(err) { if (err) return callback(err); diff --git a/lib/whilst.js b/lib/whilst.js index e11a141..9012144 100644 --- a/lib/whilst.js +++ b/lib/whilst.js @@ -1,6 +1,8 @@ import noop from 'lodash/noop'; import rest from 'lodash/rest'; +import onlyOnce from './internal/onlyOnce'; + /** * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when * stopped, or an error occurs. @@ -37,7 +39,7 @@ import rest from 'lodash/rest'; * ); */ export default function whilst(test, iteratee, callback) { - callback = callback || noop; + callback = onlyOnce(callback || noop); if (!test()) return callback(null); var next = rest(function(err, args) { if (err) return callback(err); |