Lines Matching refs:function

2  * Creates a continuation function with some arguments already applied.
5 * arguments passed to the returned function are added to the arguments
13 * @param {Function} fn - The function you want to eventually apply all
17 * @returns {Function} the partially-applied function
29 * function(callback) {
32 * function(callback) {
46 function apply(fn, ...args) {
50 function initialParams (fn) {
51 return function (...args/*, callback*/) {
59 var hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask;
60 var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
61 var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
63 function fallback(fn) {
67 function wrap(defer) {
86 * Take a sync function and make it async, passing its return value to a
89 * function will be passed to the wrapped function (except for the final
92 * If the function passed to `asyncify` returns a Promise, that promises's
104 * @param {Function} func - The synchronous function, or Promise-returning
105 * function to convert to an {@link AsyncFunction}.
110 * // passing a regular synchronous function
114 * function (data, next) {
120 * // passing a function returning a promise
123 * async.asyncify(function (contents) {
126 * function (model, next) {
128 * // If there was an error, this function would be skipped.
134 * var q = async.queue(async.asyncify(async function(file) {
141 function asyncify(func) {
143 return function (...args/*, callback*/) {
150 return initialParams(function (args, callback) {
158 if (result && typeof result.then === 'function') {
166 function handlePromise(promise, callback) {
174 function invokeCallback(callback, error, value) {
182 function isAsync(fn) {
186 function isAsyncGenerator(fn) {
190 function isAsyncIterable(obj) {
191 return typeof obj[Symbol.asyncIterator] === 'function';
194 function wrapAsync(asyncFn) {
195 if (typeof asyncFn !== 'function') throw new Error('expected a function')
199 // conditionally promisify a function.
201 function awaitify (asyncFn, arity = asyncFn.length) {
203 function awaitable (...args) {
204 if (typeof args[arity - 1] === 'function') {
220 function applyEach (eachfn) {
221 return function applyEach(fns, ...callArgs) {
222 const go = awaitify(function (callback) {
232 function _asyncMap(eachfn, arr, iteratee, callback) {
249 function isArrayLike(value) {
260 function once(fn) {
261 function wrapper (...args) {
271 function getIterator (coll) {
275 function createArrayIterator(coll) {
278 return function next() {
283 function createES2015Iterator(iterator) {
285 return function next() {
294 function createObjectIterator(obj) {
298 return function next() {
307 function createIterator(coll) {
316 function onlyOnce(fn) {
317 return function (...args) {
326 function asyncEachOfLimit(generator, limit, iteratee, callback) {
333 function replenish() {
357 function iterateeCallback(err, result) {
377 function handleError(err) {
408 function iterateeCallback(err, value) {
428 function replenish () {
462 * @param {AsyncFunction} iteratee - An async function to apply to each
470 function eachOfLimit$1(coll, limit, iteratee, callback) {
477 function eachOfArrayLike(coll, iteratee, callback) {
487 function iteratorCallback(err, value) {
505 function eachOfGeneric (coll, iteratee, callback) {
521 * @param {AsyncFunction} iteratee - A function to apply to each
539 * // asynchronous function that reads a json file and parses the contents as json object
540 * function parseFile(file, key, callback) {
541 * fs.readFile(file, "utf8", function(err, data) {
553 * async.forEachOf(validConfigFileMap, parseFile, function (err) {
564 * async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
618 function eachOf(coll, iteratee, callback) {
627 * the `iteratee` function. The `iteratee` is called with an item from `coll`
631 * `map` function) is immediately called with the error.
633 * Note, that since this function applies the `iteratee` to each item in
648 * @param {AsyncFunction} iteratee - An async function to apply to each item in
666 * // asynchronous function that returns the file size in bytes
667 * function getFileSizeInBytes(file, callback) {
668 * fs.stat(file, function(err, stat) {
677 * async.map(fileList, getFileSizeInBytes, function(err, results) {
688 * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) {
742 function map (coll, iteratee, callback) {
748 * Applies the provided arguments to each function in the array, calling
750 * argument, `fns`, then it will return a function which lets you pass in the
751 * arguments as if it were a single function call. If more arguments are
764 * function.
767 * @returns {AsyncFunction} - Returns a function that takes no args other than
799 * @param {AsyncFunction} iteratee - An async function to apply to each item in
806 function eachOfSeries(coll, iteratee, callback) {
821 * @param {AsyncFunction} iteratee - An async function to apply to each item in
830 function mapSeries (coll, iteratee, callback) {
847 * function.
850 * @returns {AsyncFunction} - A function, that when called, is the result of
858 function promiseCallback () {
860 function callback (err, ...args) {
875 * their requirements. Each function can optionally depend on other functions
876 * being completed first, and each function is run as soon as its requirements
886 * task function has no dependencies, it will only be passed a callback.
894 * function or an array of requirements, with the {@link AsyncFunction} itself the last item
897 * other tasks. The function receives one or two arguments:
900 * * a `callback(err, result)` function, which must be called when finished,
901 * passing an `error` (which can be `null`) and the result of the function's
916 * get_data: function(callback) {
920 * make_folder: function(callback) {
925 * write_file: ['get_data', 'make_folder', function(results, callback) {
930 * email_link: ['write_file', function(results, callback) {
934 * }, function(err, results) {
949 * get_data: function(callback) {
954 * make_folder: function(callback) {
960 * write_file: ['get_data', 'make_folder', function(results, callback) {
965 * email_link: ['write_file', function(results, callback) {
985 * get_data: function(callback) {
989 * make_folder: function(callback) {
994 * write_file: ['get_data', 'make_folder', function(results, callback) {
999 * email_link: ['write_file', function(results, callback) {
1018 function auto(tasks, concurrency, callback) {
1084 function enqueueTask(key, task) {
1088 function processQueue() {
1100 function addListener(taskName, fn) {
1109 function taskComplete(taskName) {
1116 function runTask(key, task) {
1153 function checkForDeadlocks() {
1176 function getDependents(taskName) {
1190 var FN_ARGS = /^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/;
1195 function stripComments(string) {
1222 function parseParams(func) {
1237 …* A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Depen…
1238 * tasks are specified as parameters to the function, after the usual callback
1246 * The autoInject function is purely syntactic sugar and its semantics are
1261 * the function's execution. The remaining parameters name other tasks on
1273 * get_data: function(callback) {
1277 * make_folder: function(callback) {
1282 * write_file: function(get_data, make_folder, callback) {
1287 * email_link: function(write_file, callback) {
1292 * }, function(err, results) {
1300 * // explicitly specify the names of the parameters your task function needs
1307 * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
1310 * email_link: ['write_file', function(write_file, callback) {
1314 * }, function(err, results) {
1319 function autoInject(tasks, callback) {
1336 // no dependencies, use the function as-is
1350 function newTask(results, taskCb) {
1447 function setInitial(dll, node) {
1452 function queue(worker, concurrency, payload) {
1471 function on (event, handler) {
1475 function once (event, handler) {
1483 function off (event, handler) {
1489 function trigger (event, ...args) {
1494 function _insert(data, insertAtFront, rejectOnError, callback) {
1495 if (callback != null && typeof callback !== 'function') {
1496 throw new Error('task callback must be a function');
1501 function promiseCallback (err, ...args) {
1537 function _createCB(tasks) {
1538 return function (err, ...args) {
1569 function _maybeDrain(data) {
1742 * @param {AsyncFunction} worker - An asynchronous function for processing an array
1753 * var cargo = async.cargo(function(tasks, callback) {
1761 * cargo.push({name: 'foo'}, function(err) {
1764 * cargo.push({name: 'bar'}, function(err) {
1770 function cargo(worker, payload) {
1793 * @param {AsyncFunction} worker - An asynchronous function for processing an array
1807 * var cargoQueue = async.cargoQueue(function(tasks, callback) {
1815 * cargoQueue.push({name: 'foo'}, function(err) {
1818 * cargoQueue.push({name: 'bar'}, function(err) {
1821 * cargoQueue.push({name: 'baz'}, function(err) {
1824 * cargoQueue.push({name: 'boo'}, function(err) {
1828 function cargo$1(worker, concurrency, payload) {
1834 * successive step. `memo` is the initial state of the reduction. This function
1837 * For performance reasons, it may make sense to split a call to this function
1839 * results. This function is for situations where each step in the reduction
1852 * @param {AsyncFunction} iteratee - A function applied to each item in the
1872 * // asynchronous function that computes the file size in bytes
1874 * function getFileSizeInBytes(memo, file, callback) {
1875 * fs.stat(file, function(err, stat) {
1884 * async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
1895 * async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
1949 function reduce(coll, memo, iteratee, callback) {
1962 * Version of the compose function that is more natural to read. Each function
1963 * consumes the return value of the previous function. It is the equivalent of
1966 * Each function is executed with the `this` binding of the composed function.
1975 * @returns {Function} a function that composes the `functions` in order
1980 * // This example uses `seq` function to avoid overnesting and error
1982 * app.get('/cats', function(request, response) {
1986 * function(user, fn) {
1989 * )(req.session.user_id, function (err, cats) {
1999 function seq(...functions) {
2001 return function (...args) {
2005 if (typeof cb == 'function') {
2023 * Creates a function which is a composition of the passed asynchronous
2024 * functions. Each function consumes the return value of the function that
2028 * If the last argument to the composed function is not a function, a promise
2031 * Each function is executed with the `this` binding of the composed function.
2039 * @returns {Function} an asynchronous function that is the composed
2043 * function add1(n, callback) {
2044 * setTimeout(function () {
2049 * function mul3(n, callback) {
2050 * setTimeout(function () {
2056 * add1mul3(4, function (err, result) {
2060 function compose(...args) {
2075 * @param {AsyncFunction} iteratee - An async function to apply to each item in
2084 function mapLimit (coll, limit, iteratee, callback) {
2101 * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
2105 * containing the concatenated results of the `iteratee` function. Invoked with
2109 function concatLimit(coll, limit, iteratee, callback) {
2133 * the original order of `coll` passed to the `iteratee` function.
2142 * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
2146 * containing the concatenated results of the `iteratee` function. Invoked with
2160 * async.concat(directoryList, fs.readdir, function(err, results) {
2170 * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
2223 function concat(coll, iteratee, callback) {
2239 * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
2244 * containing the concatenated results of the `iteratee` function. Invoked with
2248 function concatSeries(coll, iteratee, callback) {
2254 * Returns a function that when called, calls-back with the values provided.
2255 …* Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plug…
2265 * @returns {AsyncFunction} Returns a function that when invoked, automatically
2271 * function (value, next) {
2280 * function (fileData, next) {
2289 * launchServer: ["hostname", "port", function (options, cb) {
2295 function constant(...args) {
2296 return function (...ignoredArgs/*, callback*/) {
2302 function _createTester(check, getResult) {
2357 * // asynchronous function that checks if a file exists
2358 * function fileExists(file, callback) {
2365 * function(err, result) {
2396 function detect(coll, iteratee, callback) {
2424 function detectLimit(coll, limit, iteratee, callback) {
2450 function detectSeries(coll, iteratee, callback) {
2456 function consoleFunc(name) {
2474 * Logs the result of an [`async` function]{@link AsyncFunction} to the
2478 * If multiple arguments are returned from the async function,
2486 * @param {AsyncFunction} function - The function you want to eventually apply
2488 * @param {...*} arguments... - Any number of arguments to apply to the function.
2492 * var hello = function(name, callback) {
2493 * setTimeout(function() {
2516 * @param {AsyncFunction} iteratee - A function which is called each time `test`
2522 * function has failed and repeated execution of `iteratee` has stopped.
2527 function doWhilst(iteratee, test, callback) {
2533 function next(err, ...args) {
2540 function check(err, truth) {
2562 * @param {AsyncFunction} iteratee - An async function which is called each time
2568 * function has passed and repeated execution of `iteratee` has stopped. `callback`
2573 function doUntil(iteratee, test, callback) {
2581 function _withoutIndex(iteratee) {
2586 * Applies the function `iteratee` to each item in `coll`, in parallel.
2589 * main `callback` (for the `each` function) is immediately called with the
2592 * Note, that since this function applies `iteratee` to each item in parallel,
2602 * @param {AsyncFunction} iteratee - An async function to apply to
2619 * // asynchronous function that deletes a file
2620 * const deleteFile = function(file, callback) {
2625 * async.each(fileList, deleteFile, function(err) {
2634 * async.each(withMissingFileList, deleteFile, function(err){
2684 function eachLimit(coll, iteratee, callback) {
2702 * @param {AsyncFunction} iteratee - An async function to apply to each item in
2711 function eachLimit$1(coll, limit, iteratee, callback) {
2719 …* Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to eac…
2730 * @param {AsyncFunction} iteratee - An async function to apply to each
2739 function eachSeries(coll, iteratee, callback) {
2745 * Wrap an async function and ensure it calls its callback on a later tick of
2746 * the event loop. If the function already calls its callback on a next tick,
2758 * @param {AsyncFunction} fn - an async function, one that expects a node-style
2760 * @returns {AsyncFunction} Returns a wrapped function with the exact same call
2761 * signature as the function passed in.
2764 * function sometimesAsync(arg, callback) {
2779 function ensureAsync(fn) {
2781 return function (...args/*, callback*/) {
2825 * // asynchronous function that checks if a file exists
2826 * function fileExists(file, callback) {
2833 * async.every(fileList, fileExists, function(err, result) {
2839 * async.every(withMissingFileList, fileExists, function(err, result) {
2890 function every(coll, iteratee, callback) {
2916 function everyLimit(coll, limit, iteratee, callback) {
2941 function everySeries(coll, iteratee, callback) {
2946 function filterArray(eachfn, arr, iteratee, callback) {
2963 function filterGeneric(eachfn, coll, iteratee, callback) {
2981 function _filter(eachfn, coll, iteratee, callback) {
3012 * // asynchronous function that checks if a file exists
3013 * function fileExists(file, callback) {
3020 * async.filter(files, fileExists, function(err, results) {
3054 function filter (coll, iteratee, callback) {
3079 function filterLimit (coll, limit, iteratee, callback) {
3102 function filterSeries (coll, iteratee, callback) {
3108 * Calls the asynchronous function `fn` with a callback parameter that allows it
3119 * @param {AsyncFunction} fn - an async function to call repeatedly.
3122 * this function will be called, and execution stops. Invoked with (err).
3128 * function(next) {
3130 * // it will result in this function being called again.
3132 * function(err) {
3138 function forever(fn, errback) {
3142 function next(err) {
3162 * @param {AsyncFunction} iteratee - An async function to apply to each item in
3171 function groupByLimit(coll, limit, iteratee, callback) {
3207 * Note: Since this function applies the `iteratee` to each item in parallel,
3219 * @param {AsyncFunction} iteratee - An async function to apply to each item in
3236 * // asynchronous function that detects file type as none, file, or directory
3237 * function detectFile(file, callback) {
3238 * fs.stat(file, function(err, stat) {
3247 * async.groupBy(files, detectFile, function(err, result) {
3293 function groupBy (coll, iteratee, callback) {
3307 * @param {AsyncFunction} iteratee - An async function to apply to each item in
3316 function groupBySeries (coll, iteratee, callback) {
3321 * Logs the result of an `async` function to the `console`. Only works in
3324 * function, `console.log` is called on each argument in order.
3331 * @param {AsyncFunction} function - The function you want to eventually apply
3333 * @param {...*} arguments... - Any number of arguments to apply to the function.
3337 * var hello = function(name, callback) {
3338 * setTimeout(function() {
3361 * @param {AsyncFunction} iteratee - A function to apply to each value and key
3371 function mapValuesLimit(obj, limit, iteratee, callback) {
3390 * function. The `iteratee` is called each `value` and `key` from `obj` and a
3394 * function) is immediately called with the error.
3405 * @param {AsyncFunction} iteratee - A function to apply to each value and key
3433 * // asynchronous function that returns the file size in bytes
3434 * function getFileSizeInBytes(file, key, callback) {
3435 * fs.stat(file, function(err, stat) {
3444 * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) {
3459 * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) {
3521 function mapValues(obj, iteratee, callback) {
3535 * @param {AsyncFunction} iteratee - A function to apply to each value and key
3545 function mapValuesSeries(obj, iteratee, callback) {
3550 * Caches the results of an async function. When creating a hash to store
3551 * function results against, the callback is omitted from the hash and an
3552 * optional hash function can be used.
3554 * **Note: if the async function errs, the result will not be cached and
3555 * subsequent calls will call the wrapped function.**
3557 * If no hash function is specified, the first argument is used as a hash key,
3561 * specify your own hash function.
3563 * The cache of results is exposed as the `memo` property of the function
3571 * @param {AsyncFunction} fn - The async function to proxy and cache results from.
3572 * @param {Function} hasher - An optional function for generating a custom hash
3578 * var slow_fn = function(name, callback) {
3585 * fn('some name', function() {
3589 function memoize(fn, hasher = v => v) {
3635 * @param {Function} callback - The function to call on a later loop around
3642 * async.nextTick(function() {
3648 * async.setImmediate(function (a, b, c) {
3680 * the previous function has completed. If any of the functions pass an error to
3695 * be run as a function and the results will be passed to the final `callback`
3706 * Each async function can complete with any number of optional `result` values.
3708 * functions have completed successfully. This function gets a results array
3717 * function(callback) {
3718 * setTimeout(function() {
3722 * function(callback) {
3723 * setTimeout(function() {
3727 * ], function(err, results) {
3730 * // the second function had a shorter timeout.
3735 * one: function(callback) {
3736 * setTimeout(function() {
3740 * two: function(callback) {
3741 * setTimeout(function() {
3745 * }, function(err, results) {
3752 * function(callback) {
3753 * setTimeout(function() {
3757 * function(callback) {
3758 * setTimeout(function() {
3765 * // the second function had a shorter timeout.
3772 * one: function(callback) {
3773 * setTimeout(function() {
3777 * two: function(callback) {
3778 * setTimeout(function() {
3793 * function(callback) {
3794 * setTimeout(function() {
3798 * function(callback) {
3799 * setTimeout(function() {
3806 * // the second function had a shorter timeout.
3817 * one: function(callback) {
3818 * setTimeout(function() {
3822 * two: function(callback) {
3823 * setTimeout(function() {
3837 function parallel$1(tasks, callback) {
3853 * Each async function can complete with any number of optional `result` values.
3856 * functions have completed successfully. This function gets a results array
3861 function parallelLimit(tasks, limit, callback) {
3866 * A queue of tasks for the worker function to complete.
3869 * @property {Function} length - a function returning the number of items
3873 * @property {Function} running - a function returning the number of items
3875 * @property {Function} workersList - a function returning the array of items
3877 * @property {Function} idle - a function returning false if there are items
3883 * passed to the worker function at a time. only applies if this is a
3896 * function. The test function will be passed an object with a `data` property,
3900 * `function ({data, priority}) {}` and returns a Boolean.
3901 * @property {Function} saturated - a function that sets a callback that is
3905 * @property {Function} unsaturated - a function that sets a callback that is
3911 * @property {Function} empty - a function that sets a callback that is called
3914 * @property {Function} drain - a function that sets a callback that is called
3917 * @property {Function} error - a function that sets a callback that is called
3918 * when a task errors. Has the signature `function(error, task)`. If the
3923 * @property {Function} pause - a function that pauses the processing of tasks
3925 * @property {Function} resume - a function that resumes the processing of
3927 * @property {Function} kill - a function that removes the `drain` callback and
3929 * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
3961 * @param {AsyncFunction} worker - An async function for processing a queued task.
3973 * var q = async.queue(function(task, callback) {
3979 * q.drain(function() {
3986 * q.error(function(err, task) {
3991 * q.push({name: 'foo'}, function(err) {
3998 * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
4003 * q.unshift({name: 'bar'}, function (err) {
4007 function queue$1 (worker, concurrency) {
4112 function leftChi(i) {
4116 function parent(i) {
4120 function smaller(x, y) {
4139 * @param {AsyncFunction} worker - An async function for processing a queued task.
4154 function priorityQueue(worker, concurrency) {
4172 function createDataItems(tasks, priority) {
4180 q.push = function(data, priority = 0, callback) {
4184 q.pushAsync = function(data, priority = 0, callback) {
4197 * previous function has completed. Once any of the `tasks` complete or pass an
4207 * to run. Each function can complete with an optional `result` value.
4209 * completed. This function gets an error or result from the first function that
4215 * function(callback) {
4216 * setTimeout(function() {
4220 * function(callback) {
4221 * setTimeout(function() {
4227 * function(err, result) {
4231 function race(tasks, callback) {
4254 * @param {AsyncFunction} iteratee - A function applied to each item in the
4265 function reduceRight (array, memo, iteratee, callback) {
4271 * Wraps the async function in another function that always completes with a
4281 * @param {AsyncFunction} fn - The async function you want to wrap
4282 * @returns {Function} - A function that always passes null to it's callback as
4288 * async.reflect(function(callback) {
4292 * async.reflect(function(callback) {
4296 * async.reflect(function(callback) {
4302 * function(err, results) {
4309 function reflect(fn) {
4311 return initialParams(function reflectOn(args, reflectCallback) {
4332 * A helper function that wraps an array or an object of functions with `reflect`.
4347 * function(callback) {
4348 * setTimeout(function() {
4352 * function(callback) {
4356 * function(callback) {
4357 * setTimeout(function() {
4365 * function(err, results) {
4374 * one: function(callback) {
4375 * setTimeout(function() {
4379 * two: function(callback) {
4382 * three: function(callback) {
4383 * setTimeout(function() {
4391 * function(err, results) {
4398 function reflectAll(tasks) {
4411 function reject(eachfn, arr, _iteratee, callback) {
4445 * // asynchronous function that checks if a file exists
4446 * function fileExists(file, callback) {
4453 * async.reject(fileList, fileExists, function(err, results) {
4482 function reject$1 (coll, iteratee, callback) {
4507 function rejectLimit (coll, limit, iteratee, callback) {
4530 function rejectSeries (coll, iteratee, callback) {
4535 function constant$1(value) {
4536 return function () {
4558 * default is `0`. The interval may also be specified as a function of the
4560 * * `errorFilter` - An optional synchronous function that is invoked on
4562 * if the function returns `false` the retry flow is aborted with the current
4567 * @param {AsyncFunction} task - An async function to retry.
4577 * // The `retry` function can be used as a stand-alone control flow by passing
4581 * async.retry(3, apiMethod, function(err, result) {
4586 * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
4594 * interval: function(retryCount) {
4597 * }, apiMethod, function(err, result) {
4602 * async.retry(apiMethod, function(err, result) {
4609 * errorFilter: function(err) {
4612 * }, apiMethod, function(err, result) {
4621 * }, function(err, results) {
4629 function retry(opts, task, callback) {
4635 if (arguments.length < 3 && typeof opts === 'function') {
4643 if (typeof task !== 'function') {
4650 function retryAttempt() {
4654 (typeof options.errorFilter != 'function' ||
4667 function parseTimes(acc, t) {
4671 acc.intervalFunc = typeof t.interval === 'function' ?
4696 * is the arity of the `task` function, defaulting to `task.length`
4697 * @param {AsyncFunction} task - the asynchronous function to wrap.
4698 * This function will be passed any arguments passed to the returned wrapper.
4700 * @returns {AsyncFunction} The wrapped function, which when invoked, will
4702 * This function will accept the same parameters as `task`.
4707 * process: ["dep1", async.retryable(3, function (results, cb) {
4712 function retryable (opts, task) {
4727 function taskFn(cb) {
4740 * the previous function has completed. If any functions in the series pass an
4746 * be run as a function, and the results will be passed to the final `callback`
4766 * Each function can complete with any number of optional `result` values.
4768 * functions have completed. This function gets a results array (or object)
4776 * function(callback) {
4777 * setTimeout(function() {
4782 * function(callback) {
4783 * setTimeout(function() {
4788 * ], function(err, results) {
4795 * one: function(callback) {
4796 * setTimeout(function() {
4801 * two: function(callback) {
4802 * setTimeout(function() {
4807 * }, function(err, results) {
4814 * function(callback) {
4815 * setTimeout(function() {
4819 * function(callback) {
4820 * setTimeout(function() {
4833 * one: function(callback) {
4834 * setTimeout(function() {
4839 * two: function(callback) {
4840 * setTimeout(function() {
4856 * function(callback) {
4857 * setTimeout(function() {
4862 * function(callback) {
4863 * setTimeout(function() {
4881 * one: function(callback) {
4882 * setTimeout(function() {
4887 * two: function(callback) {
4888 * setTimeout(function() {
4903 function series(tasks, callback) {
4935 * // asynchronous function that checks if a file exists
4936 * function fileExists(file, callback) {
4944 * function(err, result) {
4952 * function(err, result) {
5004 function some(coll, iteratee, callback) {
5031 function someLimit(coll, limit, iteratee, callback) {
5057 function someSeries(coll, iteratee, callback) {
5072 * @param {AsyncFunction} iteratee - An async function to apply to each item in
5088 * // asynchronous function that returns the file size in bytes
5089 * function getFileSizeInBytes(file, callback) {
5090 * fs.stat(file, function(err, stat) {
5100 * function(err, results) {
5116 * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
5117 * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
5121 * }, function(err, results) {
5134 * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
5135 * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
5141 * }, function(err, results) {
5155 * function(err, results) {
5212 function sortBy (coll, iteratee, callback) {
5224 function comparator(left, right) {
5232 * Sets a time limit on an asynchronous function. If the function does not call
5241 * @param {AsyncFunction} asyncFn - The async function to limit in time.
5245 * @returns {AsyncFunction} Returns a wrapped function that can be used with any
5247 * Invoke this function with the same parameters as you would `asyncFunc`.
5250 * function myFunction(foo, callback) {
5251 * doAsyncTask(foo, function(err, data) {
5265 * wrapped({ bar: 'bar' }, function(err, data) {
5272 function timeout(asyncFn, milliseconds, info) {
5279 function timeoutCallback() {
5281 var error = new Error('Callback function "' + name + '" timed out.');
5297 // setup timer and call original function
5303 function range(size) {
5321 * @param {number} count - The number of times to run the function.
5323 * @param {AsyncFunction} iteratee - The async function to call `n` times.
5328 function timesLimit(count, limit, iteratee, callback) {
5334 * Calls the `iteratee` function `n` times, and accumulates results in the same
5343 * @param {number} n - The number of times to run the function.
5344 * @param {AsyncFunction} iteratee - The async function to call `n` times.
5351 * var createUser = function(id, callback) {
5358 * async.times(5, function(n, next) {
5359 * createUser(n, function(err, user) {
5362 * }, function(err, users) {
5366 function times (n, iteratee, callback) {
5379 * @param {number} n - The number of times to run the function.
5380 * @param {AsyncFunction} iteratee - The async function to call `n` times.
5385 function timesSeries (n, iteratee, callback) {
5402 * @param {AsyncFunction} iteratee - A function applied to each item in the
5415 * // helper function that returns human-readable size format from bytes
5416 * function formatBytes(bytes, decimals = 2) {
5423 * // asynchronous function that returns the file size, transformed to human-readable format
5425 * function transformFileSize(acc, value, key, callback) {
5426 * fs.stat(value, function(err, stat) {
5436 * async.transform(fileList, transformFileSize, function(err, result) {
5472 * // helper function that returns human-readable size format from bytes
5473 * function formatBytes(bytes, decimals = 2) {
5480 * // asynchronous function that returns the file size, transformed to human-readable format
5482 * function transformFileSize(acc, value, key, callback) {
5483 * fs.stat(value, function(err, stat) {
5493 * async.transform(fileMap, transformFileSize, function(err, result) {
5524 function transform (coll, accumulator, iteratee, callback) {
5525 if (arguments.length <= 3 && typeof accumulator === 'function') {
5551 * run, each function is passed a `callback(err, result)` it must call on
5561 * function getDataFromFirstWebsite(callback) {
5565 * function getDataFromSecondWebsite(callback) {
5572 * function(err, results) {
5577 function tryEach(tasks, callback) {
5598 * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
5607 * @param {AsyncFunction} fn - the memoized function
5608 * @returns {AsyncFunction} a function that calls the original unmemoized function
5610 function unmemoize(fn) {
5627 * @param {AsyncFunction} iteratee - An async function which is called each time
5630 * function has failed and repeated execution of `iteratee` has stopped. `callback`
5638 * function test(cb) { cb(null, count < 5); },
5639 * function iter(callback) {
5641 * setTimeout(function() {
5645 * function (err, n) {
5650 function whilst(test, iteratee, callback) {
5656 function next(err, ...rest) {
5663 function check(err, truth) {
5689 * @param {AsyncFunction} iteratee - An async function which is called each time
5692 * function has passed and repeated execution of `iteratee` has stopped. `callback`
5700 * async.until(function test(cb) {
5702 * }, function iter(next) {
5709 * }, function done (err) {
5713 function until(test, iteratee, callback) {
5721 * own callback, the next function is not executed, and the main `callback` is
5731 * Each function should complete with any number of `result` values.
5740 * function(callback) {
5743 * function(arg1, arg2, callback) {
5747 * function(arg1, callback) {
5751 * ], function (err, result) {
5760 * ], function (err, result) {
5763 * function myFirstFunction(callback) {
5766 * function mySecondFunction(arg1, arg2, callback) {
5770 * function myLastFunction(arg1, callback) {
5775 function waterfall (tasks, callback) {
5781 function nextTask(args) {
5786 function next(err, ...args) {
5800 * An "async function" in the context of Async is an asynchronous function with
5802 * (`function (arg1, arg2, ..., callback) {}`)
5804 * called once the function is completed. The callback should be called with a
5812 * This type of function is also referred to as a "Node-style async function",
5813 * or a "continuation passing-style function" (CPS). Most of the methods of this
5817 * Wherever we accept a Node-style async function, we also directly accept an
5818 …* [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referenc…
5819 * In this case, the `async` function will not be passed a final callback
5830 * must still wrap the function with [asyncify]{@link module:Utils.asyncify},
5831 * because the `async function` will be compiled to an ordinary function that