summaryrefslogtreecommitdiff
path: root/lib/whilst.js
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2018-09-30 17:00:10 -0700
committerGitHub <noreply@github.com>2018-09-30 17:00:10 -0700
commit8aecf108b3922bc5211036706a0f6f75e02bd42b (patch)
tree0f7b6bee315231ef4aefdfbee154822921de231f /lib/whilst.js
parentdf41256f49c9bb3126e035c95aca7860329b6acf (diff)
downloadasync-8aecf108b3922bc5211036706a0f6f75e02bd42b.tar.gz
feat: await-able Async methods (#1572)
* make each and family awaitable * dont pretend they're AsyncFunctions * check errors * ensure function name is preserved somehow * awaitable concat * awaitable detect * awaitable every/filter * awaitable groupBy * awaitable map/mapValues * awaitable reduce * awaitable reject * awaitable some * awaitable transform * awaitable times * awaitable auto * awaitable compose/seq * awaitable whilst/until (lol) * awaitable forever * awaitable parallel/race * awaitable retry * awaitable series (lol) * awaitable tryEach * awaitable waterfall (lol) * lint * cleanup, remove noop and unused internal functions
Diffstat (limited to 'lib/whilst.js')
-rw-r--r--lib/whilst.js10
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)