diff options
Diffstat (limited to 'lib/whilst.js')
-rw-r--r-- | lib/whilst.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/whilst.js b/lib/whilst.js index d42e6a7..1013d37 100644 --- a/lib/whilst.js +++ b/lib/whilst.js @@ -1,7 +1,6 @@ -import noop from './internal/noop'; - import onlyOnce from './internal/onlyOnce'; import wrapAsync from './internal/wrapAsync'; +import awaitify from './internal/awaitify'; /** * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when @@ -20,7 +19,7 @@ import wrapAsync from './internal/wrapAsync'; * function has failed and repeated execution of `iteratee` has stopped. `callback` * will be passed an error and any arguments passed to the final `iteratee`'s * callback. Invoked with (err, [results]); - * @returns undefined + * @returns {Promise} a promise, if no callback is passed * @example * * var count = 0; @@ -37,8 +36,8 @@ import wrapAsync from './internal/wrapAsync'; * } * ); */ -export default function whilst(test, iteratee, callback) { - callback = onlyOnce(callback || noop); +function whilst(test, iteratee, callback) { + callback = onlyOnce(callback); var _fn = wrapAsync(iteratee); var _test = wrapAsync(test); var results @@ -59,3 +58,4 @@ export default function whilst(test, iteratee, callback) { return _test(check); } +export default awaitify(whilst, 3) |