1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = doWhilst;
|
7 |
|
8 | var _noop = require('lodash/noop');
|
9 |
|
10 | var _noop2 = _interopRequireDefault(_noop);
|
11 |
|
12 | var _slice = require('./internal/slice');
|
13 |
|
14 | var _slice2 = _interopRequireDefault(_slice);
|
15 |
|
16 | var _onlyOnce = require('./internal/onlyOnce');
|
17 |
|
18 | var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
|
19 |
|
20 | var _wrapAsync = require('./internal/wrapAsync');
|
21 |
|
22 | var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
23 |
|
24 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | function doWhilst(iteratee, test, callback) {
|
49 | callback = (0, _onlyOnce2.default)(callback || _noop2.default);
|
50 | var _iteratee = (0, _wrapAsync2.default)(iteratee);
|
51 | var next = function (err /*, ...args*/) {
|
52 | if (err) return callback(err);
|
53 | var args = (0, _slice2.default)(arguments, 1);
|
54 | if (test.apply(this, args)) return _iteratee(next);
|
55 | callback.apply(null, [null].concat(args));
|
56 | };
|
57 | _iteratee(next);
|
58 | }
|
59 | module.exports = exports['default']; |
\ | No newline at end of file |