diff options
Diffstat (limited to 'lib/doWhilst.js')
-rw-r--r-- | lib/doWhilst.js | 4 |
1 files changed, 3 insertions, 1 deletions
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); |