Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / form-data / node_modules / async / doWhilst.js
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 _rest = require('./internal/rest');
13
14 var _rest2 = _interopRequireDefault(_rest);
15
16 var _onlyOnce = require('./internal/onlyOnce');
17
18 var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
19
20 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22 /**
23  * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
24  * the order of operations, the arguments `test` and `iteratee` are switched.
25  *
26  * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
27  *
28  * @name doWhilst
29  * @static
30  * @memberOf module:ControlFlow
31  * @method
32  * @see [async.whilst]{@link module:ControlFlow.whilst}
33  * @category Control Flow
34  * @param {Function} iteratee - A function which is called each time `test`
35  * passes. The function is passed a `callback(err)`, which must be called once
36  * it has completed with an optional `err` argument. Invoked with (callback).
37  * @param {Function} test - synchronous truth test to perform after each
38  * execution of `iteratee`. Invoked with the non-error callback results of 
39  * `iteratee`.
40  * @param {Function} [callback] - A callback which is called after the test
41  * function has failed and repeated execution of `iteratee` has stopped.
42  * `callback` will be passed an error and any arguments passed to the final
43  * `iteratee`'s callback. Invoked with (err, [results]);
44  */
45 function doWhilst(iteratee, test, callback) {
46     callback = (0, _onlyOnce2.default)(callback || _noop2.default);
47     var next = (0, _rest2.default)(function (err, args) {
48         if (err) return callback(err);
49         if (test.apply(this, args)) return iteratee(next);
50         callback.apply(null, [null].concat(args));
51     });
52     iteratee(next);
53 }
54 module.exports = exports['default'];