UNPKG

1.45 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = until;
7
8var _whilst = require('./whilst');
9
10var _whilst2 = _interopRequireDefault(_whilst);
11
12function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14/**
15 * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
16 * stopped, or an error occurs. `callback` will be passed an error and any
17 * arguments passed to the final `iteratee`'s callback.
18 *
19 * The inverse of [whilst]{@link module:ControlFlow.whilst}.
20 *
21 * @name until
22 * @static
23 * @memberOf module:ControlFlow
24 * @method
25 * @see [async.whilst]{@link module:ControlFlow.whilst}
26 * @category Control Flow
27 * @param {Function} test - synchronous truth test to perform before each
28 * execution of `iteratee`. Invoked with ().
29 * @param {AsyncFunction} iteratee - An async function which is called each time
30 * `test` fails. Invoked with (callback).
31 * @param {Function} [callback] - A callback which is called after the test
32 * function has passed and repeated execution of `iteratee` has stopped. `callback`
33 * will be passed an error and any arguments passed to the final `iteratee`'s
34 * callback. Invoked with (err, [results]);
35 */
36function until(test, iteratee, callback) {
37 (0, _whilst2.default)(function () {
38 return !test.apply(this, arguments);
39 }, iteratee, callback);
40}
41module.exports = exports['default'];
\No newline at end of file