3 Object.defineProperty(exports, "__esModule", {
6 exports.default = during;
8 var _noop = require('lodash/noop');
10 var _noop2 = _interopRequireDefault(_noop);
12 var _onlyOnce = require('./internal/onlyOnce');
14 var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
16 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
20 * is passed a callback in the form of `function (err, truth)`. If error is
21 * passed to `test` or `fn`, the main callback is immediately called with the
26 * @memberOf module:ControlFlow
28 * @see [async.whilst]{@link module:ControlFlow.whilst}
29 * @category Control Flow
30 * @param {Function} test - asynchronous truth test to perform before each
31 * execution of `fn`. Invoked with (callback).
32 * @param {Function} fn - A function which is called each time `test` passes.
33 * The function is passed a `callback(err)`, which must be called once it has
34 * completed with an optional `err` argument. Invoked with (callback).
35 * @param {Function} [callback] - A callback which is called after the test
36 * function has failed and repeated execution of `fn` has stopped. `callback`
37 * will be passed an error, if one occured, otherwise `null`.
43 * function (callback) {
44 * return callback(null, count < 5);
46 * function (callback) {
48 * setTimeout(callback, 1000);
51 * // 5 seconds have passed
55 function during(test, fn, callback) {
56 callback = (0, _onlyOnce2.default)(callback || _noop2.default);
59 if (err) return callback(err);
63 function check(err, truth) {
64 if (err) return callback(err);
65 if (!truth) return callback(null);
71 module.exports = exports['default'];