Server IP : 85.214.239.14 / Your IP : 3.145.92.33 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/3/cwd/proc/2/task/2/cwd/lib/node_modules/pm2/node_modules/async/ |
Upload File : |
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _once = require('./internal/once.js'); var _once2 = _interopRequireDefault(_once); 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 }; } /** * Runs the `tasks` array of functions in series, each passing their results to * the next in the array. However, if any of the `tasks` pass an error to their * own callback, the next function is not executed, and the main `callback` is * immediately called with the error. * * @name waterfall * @static * @memberOf module:ControlFlow * @method * @category Control Flow * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} * to run. * Each function should complete with any number of `result` values. * The `result` values will be passed as arguments, in order, to the next task. * @param {Function} [callback] - An optional callback to run once all the * functions have completed. This will be passed the results of the last task's * callback. Invoked with (err, [results]). * @returns {Promise} a promise, if a callback is omitted * @example * * async.waterfall([ * function(callback) { * callback(null, 'one', 'two'); * }, * function(arg1, arg2, callback) { * // arg1 now equals 'one' and arg2 now equals 'two' * callback(null, 'three'); * }, * function(arg1, callback) { * // arg1 now equals 'three' * callback(null, 'done'); * } * ], function (err, result) { * // result now equals 'done' * }); * * // Or, with named functions: * async.waterfall([ * myFirstFunction, * mySecondFunction, * myLastFunction, * ], function (err, result) { * // result now equals 'done' * }); * function myFirstFunction(callback) { * callback(null, 'one', 'two'); * } * function mySecondFunction(arg1, arg2, callback) { * // arg1 now equals 'one' and arg2 now equals 'two' * callback(null, 'three'); * } * function myLastFunction(arg1, callback) { * // arg1 now equals 'three' * callback(null, 'done'); * } */ function waterfall(tasks, callback) { callback = (0, _once2.default)(callback); if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); if (!tasks.length) return callback(); var taskIndex = 0; function nextTask(args) { var task = (0, _wrapAsync2.default)(tasks[taskIndex++]); task(...args, (0, _onlyOnce2.default)(next)); } function next(err, ...args) { if (err === false) return; if (err || taskIndex === tasks.length) { return callback(err, ...args); } nextTask(args); } nextTask([]); } exports.default = (0, _awaitify2.default)(waterfall); module.exports = exports.default;