'use strict';12Object.defineProperty(exports, "__esModule", {3value: true4});56var _onlyOnce = require('./internal/onlyOnce.js');78var _onlyOnce2 = _interopRequireDefault(_onlyOnce);910var _wrapAsync = require('./internal/wrapAsync.js');1112var _wrapAsync2 = _interopRequireDefault(_wrapAsync);1314var _awaitify = require('./internal/awaitify.js');1516var _awaitify2 = _interopRequireDefault(_awaitify);1718function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }1920/**21* The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in22* the order of operations, the arguments `test` and `iteratee` are switched.23*24* `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.25*26* @name doWhilst27* @static28* @memberOf module:ControlFlow29* @method30* @see [async.whilst]{@link module:ControlFlow.whilst}31* @category Control Flow32* @param {AsyncFunction} iteratee - A function which is called each time `test`33* passes. Invoked with (callback).34* @param {AsyncFunction} test - asynchronous truth test to perform after each35* execution of `iteratee`. Invoked with (...args, callback), where `...args` are the36* non-error args from the previous callback of `iteratee`.37* @param {Function} [callback] - A callback which is called after the test38* function has failed and repeated execution of `iteratee` has stopped.39* `callback` will be passed an error and any arguments passed to the final40* `iteratee`'s callback. Invoked with (err, [results]);41* @returns {Promise} a promise, if no callback is passed42*/43function doWhilst(iteratee, test, callback) {44callback = (0, _onlyOnce2.default)(callback);45var _fn = (0, _wrapAsync2.default)(iteratee);46var _test = (0, _wrapAsync2.default)(test);47var results;4849function next(err, ...args) {50if (err) return callback(err);51if (err === false) return;52results = args;53_test(...args, check);54}5556function check(err, truth) {57if (err) return callback(err);58if (err === false) return;59if (!truth) return callback(null, ...results);60_fn(next);61}6263return check(null, true);64}6566exports.default = (0, _awaitify2.default)(doWhilst, 3);67module.exports = exports['default'];6869