Server IP : 85.214.239.14 / Your IP : 18.118.0.48 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/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/async/ |
Upload File : |
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = reflectAll; var _reflect = require('./reflect.js'); var _reflect2 = _interopRequireDefault(_reflect); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * A helper function that wraps an array or an object of functions with `reflect`. * * @name reflectAll * @static * @memberOf module:Utils * @method * @see [async.reflect]{@link module:Utils.reflect} * @category Util * @param {Array|Object|Iterable} tasks - The collection of * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. * @returns {Array} Returns an array of async functions, each wrapped in * `async.reflect` * @example * * let tasks = [ * function(callback) { * setTimeout(function() { * callback(null, 'one'); * }, 200); * }, * function(callback) { * // do some more stuff but error ... * callback(new Error('bad stuff happened')); * }, * function(callback) { * setTimeout(function() { * callback(null, 'two'); * }, 100); * } * ]; * * async.parallel(async.reflectAll(tasks), * // optional callback * function(err, results) { * // values * // results[0].value = 'one' * // results[1].error = Error('bad stuff happened') * // results[2].value = 'two' * }); * * // an example using an object instead of an array * let tasks = { * one: function(callback) { * setTimeout(function() { * callback(null, 'one'); * }, 200); * }, * two: function(callback) { * callback('two'); * }, * three: function(callback) { * setTimeout(function() { * callback(null, 'three'); * }, 100); * } * }; * * async.parallel(async.reflectAll(tasks), * // optional callback * function(err, results) { * // values * // results.one.value = 'one' * // results.two.error = 'two' * // results.three.value = 'three' * }); */ function reflectAll(tasks) { var results; if (Array.isArray(tasks)) { results = tasks.map(_reflect2.default); } else { results = {}; Object.keys(tasks).forEach(key => { results[key] = _reflect2.default.call(this, tasks[key]); }); } return results; } module.exports = exports.default;