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