Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / form-data / node_modules / async / doDuring.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4     value: true
5 });
6 exports.default = doDuring;
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 [`during`]{@link module:ControlFlow.during}. To reflect the difference in
24  * the order of operations, the arguments `test` and `fn` are switched.
25  *
26  * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
27  * @name doDuring
28  * @static
29  * @memberOf module:ControlFlow
30  * @method
31  * @see [async.during]{@link module:ControlFlow.during}
32  * @category Control Flow
33  * @param {Function} fn - A function which is called each time `test` passes.
34  * The function is passed a `callback(err)`, which must be called once it has
35  * completed with an optional `err` argument. Invoked with (callback).
36  * @param {Function} test - asynchronous truth test to perform before each
37  * execution of `fn`. Invoked with (...args, callback), where `...args` are the
38  * non-error args from the previous callback of `fn`.
39  * @param {Function} [callback] - A callback which is called after the test
40  * function has failed and repeated execution of `fn` has stopped. `callback`
41  * will be passed an error if one occured, otherwise `null`.
42  */
43 function doDuring(fn, test, callback) {
44     callback = (0, _onlyOnce2.default)(callback || _noop2.default);
45
46     var next = (0, _rest2.default)(function (err, args) {
47         if (err) return callback(err);
48         args.push(check);
49         test.apply(this, args);
50     });
51
52     function check(err, truth) {
53         if (err) return callback(err);
54         if (!truth) return callback(null);
55         fn(next);
56     }
57
58     check(null, true);
59 }
60 module.exports = exports['default'];