Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / form-data / node_modules / async / forever.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4     value: true
5 });
6 exports.default = forever;
7
8 var _noop = require('lodash/noop');
9
10 var _noop2 = _interopRequireDefault(_noop);
11
12 var _onlyOnce = require('./internal/onlyOnce');
13
14 var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
15
16 var _ensureAsync = require('./ensureAsync');
17
18 var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
19
20 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22 /**
23  * Calls the asynchronous function `fn` with a callback parameter that allows it
24  * to call itself again, in series, indefinitely.
25
26  * If an error is passed to the
27  * callback then `errback` is called with the error, and execution stops,
28  * otherwise it will never be called.
29  *
30  * @name forever
31  * @static
32  * @memberOf module:ControlFlow
33  * @method
34  * @category Control Flow
35  * @param {Function} fn - a function to call repeatedly. Invoked with (next).
36  * @param {Function} [errback] - when `fn` passes an error to it's callback,
37  * this function will be called, and execution stops. Invoked with (err).
38  * @example
39  *
40  * async.forever(
41  *     function(next) {
42  *         // next is suitable for passing to things that need a callback(err [, whatever]);
43  *         // it will result in this function being called again.
44  *     },
45  *     function(err) {
46  *         // if next is called with a value in its first parameter, it will appear
47  *         // in here as 'err', and execution will stop.
48  *     }
49  * );
50  */
51 function forever(fn, errback) {
52     var done = (0, _onlyOnce2.default)(errback || _noop2.default);
53     var task = (0, _ensureAsync2.default)(fn);
54
55     function next(err) {
56         if (err) return done(err);
57         task(next);
58     }
59     next();
60 }
61 module.exports = exports['default'];