doUntil.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = doUntil;
  6. var _doWhilst = require('./doWhilst');
  7. var _doWhilst2 = _interopRequireDefault(_doWhilst);
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
  11. * argument ordering differs from `until`.
  12. *
  13. * @name doUntil
  14. * @static
  15. * @memberOf module:ControlFlow
  16. * @method
  17. * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
  18. * @category Control Flow
  19. * @param {AsyncFunction} iteratee - An async function which is called each time
  20. * `test` fails. Invoked with (callback).
  21. * @param {Function} test - synchronous truth test to perform after each
  22. * execution of `iteratee`. Invoked with any non-error callback results of
  23. * `iteratee`.
  24. * @param {Function} [callback] - A callback which is called after the test
  25. * function has passed and repeated execution of `iteratee` has stopped. `callback`
  26. * will be passed an error and any arguments passed to the final `iteratee`'s
  27. * callback. Invoked with (err, [results]);
  28. */
  29. function doUntil(iteratee, test, callback) {
  30. (0, _doWhilst2.default)(iteratee, function () {
  31. return !test.apply(this, arguments);
  32. }, callback);
  33. }
  34. module.exports = exports['default'];