123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- 'use strict';
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _onlyOnce = require('./internal/onlyOnce.js');
- var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
- var _wrapAsync = require('./internal/wrapAsync.js');
- var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
- var _awaitify = require('./internal/awaitify.js');
- var _awaitify2 = _interopRequireDefault(_awaitify);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function whilst(test, iteratee, callback) {
- callback = (0, _onlyOnce2.default)(callback);
- var _fn = (0, _wrapAsync2.default)(iteratee);
- var _test = (0, _wrapAsync2.default)(test);
- var results = [];
- function next(err, ...rest) {
- if (err) return callback(err);
- results = rest;
- if (err === false) return;
- _test(check);
- }
- function check(err, truth) {
- if (err) return callback(err);
- if (err === false) return;
- if (!truth) return callback(null, ...results);
- _fn(next);
- }
- return _test(check);
- }
- exports.default = (0, _awaitify2.default)(whilst, 3);
- module.exports = exports.default;
|