basant307/AI_Governance_Project
045
1'use strict';2 3Object.defineProperty(exports, "__esModule", {4 value: true5});6exports.default = doUntil;7 8var _doWhilst = require('./doWhilst.js');9 10var _doWhilst2 = _interopRequireDefault(_doWhilst);11 12var _wrapAsync = require('./internal/wrapAsync.js');13 14var _wrapAsync2 = _interopRequireDefault(_wrapAsync);15 16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }17 18/**19 * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the20 * argument ordering differs from `until`.21 *22 * @name doUntil23 * @static24 * @memberOf module:ControlFlow25 * @method26 * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}27 * @category Control Flow28 * @param {AsyncFunction} iteratee - An async function which is called each time29 * `test` fails. Invoked with (callback).30 * @param {AsyncFunction} test - asynchronous truth test to perform after each31 * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the32 * non-error args from the previous callback of `iteratee`33 * @param {Function} [callback] - A callback which is called after the test34 * function has passed and repeated execution of `iteratee` has stopped. `callback`35 * will be passed an error and any arguments passed to the final `iteratee`'s36 * callback. Invoked with (err, [results]);37 * @returns {Promise} a promise, if no callback is passed38 */39function doUntil(iteratee, test, callback) {40 const _test = (0, _wrapAsync2.default)(test);41 return (0, _doWhilst2.default)(iteratee, (...args) => {42 const cb = args.pop();43 _test(...args, (err, truth) => cb(err, !truth));44 }, callback);45}46module.exports = exports.default;