최예리

final, add s3, fix some bug

Showing 1000 changed files with 4870 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + "$basedir/node" "$basedir/../uuid/bin/uuid" "$@"
10 + ret=$?
11 +else
12 + node "$basedir/../uuid/bin/uuid" "$@"
13 + ret=$?
14 +fi
15 +exit $ret
1 +@IF EXIST "%~dp0\node.exe" (
2 + "%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %*
3 +) ELSE (
4 + @SETLOCAL
5 + @SET PATHEXT=%PATHEXT:;.JS;=;%
6 + node "%~dp0\..\uuid\bin\uuid" %*
7 +)
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2010-2018 Caolan McMahon
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
1 +![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg)
2 +
3 +[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)
4 +[![Build Status via Azure Pipelines](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)
5 +[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
6 +[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
7 +[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8 +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async)
9 +
10 +<!--
11 +|Linux|Windows|MacOS|
12 +|-|-|-|
13 +|[![Linux Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Linux&configuration=Linux%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![Windows Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Windows&configuration=Windows%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![MacOS Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=OSX&configuration=OSX%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)| -->
14 +
15 +Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install async`, it can also be used directly in the browser. A ESM version is included in the main `async` package that should automatically be used with compatible bundlers such as Webpack and Rollup.
16 +
17 +A pure ESM version of Async is available as [`async-es`](https://www.npmjs.com/package/async-es).
18 +
19 +For Documentation, visit <https://caolan.github.io/async/>
20 +
21 +*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
22 +
23 +
24 +```javascript
25 +// for use with Node-style callbacks...
26 +var async = require("async");
27 +
28 +var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
29 +var configs = {};
30 +
31 +async.forEachOf(obj, (value, key, callback) => {
32 + fs.readFile(__dirname + value, "utf8", (err, data) => {
33 + if (err) return callback(err);
34 + try {
35 + configs[key] = JSON.parse(data);
36 + } catch (e) {
37 + return callback(e);
38 + }
39 + callback();
40 + });
41 +}, err => {
42 + if (err) console.error(err.message);
43 + // configs is now a map of JSON data
44 + doSomethingWith(configs);
45 +});
46 +```
47 +
48 +```javascript
49 +var async = require("async");
50 +
51 +// ...or ES2017 async functions
52 +async.mapLimit(urls, 5, async function(url) {
53 + const response = await fetch(url)
54 + return response.body
55 +}, (err, results) => {
56 + if (err) throw err
57 + // results is now an array of the response bodies
58 + console.log(results)
59 +})
60 +```
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if every element in `coll` satisfies an async test. If any
23 + * iteratee call returns `false`, the main `callback` is immediately called.
24 + *
25 + * @name every
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @alias all
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in parallel.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + * @example
41 + *
42 + * async.every(['file1','file2','file3'], function(filePath, callback) {
43 + * fs.access(filePath, function(err) {
44 + * callback(null, !err)
45 + * });
46 + * }, function(err, result) {
47 + * // if result is true then every file exists
48 + * });
49 + */
50 +function every(coll, iteratee, callback) {
51 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOf2.default, coll, iteratee, callback);
52 +}
53 +exports.default = (0, _awaitify2.default)(every, 3);
54 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name everyLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collection in parallel.
35 + * The iteratee must complete with a boolean result value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Result will be either `true` or `false`
39 + * depending on the values of the async tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function everyLimit(coll, limit, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(everyLimit, 4);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
23 + *
24 + * @name everySeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in series.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function everySeries(coll, iteratee, callback) {
42 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(everySeries, 3);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if at least one element in the `coll` satisfies an async test.
23 + * If any iteratee call returns `true`, the main `callback` is immediately
24 + * called.
25 + *
26 + * @name some
27 + * @static
28 + * @memberOf module:Collections
29 + * @method
30 + * @alias any
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collections in parallel.
35 + * The iteratee should complete with a boolean `result` value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the iteratee functions have finished.
39 + * Result will be either `true` or `false` depending on the values of the async
40 + * tests. Invoked with (err, result).
41 + * @returns {Promise} a promise, if no callback provided
42 + * @example
43 + *
44 + * async.some(['file1','file2','file3'], function(filePath, callback) {
45 + * fs.access(filePath, function(err) {
46 + * callback(null, !err)
47 + * });
48 + * }, function(err, result) {
49 + * // if result is true then at least one of the files exists
50 + * });
51 + */
52 +function some(coll, iteratee, callback) {
53 + return (0, _createTester2.default)(Boolean, res => res)(_eachOf2.default, coll, iteratee, callback);
54 +}
55 +exports.default = (0, _awaitify2.default)(some, 3);
56 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name someLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.some]{@link module:Collections.some}
29 + * @alias anyLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collections in parallel.
35 + * The iteratee should complete with a boolean `result` value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the iteratee functions have finished.
39 + * Result will be either `true` or `false` depending on the values of the async
40 + * tests. Invoked with (err, result).
41 + * @returns {Promise} a promise, if no callback provided
42 + */
43 +function someLimit(coll, limit, iteratee, callback) {
44 + return (0, _createTester2.default)(Boolean, res => res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
45 +}
46 +exports.default = (0, _awaitify2.default)(someLimit, 4);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
23 + *
24 + * @name someSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.some]{@link module:Collections.some}
29 + * @alias anySeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collections in series.
34 + * The iteratee should complete with a boolean `result` value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called as soon as any
37 + * iteratee returns `true`, or after all the iteratee functions have finished.
38 + * Result will be either `true` or `false` depending on the values of the async
39 + * tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function someSeries(coll, iteratee, callback) {
43 + return (0, _createTester2.default)(Boolean, res => res)(_eachOfSeries2.default, coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(someSeries, 3);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (fn, ...args) {
8 + return (...callArgs) => fn(...args, ...callArgs);
9 +};
10 +
11 +module.exports = exports["default"]; /**
12 + * Creates a continuation function with some arguments already applied.
13 + *
14 + * Useful as a shorthand when combined with other control flow functions. Any
15 + * arguments passed to the returned function are added to the arguments
16 + * originally passed to apply.
17 + *
18 + * @name apply
19 + * @static
20 + * @memberOf module:Utils
21 + * @method
22 + * @category Util
23 + * @param {Function} fn - The function you want to eventually apply all
24 + * arguments to. Invokes with (arguments...).
25 + * @param {...*} arguments... - Any number of arguments to automatically apply
26 + * when the continuation is called.
27 + * @returns {Function} the partially-applied function
28 + * @example
29 + *
30 + * // using apply
31 + * async.parallel([
32 + * async.apply(fs.writeFile, 'testfile1', 'test1'),
33 + * async.apply(fs.writeFile, 'testfile2', 'test2')
34 + * ]);
35 + *
36 + *
37 + * // the same process without using apply
38 + * async.parallel([
39 + * function(callback) {
40 + * fs.writeFile('testfile1', 'test1', callback);
41 + * },
42 + * function(callback) {
43 + * fs.writeFile('testfile2', 'test2', callback);
44 + * }
45 + * ]);
46 + *
47 + * // It's possible to pass any number of additional arguments when calling the
48 + * // continuation:
49 + *
50 + * node> var fn = async.apply(sys.puts, 'one');
51 + * node> fn('two', 'three');
52 + * one
53 + * two
54 + * three
55 + */
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _applyEach = require('./internal/applyEach');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _map = require('./map');
12 +
13 +var _map2 = _interopRequireDefault(_map);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Applies the provided arguments to each function in the array, calling
19 + * `callback` after all functions have completed. If you only provide the first
20 + * argument, `fns`, then it will return a function which lets you pass in the
21 + * arguments as if it were a single function call. If more arguments are
22 + * provided, `callback` is required while `args` is still optional. The results
23 + * for each of the applied async functions are passed to the final callback
24 + * as an array.
25 + *
26 + * @name applyEach
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @category Control Flow
31 + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s
32 + * to all call with the same arguments
33 + * @param {...*} [args] - any number of separate arguments to pass to the
34 + * function.
35 + * @param {Function} [callback] - the final argument should be the callback,
36 + * called when all functions have completed processing.
37 + * @returns {AsyncFunction} - Returns a function that takes no args other than
38 + * an optional callback, that is the result of applying the `args` to each
39 + * of the functions.
40 + * @example
41 + *
42 + * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
43 + *
44 + * appliedFn((err, results) => {
45 + * // results[0] is the results for `enableSearch`
46 + * // results[1] is the results for `updateSchema`
47 + * });
48 + *
49 + * // partial application example:
50 + * async.each(
51 + * buckets,
52 + * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
53 + * callback
54 + * );
55 + */
56 +exports.default = (0, _applyEach2.default)(_map2.default);
57 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _applyEach = require('./internal/applyEach');
8 +
9 +var _applyEach2 = _interopRequireDefault(_applyEach);
10 +
11 +var _mapSeries = require('./mapSeries');
12 +
13 +var _mapSeries2 = _interopRequireDefault(_mapSeries);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
19 + *
20 + * @name applyEachSeries
21 + * @static
22 + * @memberOf module:ControlFlow
23 + * @method
24 + * @see [async.applyEach]{@link module:ControlFlow.applyEach}
25 + * @category Control Flow
26 + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all
27 + * call with the same arguments
28 + * @param {...*} [args] - any number of separate arguments to pass to the
29 + * function.
30 + * @param {Function} [callback] - the final argument should be the callback,
31 + * called when all functions have completed processing.
32 + * @returns {AsyncFunction} - A function, that when called, is the result of
33 + * appling the `args` to the list of functions. It takes no args, other than
34 + * a callback.
35 + */
36 +exports.default = (0, _applyEach2.default)(_mapSeries2.default);
37 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = asyncify;
7 +
8 +var _initialParams = require('./internal/initialParams');
9 +
10 +var _initialParams2 = _interopRequireDefault(_initialParams);
11 +
12 +var _setImmediate = require('./internal/setImmediate');
13 +
14 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 +
20 +/**
21 + * Take a sync function and make it async, passing its return value to a
22 + * callback. This is useful for plugging sync functions into a waterfall,
23 + * series, or other async functions. Any arguments passed to the generated
24 + * function will be passed to the wrapped function (except for the final
25 + * callback argument). Errors thrown will be passed to the callback.
26 + *
27 + * If the function passed to `asyncify` returns a Promise, that promises's
28 + * resolved/rejected state will be used to call the callback, rather than simply
29 + * the synchronous return value.
30 + *
31 + * This also means you can asyncify ES2017 `async` functions.
32 + *
33 + * @name asyncify
34 + * @static
35 + * @memberOf module:Utils
36 + * @method
37 + * @alias wrapSync
38 + * @category Util
39 + * @param {Function} func - The synchronous function, or Promise-returning
40 + * function to convert to an {@link AsyncFunction}.
41 + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
42 + * invoked with `(args..., callback)`.
43 + * @example
44 + *
45 + * // passing a regular synchronous function
46 + * async.waterfall([
47 + * async.apply(fs.readFile, filename, "utf8"),
48 + * async.asyncify(JSON.parse),
49 + * function (data, next) {
50 + * // data is the result of parsing the text.
51 + * // If there was a parsing error, it would have been caught.
52 + * }
53 + * ], callback);
54 + *
55 + * // passing a function returning a promise
56 + * async.waterfall([
57 + * async.apply(fs.readFile, filename, "utf8"),
58 + * async.asyncify(function (contents) {
59 + * return db.model.create(contents);
60 + * }),
61 + * function (model, next) {
62 + * // `model` is the instantiated model object.
63 + * // If there was an error, this function would be skipped.
64 + * }
65 + * ], callback);
66 + *
67 + * // es2017 example, though `asyncify` is not needed if your JS environment
68 + * // supports async functions out of the box
69 + * var q = async.queue(async.asyncify(async function(file) {
70 + * var intermediateStep = await processFile(file);
71 + * return await somePromise(intermediateStep)
72 + * }));
73 + *
74 + * q.push(files);
75 + */
76 +function asyncify(func) {
77 + if ((0, _wrapAsync.isAsync)(func)) {
78 + return function (...args /*, callback*/) {
79 + const callback = args.pop();
80 + const promise = func.apply(this, args);
81 + return handlePromise(promise, callback);
82 + };
83 + }
84 +
85 + return (0, _initialParams2.default)(function (args, callback) {
86 + var result;
87 + try {
88 + result = func.apply(this, args);
89 + } catch (e) {
90 + return callback(e);
91 + }
92 + // if result is Promise object
93 + if (result && typeof result.then === 'function') {
94 + return handlePromise(result, callback);
95 + } else {
96 + callback(null, result);
97 + }
98 + });
99 +}
100 +
101 +function handlePromise(promise, callback) {
102 + return promise.then(value => {
103 + invokeCallback(callback, null, value);
104 + }, err => {
105 + invokeCallback(callback, err && err.message ? err : new Error(err));
106 + });
107 +}
108 +
109 +function invokeCallback(callback, error, value) {
110 + try {
111 + callback(error, value);
112 + } catch (err) {
113 + (0, _setImmediate2.default)(e => {
114 + throw e;
115 + }, err);
116 + }
117 +}
118 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = auto;
7 +
8 +var _once = require('./internal/once');
9 +
10 +var _once2 = _interopRequireDefault(_once);
11 +
12 +var _onlyOnce = require('./internal/onlyOnce');
13 +
14 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
15 +
16 +var _wrapAsync = require('./internal/wrapAsync');
17 +
18 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
19 +
20 +var _promiseCallback = require('./internal/promiseCallback');
21 +
22 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23 +
24 +/**
25 + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
26 + * their requirements. Each function can optionally depend on other functions
27 + * being completed first, and each function is run as soon as its requirements
28 + * are satisfied.
29 + *
30 + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
31 + * will stop. Further tasks will not execute (so any other functions depending
32 + * on it will not run), and the main `callback` is immediately called with the
33 + * error.
34 + *
35 + * {@link AsyncFunction}s also receive an object containing the results of functions which
36 + * have completed so far as the first argument, if they have dependencies. If a
37 + * task function has no dependencies, it will only be passed a callback.
38 + *
39 + * @name auto
40 + * @static
41 + * @memberOf module:ControlFlow
42 + * @method
43 + * @category Control Flow
44 + * @param {Object} tasks - An object. Each of its properties is either a
45 + * function or an array of requirements, with the {@link AsyncFunction} itself the last item
46 + * in the array. The object's key of a property serves as the name of the task
47 + * defined by that property, i.e. can be used when specifying requirements for
48 + * other tasks. The function receives one or two arguments:
49 + * * a `results` object, containing the results of the previously executed
50 + * functions, only passed if the task has any dependencies,
51 + * * a `callback(err, result)` function, which must be called when finished,
52 + * passing an `error` (which can be `null`) and the result of the function's
53 + * execution.
54 + * @param {number} [concurrency=Infinity] - An optional `integer` for
55 + * determining the maximum number of tasks that can be run in parallel. By
56 + * default, as many as possible.
57 + * @param {Function} [callback] - An optional callback which is called when all
58 + * the tasks have been completed. It receives the `err` argument if any `tasks`
59 + * pass an error to their callback. Results are always returned; however, if an
60 + * error occurs, no further `tasks` will be performed, and the results object
61 + * will only contain partial results. Invoked with (err, results).
62 + * @returns {Promise} a promise, if a callback is not passed
63 + * @example
64 + *
65 + * async.auto({
66 + * // this function will just be passed a callback
67 + * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
68 + * showData: ['readData', function(results, cb) {
69 + * // results.readData is the file's contents
70 + * // ...
71 + * }]
72 + * }, callback);
73 + *
74 + * async.auto({
75 + * get_data: function(callback) {
76 + * console.log('in get_data');
77 + * // async code to get some data
78 + * callback(null, 'data', 'converted to array');
79 + * },
80 + * make_folder: function(callback) {
81 + * console.log('in make_folder');
82 + * // async code to create a directory to store a file in
83 + * // this is run at the same time as getting the data
84 + * callback(null, 'folder');
85 + * },
86 + * write_file: ['get_data', 'make_folder', function(results, callback) {
87 + * console.log('in write_file', JSON.stringify(results));
88 + * // once there is some data and the directory exists,
89 + * // write the data to a file in the directory
90 + * callback(null, 'filename');
91 + * }],
92 + * email_link: ['write_file', function(results, callback) {
93 + * console.log('in email_link', JSON.stringify(results));
94 + * // once the file is written let's email a link to it...
95 + * // results.write_file contains the filename returned by write_file.
96 + * callback(null, {'file':results.write_file, 'email':'user@example.com'});
97 + * }]
98 + * }, function(err, results) {
99 + * console.log('err = ', err);
100 + * console.log('results = ', results);
101 + * });
102 + */
103 +function auto(tasks, concurrency, callback) {
104 + if (typeof concurrency !== 'number') {
105 + // concurrency is optional, shift the args.
106 + callback = concurrency;
107 + concurrency = null;
108 + }
109 + callback = (0, _once2.default)(callback || (0, _promiseCallback.promiseCallback)());
110 + var numTasks = Object.keys(tasks).length;
111 + if (!numTasks) {
112 + return callback(null);
113 + }
114 + if (!concurrency) {
115 + concurrency = numTasks;
116 + }
117 +
118 + var results = {};
119 + var runningTasks = 0;
120 + var canceled = false;
121 + var hasError = false;
122 +
123 + var listeners = Object.create(null);
124 +
125 + var readyTasks = [];
126 +
127 + // for cycle detection:
128 + var readyToCheck = []; // tasks that have been identified as reachable
129 + // without the possibility of returning to an ancestor task
130 + var uncheckedDependencies = {};
131 +
132 + Object.keys(tasks).forEach(key => {
133 + var task = tasks[key];
134 + if (!Array.isArray(task)) {
135 + // no dependencies
136 + enqueueTask(key, [task]);
137 + readyToCheck.push(key);
138 + return;
139 + }
140 +
141 + var dependencies = task.slice(0, task.length - 1);
142 + var remainingDependencies = dependencies.length;
143 + if (remainingDependencies === 0) {
144 + enqueueTask(key, task);
145 + readyToCheck.push(key);
146 + return;
147 + }
148 + uncheckedDependencies[key] = remainingDependencies;
149 +
150 + dependencies.forEach(dependencyName => {
151 + if (!tasks[dependencyName]) {
152 + throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', '));
153 + }
154 + addListener(dependencyName, () => {
155 + remainingDependencies--;
156 + if (remainingDependencies === 0) {
157 + enqueueTask(key, task);
158 + }
159 + });
160 + });
161 + });
162 +
163 + checkForDeadlocks();
164 + processQueue();
165 +
166 + function enqueueTask(key, task) {
167 + readyTasks.push(() => runTask(key, task));
168 + }
169 +
170 + function processQueue() {
171 + if (canceled) return;
172 + if (readyTasks.length === 0 && runningTasks === 0) {
173 + return callback(null, results);
174 + }
175 + while (readyTasks.length && runningTasks < concurrency) {
176 + var run = readyTasks.shift();
177 + run();
178 + }
179 + }
180 +
181 + function addListener(taskName, fn) {
182 + var taskListeners = listeners[taskName];
183 + if (!taskListeners) {
184 + taskListeners = listeners[taskName] = [];
185 + }
186 +
187 + taskListeners.push(fn);
188 + }
189 +
190 + function taskComplete(taskName) {
191 + var taskListeners = listeners[taskName] || [];
192 + taskListeners.forEach(fn => fn());
193 + processQueue();
194 + }
195 +
196 + function runTask(key, task) {
197 + if (hasError) return;
198 +
199 + var taskCallback = (0, _onlyOnce2.default)((err, ...result) => {
200 + runningTasks--;
201 + if (err === false) {
202 + canceled = true;
203 + return;
204 + }
205 + if (result.length < 2) {
206 + [result] = result;
207 + }
208 + if (err) {
209 + var safeResults = {};
210 + Object.keys(results).forEach(rkey => {
211 + safeResults[rkey] = results[rkey];
212 + });
213 + safeResults[key] = result;
214 + hasError = true;
215 + listeners = Object.create(null);
216 + if (canceled) return;
217 + callback(err, safeResults);
218 + } else {
219 + results[key] = result;
220 + taskComplete(key);
221 + }
222 + });
223 +
224 + runningTasks++;
225 + var taskFn = (0, _wrapAsync2.default)(task[task.length - 1]);
226 + if (task.length > 1) {
227 + taskFn(results, taskCallback);
228 + } else {
229 + taskFn(taskCallback);
230 + }
231 + }
232 +
233 + function checkForDeadlocks() {
234 + // Kahn's algorithm
235 + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
236 + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
237 + var currentTask;
238 + var counter = 0;
239 + while (readyToCheck.length) {
240 + currentTask = readyToCheck.pop();
241 + counter++;
242 + getDependents(currentTask).forEach(dependent => {
243 + if (--uncheckedDependencies[dependent] === 0) {
244 + readyToCheck.push(dependent);
245 + }
246 + });
247 + }
248 +
249 + if (counter !== numTasks) {
250 + throw new Error('async.auto cannot execute tasks due to a recursive dependency');
251 + }
252 + }
253 +
254 + function getDependents(taskName) {
255 + var result = [];
256 + Object.keys(tasks).forEach(key => {
257 + const task = tasks[key];
258 + if (Array.isArray(task) && task.indexOf(taskName) >= 0) {
259 + result.push(key);
260 + }
261 + });
262 + return result;
263 + }
264 +
265 + return callback[_promiseCallback.PROMISE_SYMBOL];
266 +}
267 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = autoInject;
7 +
8 +var _auto = require('./auto');
9 +
10 +var _auto2 = _interopRequireDefault(_auto);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +var FN_ARGS = /^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/;
19 +var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/;
20 +var FN_ARG_SPLIT = /,/;
21 +var FN_ARG = /(=.+)?(\s*)$/;
22 +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
23 +
24 +function parseParams(func) {
25 + const src = func.toString().replace(STRIP_COMMENTS, '');
26 + let match = src.match(FN_ARGS);
27 + if (!match) {
28 + match = src.match(ARROW_FN_ARGS);
29 + }
30 + if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src);
31 + let [, args] = match;
32 + return args.replace(/\s/g, '').split(FN_ARG_SPLIT).map(arg => arg.replace(FN_ARG, '').trim());
33 +}
34 +
35 +/**
36 + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
37 + * tasks are specified as parameters to the function, after the usual callback
38 + * parameter, with the parameter names matching the names of the tasks it
39 + * depends on. This can provide even more readable task graphs which can be
40 + * easier to maintain.
41 + *
42 + * If a final callback is specified, the task results are similarly injected,
43 + * specified as named parameters after the initial error parameter.
44 + *
45 + * The autoInject function is purely syntactic sugar and its semantics are
46 + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
47 + *
48 + * @name autoInject
49 + * @static
50 + * @memberOf module:ControlFlow
51 + * @method
52 + * @see [async.auto]{@link module:ControlFlow.auto}
53 + * @category Control Flow
54 + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
55 + * the form 'func([dependencies...], callback). The object's key of a property
56 + * serves as the name of the task defined by that property, i.e. can be used
57 + * when specifying requirements for other tasks.
58 + * * The `callback` parameter is a `callback(err, result)` which must be called
59 + * when finished, passing an `error` (which can be `null`) and the result of
60 + * the function's execution. The remaining parameters name other tasks on
61 + * which the task is dependent, and the results from those tasks are the
62 + * arguments of those parameters.
63 + * @param {Function} [callback] - An optional callback which is called when all
64 + * the tasks have been completed. It receives the `err` argument if any `tasks`
65 + * pass an error to their callback, and a `results` object with any completed
66 + * task results, similar to `auto`.
67 + * @returns {Promise} a promise, if no callback is passed
68 + * @example
69 + *
70 + * // The example from `auto` can be rewritten as follows:
71 + * async.autoInject({
72 + * get_data: function(callback) {
73 + * // async code to get some data
74 + * callback(null, 'data', 'converted to array');
75 + * },
76 + * make_folder: function(callback) {
77 + * // async code to create a directory to store a file in
78 + * // this is run at the same time as getting the data
79 + * callback(null, 'folder');
80 + * },
81 + * write_file: function(get_data, make_folder, callback) {
82 + * // once there is some data and the directory exists,
83 + * // write the data to a file in the directory
84 + * callback(null, 'filename');
85 + * },
86 + * email_link: function(write_file, callback) {
87 + * // once the file is written let's email a link to it...
88 + * // write_file contains the filename returned by write_file.
89 + * callback(null, {'file':write_file, 'email':'user@example.com'});
90 + * }
91 + * }, function(err, results) {
92 + * console.log('err = ', err);
93 + * console.log('email_link = ', results.email_link);
94 + * });
95 + *
96 + * // If you are using a JS minifier that mangles parameter names, `autoInject`
97 + * // will not work with plain functions, since the parameter names will be
98 + * // collapsed to a single letter identifier. To work around this, you can
99 + * // explicitly specify the names of the parameters your task function needs
100 + * // in an array, similar to Angular.js dependency injection.
101 + *
102 + * // This still has an advantage over plain `auto`, since the results a task
103 + * // depends on are still spread into arguments.
104 + * async.autoInject({
105 + * //...
106 + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
107 + * callback(null, 'filename');
108 + * }],
109 + * email_link: ['write_file', function(write_file, callback) {
110 + * callback(null, {'file':write_file, 'email':'user@example.com'});
111 + * }]
112 + * //...
113 + * }, function(err, results) {
114 + * console.log('err = ', err);
115 + * console.log('email_link = ', results.email_link);
116 + * });
117 + */
118 +function autoInject(tasks, callback) {
119 + var newTasks = {};
120 +
121 + Object.keys(tasks).forEach(key => {
122 + var taskFn = tasks[key];
123 + var params;
124 + var fnIsAsync = (0, _wrapAsync.isAsync)(taskFn);
125 + var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0;
126 +
127 + if (Array.isArray(taskFn)) {
128 + params = [...taskFn];
129 + taskFn = params.pop();
130 +
131 + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
132 + } else if (hasNoDeps) {
133 + // no dependencies, use the function as-is
134 + newTasks[key] = taskFn;
135 + } else {
136 + params = parseParams(taskFn);
137 + if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
138 + throw new Error("autoInject task functions require explicit parameters.");
139 + }
140 +
141 + // remove callback param
142 + if (!fnIsAsync) params.pop();
143 +
144 + newTasks[key] = params.concat(newTask);
145 + }
146 +
147 + function newTask(results, taskCb) {
148 + var newArgs = params.map(name => results[name]);
149 + newArgs.push(taskCb);
150 + (0, _wrapAsync2.default)(taskFn)(...newArgs);
151 + }
152 + });
153 +
154 + return (0, _auto2.default)(newTasks, callback);
155 +}
156 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "async",
3 + "main": "dist/async.js",
4 + "ignore": [
5 + "bower_components",
6 + "lib",
7 + "test",
8 + "node_modules",
9 + "perf",
10 + "support",
11 + "**/.*",
12 + "*.config.js",
13 + "*.json",
14 + "index.js",
15 + "Makefile"
16 + ]
17 +}
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = cargo;
7 +
8 +var _queue = require('./internal/queue');
9 +
10 +var _queue2 = _interopRequireDefault(_queue);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a `cargo` object with the specified payload. Tasks added to the
16 + * cargo will be processed altogether (up to the `payload` limit). If the
17 + * `worker` is in progress, the task is queued until it becomes available. Once
18 + * the `worker` has completed some tasks, each callback of those tasks is
19 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
20 + * for how `cargo` and `queue` work.
21 + *
22 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
23 + * at a time, cargo passes an array of tasks to a single worker, repeating
24 + * when the worker is finished.
25 + *
26 + * @name cargo
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @see [async.queue]{@link module:ControlFlow.queue}
31 + * @category Control Flow
32 + * @param {AsyncFunction} worker - An asynchronous function for processing an array
33 + * of queued tasks. Invoked with `(tasks, callback)`.
34 + * @param {number} [payload=Infinity] - An optional `integer` for determining
35 + * how many tasks should be processed per round; if omitted, the default is
36 + * unlimited.
37 + * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can
38 + * attached as certain properties to listen for specific events during the
39 + * lifecycle of the cargo and inner queue.
40 + * @example
41 + *
42 + * // create a cargo object with payload 2
43 + * var cargo = async.cargo(function(tasks, callback) {
44 + * for (var i=0; i<tasks.length; i++) {
45 + * console.log('hello ' + tasks[i].name);
46 + * }
47 + * callback();
48 + * }, 2);
49 + *
50 + * // add some items
51 + * cargo.push({name: 'foo'}, function(err) {
52 + * console.log('finished processing foo');
53 + * });
54 + * cargo.push({name: 'bar'}, function(err) {
55 + * console.log('finished processing bar');
56 + * });
57 + * await cargo.push({name: 'baz'});
58 + * console.log('finished processing baz');
59 + */
60 +function cargo(worker, payload) {
61 + return (0, _queue2.default)(worker, 1, payload);
62 +}
63 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = cargo;
7 +
8 +var _queue = require('./internal/queue');
9 +
10 +var _queue2 = _interopRequireDefault(_queue);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a `cargoQueue` object with the specified payload. Tasks added to the
16 + * cargoQueue will be processed together (up to the `payload` limit) in `concurrency` parallel workers.
17 + * If the all `workers` are in progress, the task is queued until one becomes available. Once
18 + * a `worker` has completed some tasks, each callback of those tasks is
19 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
20 + * for how `cargo` and `queue` work.
21 + *
22 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
23 + * at a time, and [`cargo`]{@link module:ControlFlow.cargo} passes an array of tasks to a single worker,
24 + * the cargoQueue passes an array of tasks to multiple parallel workers.
25 + *
26 + * @name cargoQueue
27 + * @static
28 + * @memberOf module:ControlFlow
29 + * @method
30 + * @see [async.queue]{@link module:ControlFlow.queue}
31 + * @see [async.cargo]{@link module:ControlFLow.cargo}
32 + * @category Control Flow
33 + * @param {AsyncFunction} worker - An asynchronous function for processing an array
34 + * of queued tasks. Invoked with `(tasks, callback)`.
35 + * @param {number} [concurrency=1] - An `integer` for determining how many
36 + * `worker` functions should be run in parallel. If omitted, the concurrency
37 + * defaults to `1`. If the concurrency is `0`, an error is thrown.
38 + * @param {number} [payload=Infinity] - An optional `integer` for determining
39 + * how many tasks should be processed per round; if omitted, the default is
40 + * unlimited.
41 + * @returns {module:ControlFlow.CargoObject} A cargoQueue object to manage the tasks. Callbacks can
42 + * attached as certain properties to listen for specific events during the
43 + * lifecycle of the cargoQueue and inner queue.
44 + * @example
45 + *
46 + * // create a cargoQueue object with payload 2 and concurrency 2
47 + * var cargoQueue = async.cargoQueue(function(tasks, callback) {
48 + * for (var i=0; i<tasks.length; i++) {
49 + * console.log('hello ' + tasks[i].name);
50 + * }
51 + * callback();
52 + * }, 2, 2);
53 + *
54 + * // add some items
55 + * cargoQueue.push({name: 'foo'}, function(err) {
56 + * console.log('finished processing foo');
57 + * });
58 + * cargoQueue.push({name: 'bar'}, function(err) {
59 + * console.log('finished processing bar');
60 + * });
61 + * cargoQueue.push({name: 'baz'}, function(err) {
62 + * console.log('finished processing baz');
63 + * });
64 + * cargoQueue.push({name: 'boo'}, function(err) {
65 + * console.log('finished processing boo');
66 + * });
67 + */
68 +function cargo(worker, concurrency, payload) {
69 + return (0, _queue2.default)(worker, concurrency, payload);
70 +}
71 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = compose;
7 +
8 +var _seq = require('./seq');
9 +
10 +var _seq2 = _interopRequireDefault(_seq);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Creates a function which is a composition of the passed asynchronous
16 + * functions. Each function consumes the return value of the function that
17 + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
18 + * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
19 + *
20 + * If the last argument to the composed function is not a function, a promise
21 + * is returned when you call it.
22 + *
23 + * Each function is executed with the `this` binding of the composed function.
24 + *
25 + * @name compose
26 + * @static
27 + * @memberOf module:ControlFlow
28 + * @method
29 + * @category Control Flow
30 + * @param {...AsyncFunction} functions - the asynchronous functions to compose
31 + * @returns {Function} an asynchronous function that is the composed
32 + * asynchronous `functions`
33 + * @example
34 + *
35 + * function add1(n, callback) {
36 + * setTimeout(function () {
37 + * callback(null, n + 1);
38 + * }, 10);
39 + * }
40 + *
41 + * function mul3(n, callback) {
42 + * setTimeout(function () {
43 + * callback(null, n * 3);
44 + * }, 10);
45 + * }
46 + *
47 + * var add1mul3 = async.compose(mul3, add1);
48 + * add1mul3(4, function (err, result) {
49 + * // result now equals 15
50 + * });
51 + */
52 +function compose(...args) {
53 + return (0, _seq2.default)(...args.reverse());
54 +}
55 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
19 + * the concatenated list. The `iteratee`s are called in parallel, and the
20 + * results are concatenated as they return. The results array will be returned in
21 + * the original order of `coll` passed to the `iteratee` function.
22 + *
23 + * @name concat
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @category Collection
28 + * @alias flatMap
29 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
30 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
31 + * which should use an array as its result. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished, or an error occurs. Results is an array
34 + * containing the concatenated results of the `iteratee` function. Invoked with
35 + * (err, results).
36 + * @returns A Promise, if no callback is passed
37 + * @example
38 + *
39 + * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
40 + * // files is now a list of filenames that exist in the 3 directories
41 + * });
42 + */
43 +function concat(coll, iteratee, callback) {
44 + return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
45 +}
46 +exports.default = (0, _awaitify2.default)(concat, 3);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _wrapAsync = require('./internal/wrapAsync');
8 +
9 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
10 +
11 +var _mapLimit = require('./mapLimit');
12 +
13 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name concatLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.concat]{@link module:Collections.concat}
29 + * @category Collection
30 + * @alias flatMapLimit
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
34 + * which should use an array as its result. Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called after all the
36 + * `iteratee` functions have finished, or an error occurs. Results is an array
37 + * containing the concatenated results of the `iteratee` function. Invoked with
38 + * (err, results).
39 + * @returns A Promise, if no callback is passed
40 + */
41 +function concatLimit(coll, limit, iteratee, callback) {
42 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
43 + return (0, _mapLimit2.default)(coll, limit, (val, iterCb) => {
44 + _iteratee(val, (err, ...args) => {
45 + if (err) return iterCb(err);
46 + return iterCb(err, args);
47 + });
48 + }, (err, mapResults) => {
49 + var result = [];
50 + for (var i = 0; i < mapResults.length; i++) {
51 + if (mapResults[i]) {
52 + result = result.concat(...mapResults[i]);
53 + }
54 + }
55 +
56 + return callback(err, result);
57 + });
58 +}
59 +exports.default = (0, _awaitify2.default)(concatLimit, 4);
60 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
19 + *
20 + * @name concatSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.concat]{@link module:Collections.concat}
25 + * @category Collection
26 + * @alias flatMapSeries
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
29 + * The iteratee should complete with an array an array of results.
30 + * Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called after all the
32 + * `iteratee` functions have finished, or an error occurs. Results is an array
33 + * containing the concatenated results of the `iteratee` function. Invoked with
34 + * (err, results).
35 + * @returns A Promise, if no callback is passed
36 + */
37 +function concatSeries(coll, iteratee, callback) {
38 + return (0, _concatLimit2.default)(coll, 1, iteratee, callback);
39 +}
40 +exports.default = (0, _awaitify2.default)(concatSeries, 3);
41 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (...args) {
8 + return function (...ignoredArgs /*, callback*/) {
9 + var callback = ignoredArgs.pop();
10 + return callback(null, ...args);
11 + };
12 +};
13 +
14 +module.exports = exports["default"]; /**
15 + * Returns a function that when called, calls-back with the values provided.
16 + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
17 + * [`auto`]{@link module:ControlFlow.auto}.
18 + *
19 + * @name constant
20 + * @static
21 + * @memberOf module:Utils
22 + * @method
23 + * @category Util
24 + * @param {...*} arguments... - Any number of arguments to automatically invoke
25 + * callback with.
26 + * @returns {AsyncFunction} Returns a function that when invoked, automatically
27 + * invokes the callback with the previous given arguments.
28 + * @example
29 + *
30 + * async.waterfall([
31 + * async.constant(42),
32 + * function (value, next) {
33 + * // value === 42
34 + * },
35 + * //...
36 + * ], callback);
37 + *
38 + * async.waterfall([
39 + * async.constant(filename, "utf8"),
40 + * fs.readFile,
41 + * function (fileData, next) {
42 + * //...
43 + * }
44 + * //...
45 + * ], callback);
46 + *
47 + * async.auto({
48 + * hostname: async.constant("https://server.net/"),
49 + * port: findFreePort,
50 + * launchServer: ["hostname", "port", function (options, cb) {
51 + * startServer(options, cb);
52 + * }],
53 + * //...
54 + * }, callback);
55 + */
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns the first value in `coll` that passes an async truth test. The
23 + * `iteratee` is applied in parallel, meaning the first iteratee to return
24 + * `true` will fire the detect `callback` with that result. That means the
25 + * result might not be the first item in the original `coll` (in terms of order)
26 + * that passes the test.
27 +
28 + * If order within the original `coll` is important, then look at
29 + * [`detectSeries`]{@link module:Collections.detectSeries}.
30 + *
31 + * @name detect
32 + * @static
33 + * @memberOf module:Collections
34 + * @method
35 + * @alias find
36 + * @category Collections
37 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
38 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
39 + * The iteratee must complete with a boolean value as its result.
40 + * Invoked with (item, callback).
41 + * @param {Function} [callback] - A callback which is called as soon as any
42 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
43 + * Result will be the first item in the array that passes the truth test
44 + * (iteratee) or the value `undefined` if none passed. Invoked with
45 + * (err, result).
46 + * @returns A Promise, if no callback is passed
47 + * @example
48 + *
49 + * async.detect(['file1','file2','file3'], function(filePath, callback) {
50 + * fs.access(filePath, function(err) {
51 + * callback(null, !err)
52 + * });
53 + * }, function(err, result) {
54 + * // result now equals the first file in the list that exists
55 + * });
56 + */
57 +function detect(coll, iteratee, callback) {
58 + return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
59 +}
60 +exports.default = (0, _awaitify2.default)(detect, 3);
61 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name detectLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.detect]{@link module:Collections.detect}
30 + * @alias findLimit
31 + * @category Collections
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
35 + * The iteratee must complete with a boolean value as its result.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
39 + * Result will be the first item in the array that passes the truth test
40 + * (iteratee) or the value `undefined` if none passed. Invoked with
41 + * (err, result).
42 + * @returns a Promise if no callback is passed
43 + */
44 +function detectLimit(coll, limit, iteratee, callback) {
45 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
46 +}
47 +exports.default = (0, _awaitify2.default)(detectLimit, 4);
48 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
23 + *
24 + * @name detectSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.detect]{@link module:Collections.detect}
29 + * @alias findSeries
30 + * @category Collections
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
33 + * The iteratee must complete with a boolean value as its result.
34 + * Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called as soon as any
36 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
37 + * Result will be the first item in the array that passes the truth test
38 + * (iteratee) or the value `undefined` if none passed. Invoked with
39 + * (err, result).
40 + * @returns a Promise if no callback is passed
41 + */
42 +function detectSeries(coll, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(1), coll, iteratee, callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(detectSeries, 3);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _consoleFunc = require('./internal/consoleFunc');
8 +
9 +var _consoleFunc2 = _interopRequireDefault(_consoleFunc);
10 +
11 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12 +
13 +/**
14 + * Logs the result of an [`async` function]{@link AsyncFunction} to the
15 + * `console` using `console.dir` to display the properties of the resulting object.
16 + * Only works in Node.js or in browsers that support `console.dir` and
17 + * `console.error` (such as FF and Chrome).
18 + * If multiple arguments are returned from the async function,
19 + * `console.dir` is called on each argument in order.
20 + *
21 + * @name dir
22 + * @static
23 + * @memberOf module:Utils
24 + * @method
25 + * @category Util
26 + * @param {AsyncFunction} function - The function you want to eventually apply
27 + * all arguments to.
28 + * @param {...*} arguments... - Any number of arguments to apply to the function.
29 + * @example
30 + *
31 + * // in a module
32 + * var hello = function(name, callback) {
33 + * setTimeout(function() {
34 + * callback(null, {hello: name});
35 + * }, 1000);
36 + * };
37 + *
38 + * // in the node repl
39 + * node> async.dir(hello, 'world');
40 + * {hello: 'world'}
41 + */
42 +exports.default = (0, _consoleFunc2.default)('dir');
43 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
23 + * the order of operations, the arguments `test` and `iteratee` are switched.
24 + *
25 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
26 + *
27 + * @name doWhilst
28 + * @static
29 + * @memberOf module:ControlFlow
30 + * @method
31 + * @see [async.whilst]{@link module:ControlFlow.whilst}
32 + * @category Control Flow
33 + * @param {AsyncFunction} iteratee - A function which is called each time `test`
34 + * passes. Invoked with (callback).
35 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
36 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
37 + * non-error args from the previous callback of `iteratee`.
38 + * @param {Function} [callback] - A callback which is called after the test
39 + * function has failed and repeated execution of `iteratee` has stopped.
40 + * `callback` will be passed an error and any arguments passed to the final
41 + * `iteratee`'s callback. Invoked with (err, [results]);
42 + * @returns {Promise} a promise, if no callback is passed
43 + */
44 +function doWhilst(iteratee, test, callback) {
45 + callback = (0, _onlyOnce2.default)(callback);
46 + var _fn = (0, _wrapAsync2.default)(iteratee);
47 + var _test = (0, _wrapAsync2.default)(test);
48 + var results;
49 +
50 + function next(err, ...args) {
51 + if (err) return callback(err);
52 + if (err === false) return;
53 + results = args;
54 + _test(...args, check);
55 + }
56 +
57 + function check(err, truth) {
58 + if (err) return callback(err);
59 + if (err === false) return;
60 + if (!truth) return callback(null, ...results);
61 + _fn(next);
62 + }
63 +
64 + return check(null, true);
65 +}
66 +
67 +exports.default = (0, _awaitify2.default)(doWhilst, 3);
68 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = doUntil;
7 +
8 +var _doWhilst = require('./doWhilst');
9 +
10 +var _doWhilst2 = _interopRequireDefault(_doWhilst);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
20 + * argument ordering differs from `until`.
21 + *
22 + * @name doUntil
23 + * @static
24 + * @memberOf module:ControlFlow
25 + * @method
26 + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
27 + * @category Control Flow
28 + * @param {AsyncFunction} iteratee - An async function which is called each time
29 + * `test` fails. Invoked with (callback).
30 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
31 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
32 + * non-error args from the previous callback of `iteratee`
33 + * @param {Function} [callback] - A callback which is called after the test
34 + * function has passed and repeated execution of `iteratee` has stopped. `callback`
35 + * will be passed an error and any arguments passed to the final `iteratee`'s
36 + * callback. Invoked with (err, [results]);
37 + * @returns {Promise} a promise, if no callback is passed
38 + */
39 +function doUntil(iteratee, test, callback) {
40 + const _test = (0, _wrapAsync2.default)(test);
41 + return (0, _doWhilst2.default)(iteratee, (...args) => {
42 + const cb = args.pop();
43 + _test(...args, (err, truth) => cb(err, !truth));
44 + }, callback);
45 +}
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
23 + * the order of operations, the arguments `test` and `iteratee` are switched.
24 + *
25 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
26 + *
27 + * @name doWhilst
28 + * @static
29 + * @memberOf module:ControlFlow
30 + * @method
31 + * @see [async.whilst]{@link module:ControlFlow.whilst}
32 + * @category Control Flow
33 + * @param {AsyncFunction} iteratee - A function which is called each time `test`
34 + * passes. Invoked with (callback).
35 + * @param {AsyncFunction} test - asynchronous truth test to perform after each
36 + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
37 + * non-error args from the previous callback of `iteratee`.
38 + * @param {Function} [callback] - A callback which is called after the test
39 + * function has failed and repeated execution of `iteratee` has stopped.
40 + * `callback` will be passed an error and any arguments passed to the final
41 + * `iteratee`'s callback. Invoked with (err, [results]);
42 + * @returns {Promise} a promise, if no callback is passed
43 + */
44 +function doWhilst(iteratee, test, callback) {
45 + callback = (0, _onlyOnce2.default)(callback);
46 + var _fn = (0, _wrapAsync2.default)(iteratee);
47 + var _test = (0, _wrapAsync2.default)(test);
48 + var results;
49 +
50 + function next(err, ...args) {
51 + if (err) return callback(err);
52 + if (err === false) return;
53 + results = args;
54 + _test(...args, check);
55 + }
56 +
57 + function check(err, truth) {
58 + if (err) return callback(err);
59 + if (err === false) return;
60 + if (!truth) return callback(null, ...results);
61 + _fn(next);
62 + }
63 +
64 + return check(null, true);
65 +}
66 +
67 +exports.default = (0, _awaitify2.default)(doWhilst, 3);
68 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
23 + * stopped, or an error occurs.
24 + *
25 + * @name whilst
26 + * @static
27 + * @memberOf module:ControlFlow
28 + * @method
29 + * @category Control Flow
30 + * @param {AsyncFunction} test - asynchronous truth test to perform before each
31 + * execution of `iteratee`. Invoked with ().
32 + * @param {AsyncFunction} iteratee - An async function which is called each time
33 + * `test` passes. Invoked with (callback).
34 + * @param {Function} [callback] - A callback which is called after the test
35 + * function has failed and repeated execution of `iteratee` has stopped. `callback`
36 + * will be passed an error and any arguments passed to the final `iteratee`'s
37 + * callback. Invoked with (err, [results]);
38 + * @returns {Promise} a promise, if no callback is passed
39 + * @example
40 + *
41 + * var count = 0;
42 + * async.whilst(
43 + * function test(cb) { cb(null, count < 5;) },
44 + * function iter(callback) {
45 + * count++;
46 + * setTimeout(function() {
47 + * callback(null, count);
48 + * }, 1000);
49 + * },
50 + * function (err, n) {
51 + * // 5 seconds have passed, n = 5
52 + * }
53 + * );
54 + */
55 +function whilst(test, iteratee, callback) {
56 + callback = (0, _onlyOnce2.default)(callback);
57 + var _fn = (0, _wrapAsync2.default)(iteratee);
58 + var _test = (0, _wrapAsync2.default)(test);
59 + var results = [];
60 +
61 + function next(err, ...rest) {
62 + if (err) return callback(err);
63 + results = rest;
64 + if (err === false) return;
65 + _test(check);
66 + }
67 +
68 + function check(err, truth) {
69 + if (err) return callback(err);
70 + if (err === false) return;
71 + if (!truth) return callback(null, ...results);
72 + _fn(next);
73 + }
74 +
75 + return _test(check);
76 +}
77 +exports.default = (0, _awaitify2.default)(whilst, 3);
78 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOf = require('./eachOf');
8 +
9 +var _eachOf2 = _interopRequireDefault(_eachOf);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Applies the function `iteratee` to each item in `coll`, in parallel.
27 + * The `iteratee` is called with an item from the list, and a callback for when
28 + * it has finished. If the `iteratee` passes an error to its `callback`, the
29 + * main `callback` (for the `each` function) is immediately called with the
30 + * error.
31 + *
32 + * Note, that since this function applies `iteratee` to each item in parallel,
33 + * there is no guarantee that the iteratee functions will complete in order.
34 + *
35 + * @name each
36 + * @static
37 + * @memberOf module:Collections
38 + * @method
39 + * @alias forEach
40 + * @category Collection
41 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
42 + * @param {AsyncFunction} iteratee - An async function to apply to
43 + * each item in `coll`. Invoked with (item, callback).
44 + * The array index is not passed to the iteratee.
45 + * If you need the index, use `eachOf`.
46 + * @param {Function} [callback] - A callback which is called when all
47 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
48 + * @returns {Promise} a promise, if a callback is omitted
49 + * @example
50 + *
51 + * // assuming openFiles is an array of file names and saveFile is a function
52 + * // to save the modified contents of that file:
53 + *
54 + * async.each(openFiles, saveFile, function(err){
55 + * // if any of the saves produced an error, err would equal that error
56 + * });
57 + *
58 + * // assuming openFiles is an array of file names
59 + * async.each(openFiles, function(file, callback) {
60 + *
61 + * // Perform operation on file here.
62 + * console.log('Processing file ' + file);
63 + *
64 + * if( file.length > 32 ) {
65 + * console.log('This file name is too long');
66 + * callback('File name too long');
67 + * } else {
68 + * // Do work to process file here
69 + * console.log('File processed');
70 + * callback();
71 + * }
72 + * }, function(err) {
73 + * // if any of the file processing produced an error, err would equal that error
74 + * if( err ) {
75 + * // One of the iterations produced an error.
76 + * // All processing will now stop.
77 + * console.log('A file failed to process');
78 + * } else {
79 + * console.log('All files have been processed successfully');
80 + * }
81 + * });
82 + */
83 +function eachLimit(coll, iteratee, callback) {
84 + return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
85 +}
86 +
87 +exports.default = (0, _awaitify2.default)(eachLimit, 3);
88 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./internal/eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
27 + *
28 + * @name eachLimit
29 + * @static
30 + * @memberOf module:Collections
31 + * @method
32 + * @see [async.each]{@link module:Collections.each}
33 + * @alias forEachLimit
34 + * @category Collection
35 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
36 + * @param {number} limit - The maximum number of async operations at a time.
37 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
38 + * `coll`.
39 + * The array index is not passed to the iteratee.
40 + * If you need the index, use `eachOfLimit`.
41 + * Invoked with (item, callback).
42 + * @param {Function} [callback] - A callback which is called when all
43 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
44 + * @returns {Promise} a promise, if a callback is omitted
45 + */
46 +function eachLimit(coll, limit, iteratee, callback) {
47 + return (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
48 +}
49 +exports.default = (0, _awaitify2.default)(eachLimit, 4);
50 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _isArrayLike = require('./internal/isArrayLike');
8 +
9 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
10 +
11 +var _breakLoop = require('./internal/breakLoop');
12 +
13 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
14 +
15 +var _eachOfLimit = require('./eachOfLimit');
16 +
17 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
18 +
19 +var _once = require('./internal/once');
20 +
21 +var _once2 = _interopRequireDefault(_once);
22 +
23 +var _onlyOnce = require('./internal/onlyOnce');
24 +
25 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
26 +
27 +var _wrapAsync = require('./internal/wrapAsync');
28 +
29 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
30 +
31 +var _awaitify = require('./internal/awaitify');
32 +
33 +var _awaitify2 = _interopRequireDefault(_awaitify);
34 +
35 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36 +
37 +// eachOf implementation optimized for array-likes
38 +function eachOfArrayLike(coll, iteratee, callback) {
39 + callback = (0, _once2.default)(callback);
40 + var index = 0,
41 + completed = 0,
42 + { length } = coll,
43 + canceled = false;
44 + if (length === 0) {
45 + callback(null);
46 + }
47 +
48 + function iteratorCallback(err, value) {
49 + if (err === false) {
50 + canceled = true;
51 + }
52 + if (canceled === true) return;
53 + if (err) {
54 + callback(err);
55 + } else if (++completed === length || value === _breakLoop2.default) {
56 + callback(null);
57 + }
58 + }
59 +
60 + for (; index < length; index++) {
61 + iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
62 + }
63 +}
64 +
65 +// a generic version of eachOf which can handle array, object, and iterator cases.
66 +function eachOfGeneric(coll, iteratee, callback) {
67 + return (0, _eachOfLimit2.default)(coll, Infinity, iteratee, callback);
68 +}
69 +
70 +/**
71 + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
72 + * to the iteratee.
73 + *
74 + * @name eachOf
75 + * @static
76 + * @memberOf module:Collections
77 + * @method
78 + * @alias forEachOf
79 + * @category Collection
80 + * @see [async.each]{@link module:Collections.each}
81 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
82 + * @param {AsyncFunction} iteratee - A function to apply to each
83 + * item in `coll`.
84 + * The `key` is the item's key, or index in the case of an array.
85 + * Invoked with (item, key, callback).
86 + * @param {Function} [callback] - A callback which is called when all
87 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
88 + * @returns {Promise} a promise, if a callback is omitted
89 + * @example
90 + *
91 + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
92 + * var configs = {};
93 + *
94 + * async.forEachOf(obj, function (value, key, callback) {
95 + * fs.readFile(__dirname + value, "utf8", function (err, data) {
96 + * if (err) return callback(err);
97 + * try {
98 + * configs[key] = JSON.parse(data);
99 + * } catch (e) {
100 + * return callback(e);
101 + * }
102 + * callback();
103 + * });
104 + * }, function (err) {
105 + * if (err) console.error(err.message);
106 + * // configs is now a map of JSON data
107 + * doSomethingWith(configs);
108 + * });
109 + */
110 +function eachOf(coll, iteratee, callback) {
111 + var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
112 + return eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
113 +}
114 +
115 +exports.default = (0, _awaitify2.default)(eachOf, 3);
116 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit2 = require('./internal/eachOfLimit');
8 +
9 +var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name eachOfLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.eachOf]{@link module:Collections.eachOf}
30 + * @alias forEachOfLimit
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - An async function to apply to each
35 + * item in `coll`. The `key` is the item's key, or index in the case of an
36 + * array.
37 + * Invoked with (item, key, callback).
38 + * @param {Function} [callback] - A callback which is called when all
39 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
40 + * @returns {Promise} a promise, if a callback is omitted
41 + */
42 +function eachOfLimit(coll, limit, iteratee, callback) {
43 + return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(eachOfLimit, 4);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
19 + *
20 + * @name eachOfSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.eachOf]{@link module:Collections.eachOf}
25 + * @alias forEachOfSeries
26 + * @category Collection
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
29 + * `coll`.
30 + * Invoked with (item, key, callback).
31 + * @param {Function} [callback] - A callback which is called when all `iteratee`
32 + * functions have finished, or an error occurs. Invoked with (err).
33 + * @returns {Promise} a promise, if a callback is omitted
34 + */
35 +function eachOfSeries(coll, iteratee, callback) {
36 + return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback);
37 +}
38 +exports.default = (0, _awaitify2.default)(eachOfSeries, 3);
39 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachLimit = require('./eachLimit');
8 +
9 +var _eachLimit2 = _interopRequireDefault(_eachLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
19 + *
20 + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item
21 + * in series and therefore the iteratee functions will complete in order.
22 +
23 + * @name eachSeries
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @see [async.each]{@link module:Collections.each}
28 + * @alias forEachSeries
29 + * @category Collection
30 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 + * @param {AsyncFunction} iteratee - An async function to apply to each
32 + * item in `coll`.
33 + * The array index is not passed to the iteratee.
34 + * If you need the index, use `eachOfSeries`.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called when all
37 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
38 + * @returns {Promise} a promise, if a callback is omitted
39 + */
40 +function eachSeries(coll, iteratee, callback) {
41 + return (0, _eachLimit2.default)(coll, 1, iteratee, callback);
42 +}
43 +exports.default = (0, _awaitify2.default)(eachSeries, 3);
44 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = ensureAsync;
7 +
8 +var _setImmediate = require('./internal/setImmediate');
9 +
10 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
11 +
12 +var _wrapAsync = require('./internal/wrapAsync');
13 +
14 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 +
16 +/**
17 + * Wrap an async function and ensure it calls its callback on a later tick of
18 + * the event loop. If the function already calls its callback on a next tick,
19 + * no extra deferral is added. This is useful for preventing stack overflows
20 + * (`RangeError: Maximum call stack size exceeded`) and generally keeping
21 + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
22 + * contained. ES2017 `async` functions are returned as-is -- they are immune
23 + * to Zalgo's corrupting influences, as they always resolve on a later tick.
24 + *
25 + * @name ensureAsync
26 + * @static
27 + * @memberOf module:Utils
28 + * @method
29 + * @category Util
30 + * @param {AsyncFunction} fn - an async function, one that expects a node-style
31 + * callback as its last argument.
32 + * @returns {AsyncFunction} Returns a wrapped function with the exact same call
33 + * signature as the function passed in.
34 + * @example
35 + *
36 + * function sometimesAsync(arg, callback) {
37 + * if (cache[arg]) {
38 + * return callback(null, cache[arg]); // this would be synchronous!!
39 + * } else {
40 + * doSomeIO(arg, callback); // this IO would be asynchronous
41 + * }
42 + * }
43 + *
44 + * // this has a risk of stack overflows if many results are cached in a row
45 + * async.mapSeries(args, sometimesAsync, done);
46 + *
47 + * // this will defer sometimesAsync's callback if necessary,
48 + * // preventing stack overflows
49 + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
50 + */
51 +function ensureAsync(fn) {
52 + if ((0, _wrapAsync.isAsync)(fn)) return fn;
53 + return function (...args /*, callback*/) {
54 + var callback = args.pop();
55 + var sync = true;
56 + args.push((...innerArgs) => {
57 + if (sync) {
58 + (0, _setImmediate2.default)(() => callback(...innerArgs));
59 + } else {
60 + callback(...innerArgs);
61 + }
62 + });
63 + fn.apply(this, args);
64 + sync = false;
65 + };
66 +}
67 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns `true` if every element in `coll` satisfies an async test. If any
23 + * iteratee call returns `false`, the main `callback` is immediately called.
24 + *
25 + * @name every
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @alias all
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in parallel.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + * @example
41 + *
42 + * async.every(['file1','file2','file3'], function(filePath, callback) {
43 + * fs.access(filePath, function(err) {
44 + * callback(null, !err)
45 + * });
46 + * }, function(err, result) {
47 + * // if result is true then every file exists
48 + * });
49 + */
50 +function every(coll, iteratee, callback) {
51 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOf2.default, coll, iteratee, callback);
52 +}
53 +exports.default = (0, _awaitify2.default)(every, 3);
54 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name everyLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allLimit
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
34 + * in the collection in parallel.
35 + * The iteratee must complete with a boolean result value.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Result will be either `true` or `false`
39 + * depending on the values of the async tests. Invoked with (err, result).
40 + * @returns {Promise} a promise, if no callback provided
41 + */
42 +function everyLimit(coll, limit, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => !bool, res => !res)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
44 +}
45 +exports.default = (0, _awaitify2.default)(everyLimit, 4);
46 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfSeries = require('./eachOfSeries');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
23 + *
24 + * @name everySeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.every]{@link module:Collections.every}
29 + * @alias allSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - An async truth test to apply to each item
33 + * in the collection in series.
34 + * The iteratee must complete with a boolean result value.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Result will be either `true` or `false`
38 + * depending on the values of the async tests. Invoked with (err, result).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function everySeries(coll, iteratee, callback) {
42 + return (0, _createTester2.default)(bool => !bool, res => !res)(_eachOfSeries2.default, coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(everySeries, 3);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns a new array of all the values in `coll` which pass an async truth
23 + * test. This operation is performed in parallel, but the results array will be
24 + * in the same order as the original.
25 + *
26 + * @name filter
27 + * @static
28 + * @memberOf module:Collections
29 + * @method
30 + * @alias select
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
34 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
35 + * with a boolean argument once it has completed. Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called after all the
37 + * `iteratee` functions have finished. Invoked with (err, results).
38 + * @returns {Promise} a promise, if no callback provided
39 + * @example
40 + *
41 + * async.filter(['file1','file2','file3'], function(filePath, callback) {
42 + * fs.access(filePath, function(err) {
43 + * callback(null, !err)
44 + * });
45 + * }, function(err, results) {
46 + * // results now equals an array of the existing files
47 + * });
48 + */
49 +function filter(coll, iteratee, callback) {
50 + return (0, _filter3.default)(_eachOf2.default, coll, iteratee, callback);
51 +}
52 +exports.default = (0, _awaitify2.default)(filter, 3);
53 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name filterLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.filter]{@link module:Collections.filter}
30 + * @alias selectLimit
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
35 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
36 + * with a boolean argument once it has completed. Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called after all the
38 + * `iteratee` functions have finished. Invoked with (err, results).
39 + * @returns {Promise} a promise, if no callback provided
40 + */
41 +function filterLimit(coll, limit, iteratee, callback) {
42 + return (0, _filter3.default)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
43 +}
44 +exports.default = (0, _awaitify2.default)(filterLimit, 4);
45 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _filter2 = require('./internal/filter');
8 +
9 +var _filter3 = _interopRequireDefault(_filter2);
10 +
11 +var _eachOfSeries = require('./eachOfSeries');
12 +
13 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
23 + *
24 + * @name filterSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.filter]{@link module:Collections.filter}
29 + * @alias selectSeries
30 + * @category Collection
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
33 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
34 + * with a boolean argument once it has completed. Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called after all the
36 + * `iteratee` functions have finished. Invoked with (err, results)
37 + * @returns {Promise} a promise, if no callback provided
38 + */
39 +function filterSeries(coll, iteratee, callback) {
40 + return (0, _filter3.default)(_eachOfSeries2.default, coll, iteratee, callback);
41 +}
42 +exports.default = (0, _awaitify2.default)(filterSeries, 3);
43 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOf = require('./eachOf');
12 +
13 +var _eachOf2 = _interopRequireDefault(_eachOf);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * Returns the first value in `coll` that passes an async truth test. The
23 + * `iteratee` is applied in parallel, meaning the first iteratee to return
24 + * `true` will fire the detect `callback` with that result. That means the
25 + * result might not be the first item in the original `coll` (in terms of order)
26 + * that passes the test.
27 +
28 + * If order within the original `coll` is important, then look at
29 + * [`detectSeries`]{@link module:Collections.detectSeries}.
30 + *
31 + * @name detect
32 + * @static
33 + * @memberOf module:Collections
34 + * @method
35 + * @alias find
36 + * @category Collections
37 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
38 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
39 + * The iteratee must complete with a boolean value as its result.
40 + * Invoked with (item, callback).
41 + * @param {Function} [callback] - A callback which is called as soon as any
42 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
43 + * Result will be the first item in the array that passes the truth test
44 + * (iteratee) or the value `undefined` if none passed. Invoked with
45 + * (err, result).
46 + * @returns A Promise, if no callback is passed
47 + * @example
48 + *
49 + * async.detect(['file1','file2','file3'], function(filePath, callback) {
50 + * fs.access(filePath, function(err) {
51 + * callback(null, !err)
52 + * });
53 + * }, function(err, result) {
54 + * // result now equals the first file in the list that exists
55 + * });
56 + */
57 +function detect(coll, iteratee, callback) {
58 + return (0, _createTester2.default)(bool => bool, (res, item) => item)(_eachOf2.default, coll, iteratee, callback);
59 +}
60 +exports.default = (0, _awaitify2.default)(detect, 3);
61 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name detectLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.detect]{@link module:Collections.detect}
30 + * @alias findLimit
31 + * @category Collections
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
35 + * The iteratee must complete with a boolean value as its result.
36 + * Invoked with (item, callback).
37 + * @param {Function} [callback] - A callback which is called as soon as any
38 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
39 + * Result will be the first item in the array that passes the truth test
40 + * (iteratee) or the value `undefined` if none passed. Invoked with
41 + * (err, result).
42 + * @returns a Promise if no callback is passed
43 + */
44 +function detectLimit(coll, limit, iteratee, callback) {
45 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(limit), coll, iteratee, callback);
46 +}
47 +exports.default = (0, _awaitify2.default)(detectLimit, 4);
48 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./internal/eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
23 + *
24 + * @name detectSeries
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.detect]{@link module:Collections.detect}
29 + * @alias findSeries
30 + * @category Collections
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
33 + * The iteratee must complete with a boolean value as its result.
34 + * Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called as soon as any
36 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
37 + * Result will be the first item in the array that passes the truth test
38 + * (iteratee) or the value `undefined` if none passed. Invoked with
39 + * (err, result).
40 + * @returns a Promise if no callback is passed
41 + */
42 +function detectSeries(coll, iteratee, callback) {
43 + return (0, _createTester2.default)(bool => bool, (res, item) => item)((0, _eachOfLimit2.default)(1), coll, iteratee, callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(detectSeries, 3);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
19 + * the concatenated list. The `iteratee`s are called in parallel, and the
20 + * results are concatenated as they return. The results array will be returned in
21 + * the original order of `coll` passed to the `iteratee` function.
22 + *
23 + * @name concat
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @category Collection
28 + * @alias flatMap
29 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
30 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
31 + * which should use an array as its result. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished, or an error occurs. Results is an array
34 + * containing the concatenated results of the `iteratee` function. Invoked with
35 + * (err, results).
36 + * @returns A Promise, if no callback is passed
37 + * @example
38 + *
39 + * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
40 + * // files is now a list of filenames that exist in the 3 directories
41 + * });
42 + */
43 +function concat(coll, iteratee, callback) {
44 + return (0, _concatLimit2.default)(coll, Infinity, iteratee, callback);
45 +}
46 +exports.default = (0, _awaitify2.default)(concat, 3);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _wrapAsync = require('./internal/wrapAsync');
8 +
9 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
10 +
11 +var _mapLimit = require('./mapLimit');
12 +
13 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name concatLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.concat]{@link module:Collections.concat}
29 + * @category Collection
30 + * @alias flatMapLimit
31 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
34 + * which should use an array as its result. Invoked with (item, callback).
35 + * @param {Function} [callback] - A callback which is called after all the
36 + * `iteratee` functions have finished, or an error occurs. Results is an array
37 + * containing the concatenated results of the `iteratee` function. Invoked with
38 + * (err, results).
39 + * @returns A Promise, if no callback is passed
40 + */
41 +function concatLimit(coll, limit, iteratee, callback) {
42 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
43 + return (0, _mapLimit2.default)(coll, limit, (val, iterCb) => {
44 + _iteratee(val, (err, ...args) => {
45 + if (err) return iterCb(err);
46 + return iterCb(err, args);
47 + });
48 + }, (err, mapResults) => {
49 + var result = [];
50 + for (var i = 0; i < mapResults.length; i++) {
51 + if (mapResults[i]) {
52 + result = result.concat(...mapResults[i]);
53 + }
54 + }
55 +
56 + return callback(err, result);
57 + });
58 +}
59 +exports.default = (0, _awaitify2.default)(concatLimit, 4);
60 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _concatLimit = require('./concatLimit');
8 +
9 +var _concatLimit2 = _interopRequireDefault(_concatLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
19 + *
20 + * @name concatSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.concat]{@link module:Collections.concat}
25 + * @category Collection
26 + * @alias flatMapSeries
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
29 + * The iteratee should complete with an array an array of results.
30 + * Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called after all the
32 + * `iteratee` functions have finished, or an error occurs. Results is an array
33 + * containing the concatenated results of the `iteratee` function. Invoked with
34 + * (err, results).
35 + * @returns A Promise, if no callback is passed
36 + */
37 +function concatSeries(coll, iteratee, callback) {
38 + return (0, _concatLimit2.default)(coll, 1, iteratee, callback);
39 +}
40 +exports.default = (0, _awaitify2.default)(concatSeries, 3);
41 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfSeries = require('./eachOfSeries');
8 +
9 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
10 +
11 +var _once = require('./internal/once');
12 +
13 +var _once2 = _interopRequireDefault(_once);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Reduces `coll` into a single value using an async `iteratee` to return each
27 + * successive step. `memo` is the initial state of the reduction. This function
28 + * only operates in series.
29 + *
30 + * For performance reasons, it may make sense to split a call to this function
31 + * into a parallel map, and then use the normal `Array.prototype.reduce` on the
32 + * results. This function is for situations where each step in the reduction
33 + * needs to be async; if you can get the data before reducing it, then it's
34 + * probably a good idea to do so.
35 + *
36 + * @name reduce
37 + * @static
38 + * @memberOf module:Collections
39 + * @method
40 + * @alias inject
41 + * @alias foldl
42 + * @category Collection
43 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
44 + * @param {*} memo - The initial state of the reduction.
45 + * @param {AsyncFunction} iteratee - A function applied to each item in the
46 + * array to produce the next step in the reduction.
47 + * The `iteratee` should complete with the next state of the reduction.
48 + * If the iteratee complete with an error, the reduction is stopped and the
49 + * main `callback` is immediately called with the error.
50 + * Invoked with (memo, item, callback).
51 + * @param {Function} [callback] - A callback which is called after all the
52 + * `iteratee` functions have finished. Result is the reduced value. Invoked with
53 + * (err, result).
54 + * @returns {Promise} a promise, if no callback is passed
55 + * @example
56 + *
57 + * async.reduce([1,2,3], 0, function(memo, item, callback) {
58 + * // pointless async:
59 + * process.nextTick(function() {
60 + * callback(null, memo + item)
61 + * });
62 + * }, function(err, result) {
63 + * // result is now equal to the last value of memo, which is 6
64 + * });
65 + */
66 +function reduce(coll, memo, iteratee, callback) {
67 + callback = (0, _once2.default)(callback);
68 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
69 + return (0, _eachOfSeries2.default)(coll, (x, i, iterCb) => {
70 + _iteratee(memo, x, (err, v) => {
71 + memo = v;
72 + iterCb(err);
73 + });
74 + }, err => callback(err, memo));
75 +}
76 +exports.default = (0, _awaitify2.default)(reduce, 4);
77 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = reduceRight;
7 +
8 +var _reduce = require('./reduce');
9 +
10 +var _reduce2 = _interopRequireDefault(_reduce);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
16 + *
17 + * @name reduceRight
18 + * @static
19 + * @memberOf module:Collections
20 + * @method
21 + * @see [async.reduce]{@link module:Collections.reduce}
22 + * @alias foldr
23 + * @category Collection
24 + * @param {Array} array - A collection to iterate over.
25 + * @param {*} memo - The initial state of the reduction.
26 + * @param {AsyncFunction} iteratee - A function applied to each item in the
27 + * array to produce the next step in the reduction.
28 + * The `iteratee` should complete with the next state of the reduction.
29 + * If the iteratee complete with an error, the reduction is stopped and the
30 + * main `callback` is immediately called with the error.
31 + * Invoked with (memo, item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished. Result is the reduced value. Invoked with
34 + * (err, result).
35 + * @returns {Promise} a promise, if no callback is passed
36 + */
37 +function reduceRight(array, memo, iteratee, callback) {
38 + var reversed = [...array].reverse();
39 + return (0, _reduce2.default)(reversed, memo, iteratee, callback);
40 +}
41 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOf = require('./eachOf');
8 +
9 +var _eachOf2 = _interopRequireDefault(_eachOf);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Applies the function `iteratee` to each item in `coll`, in parallel.
27 + * The `iteratee` is called with an item from the list, and a callback for when
28 + * it has finished. If the `iteratee` passes an error to its `callback`, the
29 + * main `callback` (for the `each` function) is immediately called with the
30 + * error.
31 + *
32 + * Note, that since this function applies `iteratee` to each item in parallel,
33 + * there is no guarantee that the iteratee functions will complete in order.
34 + *
35 + * @name each
36 + * @static
37 + * @memberOf module:Collections
38 + * @method
39 + * @alias forEach
40 + * @category Collection
41 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
42 + * @param {AsyncFunction} iteratee - An async function to apply to
43 + * each item in `coll`. Invoked with (item, callback).
44 + * The array index is not passed to the iteratee.
45 + * If you need the index, use `eachOf`.
46 + * @param {Function} [callback] - A callback which is called when all
47 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
48 + * @returns {Promise} a promise, if a callback is omitted
49 + * @example
50 + *
51 + * // assuming openFiles is an array of file names and saveFile is a function
52 + * // to save the modified contents of that file:
53 + *
54 + * async.each(openFiles, saveFile, function(err){
55 + * // if any of the saves produced an error, err would equal that error
56 + * });
57 + *
58 + * // assuming openFiles is an array of file names
59 + * async.each(openFiles, function(file, callback) {
60 + *
61 + * // Perform operation on file here.
62 + * console.log('Processing file ' + file);
63 + *
64 + * if( file.length > 32 ) {
65 + * console.log('This file name is too long');
66 + * callback('File name too long');
67 + * } else {
68 + * // Do work to process file here
69 + * console.log('File processed');
70 + * callback();
71 + * }
72 + * }, function(err) {
73 + * // if any of the file processing produced an error, err would equal that error
74 + * if( err ) {
75 + * // One of the iterations produced an error.
76 + * // All processing will now stop.
77 + * console.log('A file failed to process');
78 + * } else {
79 + * console.log('All files have been processed successfully');
80 + * }
81 + * });
82 + */
83 +function eachLimit(coll, iteratee, callback) {
84 + return (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
85 +}
86 +
87 +exports.default = (0, _awaitify2.default)(eachLimit, 3);
88 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./internal/eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _withoutIndex = require('./internal/withoutIndex');
12 +
13 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
27 + *
28 + * @name eachLimit
29 + * @static
30 + * @memberOf module:Collections
31 + * @method
32 + * @see [async.each]{@link module:Collections.each}
33 + * @alias forEachLimit
34 + * @category Collection
35 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
36 + * @param {number} limit - The maximum number of async operations at a time.
37 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
38 + * `coll`.
39 + * The array index is not passed to the iteratee.
40 + * If you need the index, use `eachOfLimit`.
41 + * Invoked with (item, callback).
42 + * @param {Function} [callback] - A callback which is called when all
43 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
44 + * @returns {Promise} a promise, if a callback is omitted
45 + */
46 +function eachLimit(coll, limit, iteratee, callback) {
47 + return (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
48 +}
49 +exports.default = (0, _awaitify2.default)(eachLimit, 4);
50 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _isArrayLike = require('./internal/isArrayLike');
8 +
9 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
10 +
11 +var _breakLoop = require('./internal/breakLoop');
12 +
13 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
14 +
15 +var _eachOfLimit = require('./eachOfLimit');
16 +
17 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
18 +
19 +var _once = require('./internal/once');
20 +
21 +var _once2 = _interopRequireDefault(_once);
22 +
23 +var _onlyOnce = require('./internal/onlyOnce');
24 +
25 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
26 +
27 +var _wrapAsync = require('./internal/wrapAsync');
28 +
29 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
30 +
31 +var _awaitify = require('./internal/awaitify');
32 +
33 +var _awaitify2 = _interopRequireDefault(_awaitify);
34 +
35 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36 +
37 +// eachOf implementation optimized for array-likes
38 +function eachOfArrayLike(coll, iteratee, callback) {
39 + callback = (0, _once2.default)(callback);
40 + var index = 0,
41 + completed = 0,
42 + { length } = coll,
43 + canceled = false;
44 + if (length === 0) {
45 + callback(null);
46 + }
47 +
48 + function iteratorCallback(err, value) {
49 + if (err === false) {
50 + canceled = true;
51 + }
52 + if (canceled === true) return;
53 + if (err) {
54 + callback(err);
55 + } else if (++completed === length || value === _breakLoop2.default) {
56 + callback(null);
57 + }
58 + }
59 +
60 + for (; index < length; index++) {
61 + iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
62 + }
63 +}
64 +
65 +// a generic version of eachOf which can handle array, object, and iterator cases.
66 +function eachOfGeneric(coll, iteratee, callback) {
67 + return (0, _eachOfLimit2.default)(coll, Infinity, iteratee, callback);
68 +}
69 +
70 +/**
71 + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
72 + * to the iteratee.
73 + *
74 + * @name eachOf
75 + * @static
76 + * @memberOf module:Collections
77 + * @method
78 + * @alias forEachOf
79 + * @category Collection
80 + * @see [async.each]{@link module:Collections.each}
81 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
82 + * @param {AsyncFunction} iteratee - A function to apply to each
83 + * item in `coll`.
84 + * The `key` is the item's key, or index in the case of an array.
85 + * Invoked with (item, key, callback).
86 + * @param {Function} [callback] - A callback which is called when all
87 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
88 + * @returns {Promise} a promise, if a callback is omitted
89 + * @example
90 + *
91 + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
92 + * var configs = {};
93 + *
94 + * async.forEachOf(obj, function (value, key, callback) {
95 + * fs.readFile(__dirname + value, "utf8", function (err, data) {
96 + * if (err) return callback(err);
97 + * try {
98 + * configs[key] = JSON.parse(data);
99 + * } catch (e) {
100 + * return callback(e);
101 + * }
102 + * callback();
103 + * });
104 + * }, function (err) {
105 + * if (err) console.error(err.message);
106 + * // configs is now a map of JSON data
107 + * doSomethingWith(configs);
108 + * });
109 + */
110 +function eachOf(coll, iteratee, callback) {
111 + var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
112 + return eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
113 +}
114 +
115 +exports.default = (0, _awaitify2.default)(eachOf, 3);
116 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit2 = require('./internal/eachOfLimit');
8 +
9 +var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
23 + * time.
24 + *
25 + * @name eachOfLimit
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @see [async.eachOf]{@link module:Collections.eachOf}
30 + * @alias forEachOfLimit
31 + * @category Collection
32 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {AsyncFunction} iteratee - An async function to apply to each
35 + * item in `coll`. The `key` is the item's key, or index in the case of an
36 + * array.
37 + * Invoked with (item, key, callback).
38 + * @param {Function} [callback] - A callback which is called when all
39 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
40 + * @returns {Promise} a promise, if a callback is omitted
41 + */
42 +function eachOfLimit(coll, limit, iteratee, callback) {
43 + return (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
44 +}
45 +
46 +exports.default = (0, _awaitify2.default)(eachOfLimit, 4);
47 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfLimit = require('./eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
19 + *
20 + * @name eachOfSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.eachOf]{@link module:Collections.eachOf}
25 + * @alias forEachOfSeries
26 + * @category Collection
27 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
28 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
29 + * `coll`.
30 + * Invoked with (item, key, callback).
31 + * @param {Function} [callback] - A callback which is called when all `iteratee`
32 + * functions have finished, or an error occurs. Invoked with (err).
33 + * @returns {Promise} a promise, if a callback is omitted
34 + */
35 +function eachOfSeries(coll, iteratee, callback) {
36 + return (0, _eachOfLimit2.default)(coll, 1, iteratee, callback);
37 +}
38 +exports.default = (0, _awaitify2.default)(eachOfSeries, 3);
39 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachLimit = require('./eachLimit');
8 +
9 +var _eachLimit2 = _interopRequireDefault(_eachLimit);
10 +
11 +var _awaitify = require('./internal/awaitify');
12 +
13 +var _awaitify2 = _interopRequireDefault(_awaitify);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
19 + *
20 + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item
21 + * in series and therefore the iteratee functions will complete in order.
22 +
23 + * @name eachSeries
24 + * @static
25 + * @memberOf module:Collections
26 + * @method
27 + * @see [async.each]{@link module:Collections.each}
28 + * @alias forEachSeries
29 + * @category Collection
30 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 + * @param {AsyncFunction} iteratee - An async function to apply to each
32 + * item in `coll`.
33 + * The array index is not passed to the iteratee.
34 + * If you need the index, use `eachOfSeries`.
35 + * Invoked with (item, callback).
36 + * @param {Function} [callback] - A callback which is called when all
37 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
38 + * @returns {Promise} a promise, if a callback is omitted
39 + */
40 +function eachSeries(coll, iteratee, callback) {
41 + return (0, _eachLimit2.default)(coll, 1, iteratee, callback);
42 +}
43 +exports.default = (0, _awaitify2.default)(eachSeries, 3);
44 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _onlyOnce = require('./internal/onlyOnce');
8 +
9 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
10 +
11 +var _ensureAsync = require('./ensureAsync');
12 +
13 +var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Calls the asynchronous function `fn` with a callback parameter that allows it
27 + * to call itself again, in series, indefinitely.
28 +
29 + * If an error is passed to the callback then `errback` is called with the
30 + * error, and execution stops, otherwise it will never be called.
31 + *
32 + * @name forever
33 + * @static
34 + * @memberOf module:ControlFlow
35 + * @method
36 + * @category Control Flow
37 + * @param {AsyncFunction} fn - an async function to call repeatedly.
38 + * Invoked with (next).
39 + * @param {Function} [errback] - when `fn` passes an error to it's callback,
40 + * this function will be called, and execution stops. Invoked with (err).
41 + * @returns {Promise} a promise that rejects if an error occurs and an errback
42 + * is not passed
43 + * @example
44 + *
45 + * async.forever(
46 + * function(next) {
47 + * // next is suitable for passing to things that need a callback(err [, whatever]);
48 + * // it will result in this function being called again.
49 + * },
50 + * function(err) {
51 + * // if next is called with a value in its first parameter, it will appear
52 + * // in here as 'err', and execution will stop.
53 + * }
54 + * );
55 + */
56 +function forever(fn, errback) {
57 + var done = (0, _onlyOnce2.default)(errback);
58 + var task = (0, _wrapAsync2.default)((0, _ensureAsync2.default)(fn));
59 +
60 + function next(err) {
61 + if (err) return done(err);
62 + if (err === false) return;
63 + task(next);
64 + }
65 + return next();
66 +}
67 +exports.default = (0, _awaitify2.default)(forever, 2);
68 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = groupBy;
7 +
8 +var _groupByLimit = require('./groupByLimit');
9 +
10 +var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Returns a new object, where each value corresponds to an array of items, from
16 + * `coll`, that returned the corresponding key. That is, the keys of the object
17 + * correspond to the values passed to the `iteratee` callback.
18 + *
19 + * Note: Since this function applies the `iteratee` to each item in parallel,
20 + * there is no guarantee that the `iteratee` functions will complete in order.
21 + * However, the values for each key in the `result` will be in the same order as
22 + * the original `coll`. For Objects, the values will roughly be in the order of
23 + * the original Objects' keys (but this can vary across JavaScript engines).
24 + *
25 + * @name groupBy
26 + * @static
27 + * @memberOf module:Collections
28 + * @method
29 + * @category Collection
30 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
32 + * `coll`.
33 + * The iteratee should complete with a `key` to group the value under.
34 + * Invoked with (value, callback).
35 + * @param {Function} [callback] - A callback which is called when all `iteratee`
36 + * functions have finished, or an error occurs. Result is an `Object` whoses
37 + * properties are arrays of values which returned the corresponding key.
38 + * @returns {Promise} a promise, if no callback is passed
39 + * @example
40 + *
41 + * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
42 + * db.findById(userId, function(err, user) {
43 + * if (err) return callback(err);
44 + * return callback(null, user.age);
45 + * });
46 + * }, function(err, result) {
47 + * // result is object containing the userIds grouped by age
48 + * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
49 + * });
50 + */
51 +function groupBy(coll, iteratee, callback) {
52 + return (0, _groupByLimit2.default)(coll, Infinity, iteratee, callback);
53 +}
54 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _mapLimit = require('./mapLimit');
8 +
9 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
10 +
11 +var _wrapAsync = require('./internal/wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./internal/awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +/**
22 + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
23 + *
24 + * @name groupByLimit
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @see [async.groupBy]{@link module:Collections.groupBy}
29 + * @category Collection
30 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
31 + * @param {number} limit - The maximum number of async operations at a time.
32 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
33 + * `coll`.
34 + * The iteratee should complete with a `key` to group the value under.
35 + * Invoked with (value, callback).
36 + * @param {Function} [callback] - A callback which is called when all `iteratee`
37 + * functions have finished, or an error occurs. Result is an `Object` whoses
38 + * properties are arrays of values which returned the corresponding key.
39 + * @returns {Promise} a promise, if no callback is passed
40 + */
41 +function groupByLimit(coll, limit, iteratee, callback) {
42 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
43 + return (0, _mapLimit2.default)(coll, limit, (val, iterCb) => {
44 + _iteratee(val, (err, key) => {
45 + if (err) return iterCb(err);
46 + return iterCb(err, { key, val });
47 + });
48 + }, (err, mapResults) => {
49 + var result = {};
50 + // from MDN, handle object having an `hasOwnProperty` prop
51 + var { hasOwnProperty } = Object.prototype;
52 +
53 + for (var i = 0; i < mapResults.length; i++) {
54 + if (mapResults[i]) {
55 + var { key } = mapResults[i];
56 + var { val } = mapResults[i];
57 +
58 + if (hasOwnProperty.call(result, key)) {
59 + result[key].push(val);
60 + } else {
61 + result[key] = [val];
62 + }
63 + }
64 + }
65 +
66 + return callback(err, result);
67 + });
68 +}
69 +
70 +exports.default = (0, _awaitify2.default)(groupByLimit, 4);
71 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = groupBySeries;
7 +
8 +var _groupByLimit = require('./groupByLimit');
9 +
10 +var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
16 + *
17 + * @name groupBySeries
18 + * @static
19 + * @memberOf module:Collections
20 + * @method
21 + * @see [async.groupBy]{@link module:Collections.groupBy}
22 + * @category Collection
23 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
24 + * @param {AsyncFunction} iteratee - An async function to apply to each item in
25 + * `coll`.
26 + * The iteratee should complete with a `key` to group the value under.
27 + * Invoked with (value, callback).
28 + * @param {Function} [callback] - A callback which is called when all `iteratee`
29 + * functions have finished, or an error occurs. Result is an `Object` whoses
30 + * properties are arrays of values which returned the corresponding key.
31 + * @returns {Promise} a promise, if no callback is passed
32 + */
33 +function groupBySeries(coll, iteratee, callback) {
34 + return (0, _groupByLimit2.default)(coll, 1, iteratee, callback);
35 +}
36 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _eachOfSeries = require('./eachOfSeries');
8 +
9 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
10 +
11 +var _once = require('./internal/once');
12 +
13 +var _once2 = _interopRequireDefault(_once);
14 +
15 +var _wrapAsync = require('./internal/wrapAsync');
16 +
17 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
18 +
19 +var _awaitify = require('./internal/awaitify');
20 +
21 +var _awaitify2 = _interopRequireDefault(_awaitify);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Reduces `coll` into a single value using an async `iteratee` to return each
27 + * successive step. `memo` is the initial state of the reduction. This function
28 + * only operates in series.
29 + *
30 + * For performance reasons, it may make sense to split a call to this function
31 + * into a parallel map, and then use the normal `Array.prototype.reduce` on the
32 + * results. This function is for situations where each step in the reduction
33 + * needs to be async; if you can get the data before reducing it, then it's
34 + * probably a good idea to do so.
35 + *
36 + * @name reduce
37 + * @static
38 + * @memberOf module:Collections
39 + * @method
40 + * @alias inject
41 + * @alias foldl
42 + * @category Collection
43 + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
44 + * @param {*} memo - The initial state of the reduction.
45 + * @param {AsyncFunction} iteratee - A function applied to each item in the
46 + * array to produce the next step in the reduction.
47 + * The `iteratee` should complete with the next state of the reduction.
48 + * If the iteratee complete with an error, the reduction is stopped and the
49 + * main `callback` is immediately called with the error.
50 + * Invoked with (memo, item, callback).
51 + * @param {Function} [callback] - A callback which is called after all the
52 + * `iteratee` functions have finished. Result is the reduced value. Invoked with
53 + * (err, result).
54 + * @returns {Promise} a promise, if no callback is passed
55 + * @example
56 + *
57 + * async.reduce([1,2,3], 0, function(memo, item, callback) {
58 + * // pointless async:
59 + * process.nextTick(function() {
60 + * callback(null, memo + item)
61 + * });
62 + * }, function(err, result) {
63 + * // result is now equal to the last value of memo, which is 6
64 + * });
65 + */
66 +function reduce(coll, memo, iteratee, callback) {
67 + callback = (0, _once2.default)(callback);
68 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
69 + return (0, _eachOfSeries2.default)(coll, (x, i, iterCb) => {
70 + _iteratee(memo, x, (err, v) => {
71 + memo = v;
72 + iterCb(err);
73 + });
74 + }, err => callback(err, memo));
75 +}
76 +exports.default = (0, _awaitify2.default)(reduce, 4);
77 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
7 +// used for queues. This implementation assumes that the node provided by the user can be modified
8 +// to adjust the next and last properties. We implement only the minimal functionality
9 +// for queue support.
10 +class DLL {
11 + constructor() {
12 + this.head = this.tail = null;
13 + this.length = 0;
14 + }
15 +
16 + removeLink(node) {
17 + if (node.prev) node.prev.next = node.next;else this.head = node.next;
18 + if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
19 +
20 + node.prev = node.next = null;
21 + this.length -= 1;
22 + return node;
23 + }
24 +
25 + empty() {
26 + while (this.head) this.shift();
27 + return this;
28 + }
29 +
30 + insertAfter(node, newNode) {
31 + newNode.prev = node;
32 + newNode.next = node.next;
33 + if (node.next) node.next.prev = newNode;else this.tail = newNode;
34 + node.next = newNode;
35 + this.length += 1;
36 + }
37 +
38 + insertBefore(node, newNode) {
39 + newNode.prev = node.prev;
40 + newNode.next = node;
41 + if (node.prev) node.prev.next = newNode;else this.head = newNode;
42 + node.prev = newNode;
43 + this.length += 1;
44 + }
45 +
46 + unshift(node) {
47 + if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
48 + }
49 +
50 + push(node) {
51 + if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
52 + }
53 +
54 + shift() {
55 + return this.head && this.removeLink(this.head);
56 + }
57 +
58 + pop() {
59 + return this.tail && this.removeLink(this.tail);
60 + }
61 +
62 + toArray() {
63 + return [...this];
64 + }
65 +
66 + *[Symbol.iterator]() {
67 + var cur = this.head;
68 + while (cur) {
69 + yield cur.data;
70 + cur = cur.next;
71 + }
72 + }
73 +
74 + remove(testFn) {
75 + var curr = this.head;
76 + while (curr) {
77 + var { next } = curr;
78 + if (testFn(curr)) {
79 + this.removeLink(curr);
80 + }
81 + curr = next;
82 + }
83 + return this;
84 + }
85 +}
86 +
87 +exports.default = DLL;
88 +function setInitial(dll, node) {
89 + dll.length = 1;
90 + dll.head = dll.tail = node;
91 +}
92 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +// Binary min-heap implementation used for priority queue.
7 +// Implementation is stable, i.e. push time is considered for equal priorities
8 +class Heap {
9 + constructor() {
10 + this.heap = [];
11 + this.pushCount = Number.MIN_SAFE_INTEGER;
12 + }
13 +
14 + get length() {
15 + return this.heap.length;
16 + }
17 +
18 + empty() {
19 + this.heap = [];
20 + return this;
21 + }
22 +
23 + percUp(index) {
24 + let p;
25 +
26 + while (index > 0 && smaller(this.heap[index], this.heap[p = parent(index)])) {
27 + let t = this.heap[index];
28 + this.heap[index] = this.heap[p];
29 + this.heap[p] = t;
30 +
31 + index = p;
32 + }
33 + }
34 +
35 + percDown(index) {
36 + let l;
37 +
38 + while ((l = leftChi(index)) < this.heap.length) {
39 + if (l + 1 < this.heap.length && smaller(this.heap[l + 1], this.heap[l])) {
40 + l = l + 1;
41 + }
42 +
43 + if (smaller(this.heap[index], this.heap[l])) {
44 + break;
45 + }
46 +
47 + let t = this.heap[index];
48 + this.heap[index] = this.heap[l];
49 + this.heap[l] = t;
50 +
51 + index = l;
52 + }
53 + }
54 +
55 + push(node) {
56 + node.pushCount = ++this.pushCount;
57 + this.heap.push(node);
58 + this.percUp(this.heap.length - 1);
59 + }
60 +
61 + unshift(node) {
62 + return this.heap.push(node);
63 + }
64 +
65 + shift() {
66 + let [top] = this.heap;
67 +
68 + this.heap[0] = this.heap[this.heap.length - 1];
69 + this.heap.pop();
70 + this.percDown(0);
71 +
72 + return top;
73 + }
74 +
75 + toArray() {
76 + return [...this];
77 + }
78 +
79 + *[Symbol.iterator]() {
80 + for (let i = 0; i < this.heap.length; i++) {
81 + yield this.heap[i].data;
82 + }
83 + }
84 +
85 + remove(testFn) {
86 + let j = 0;
87 + for (let i = 0; i < this.heap.length; i++) {
88 + if (!testFn(this.heap[i])) {
89 + this.heap[j] = this.heap[i];
90 + j++;
91 + }
92 + }
93 +
94 + this.heap.splice(j);
95 +
96 + for (let i = parent(this.heap.length - 1); i >= 0; i--) {
97 + this.percDown(i);
98 + }
99 +
100 + return this;
101 + }
102 +}
103 +
104 +exports.default = Heap;
105 +function leftChi(i) {
106 + return (i << 1) + 1;
107 +}
108 +
109 +function parent(i) {
110 + return (i + 1 >> 1) - 1;
111 +}
112 +
113 +function smaller(x, y) {
114 + if (x.priority !== y.priority) {
115 + return x.priority < y.priority;
116 + } else {
117 + return x.pushCount < y.pushCount;
118 + }
119 +}
120 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (eachfn) {
8 + return function applyEach(fns, ...callArgs) {
9 + const go = (0, _awaitify2.default)(function (callback) {
10 + var that = this;
11 + return eachfn(fns, (fn, cb) => {
12 + (0, _wrapAsync2.default)(fn).apply(that, callArgs.concat(cb));
13 + }, callback);
14 + });
15 + return go;
16 + };
17 +};
18 +
19 +var _wrapAsync = require('./wrapAsync');
20 +
21 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
22 +
23 +var _awaitify = require('./awaitify');
24 +
25 +var _awaitify2 = _interopRequireDefault(_awaitify);
26 +
27 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28 +
29 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = asyncEachOfLimit;
7 +
8 +var _breakLoop = require('./breakLoop');
9 +
10 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +// for async generators
15 +function asyncEachOfLimit(generator, limit, iteratee, callback) {
16 + let done = false;
17 + let canceled = false;
18 + let awaiting = false;
19 + let running = 0;
20 + let idx = 0;
21 +
22 + function replenish() {
23 + //console.log('replenish')
24 + if (running >= limit || awaiting || done) return;
25 + //console.log('replenish awaiting')
26 + awaiting = true;
27 + generator.next().then(({ value, done: iterDone }) => {
28 + //console.log('got value', value)
29 + if (canceled || done) return;
30 + awaiting = false;
31 + if (iterDone) {
32 + done = true;
33 + if (running <= 0) {
34 + //console.log('done nextCb')
35 + callback(null);
36 + }
37 + return;
38 + }
39 + running++;
40 + iteratee(value, idx, iterateeCallback);
41 + idx++;
42 + replenish();
43 + }).catch(handleError);
44 + }
45 +
46 + function iterateeCallback(err, result) {
47 + //console.log('iterateeCallback')
48 + running -= 1;
49 + if (canceled) return;
50 + if (err) return handleError(err);
51 +
52 + if (err === false) {
53 + done = true;
54 + canceled = true;
55 + return;
56 + }
57 +
58 + if (result === _breakLoop2.default || done && running <= 0) {
59 + done = true;
60 + //console.log('done iterCb')
61 + return callback(null);
62 + }
63 + replenish();
64 + }
65 +
66 + function handleError(err) {
67 + if (canceled) return;
68 + awaiting = false;
69 + done = true;
70 + callback(err);
71 + }
72 +
73 + replenish();
74 +}
75 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = awaitify;
7 +// conditionally promisify a function.
8 +// only return a promise if a callback is omitted
9 +function awaitify(asyncFn, arity = asyncFn.length) {
10 + if (!arity) throw new Error('arity is undefined');
11 + function awaitable(...args) {
12 + if (typeof args[arity - 1] === 'function') {
13 + return asyncFn.apply(this, args);
14 + }
15 +
16 + return new Promise((resolve, reject) => {
17 + args[arity - 1] = (err, ...cbArgs) => {
18 + if (err) return reject(err);
19 + resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]);
20 + };
21 + asyncFn.apply(this, args);
22 + });
23 + }
24 +
25 + Object.defineProperty(awaitable, 'name', {
26 + value: `awaitable(${asyncFn.name})`
27 + });
28 +
29 + return awaitable;
30 +}
31 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +// A temporary value used to identify if the loop should be broken.
7 +// See #1064, #1293
8 +const breakLoop = {};
9 +exports.default = breakLoop;
10 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = consoleFunc;
7 +
8 +var _wrapAsync = require('./wrapAsync');
9 +
10 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function consoleFunc(name) {
15 + return (fn, ...args) => (0, _wrapAsync2.default)(fn)(...args, (err, ...resultArgs) => {
16 + if (typeof console === 'object') {
17 + if (err) {
18 + if (console.error) {
19 + console.error(err);
20 + }
21 + } else if (console[name]) {
22 + resultArgs.forEach(x => console[name](x));
23 + }
24 + }
25 + });
26 +}
27 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = _createTester;
7 +
8 +var _breakLoop = require('./breakLoop');
9 +
10 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
11 +
12 +var _wrapAsync = require('./wrapAsync');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function _createTester(check, getResult) {
19 + return (eachfn, arr, _iteratee, cb) => {
20 + var testPassed = false;
21 + var testResult;
22 + const iteratee = (0, _wrapAsync2.default)(_iteratee);
23 + eachfn(arr, (value, _, callback) => {
24 + iteratee(value, (err, result) => {
25 + if (err || err === false) return callback(err);
26 +
27 + if (check(result) && !testResult) {
28 + testPassed = true;
29 + testResult = getResult(true, value);
30 + return callback(null, _breakLoop2.default);
31 + }
32 + callback();
33 + });
34 + }, err => {
35 + if (err) return cb(err);
36 + cb(null, testPassed ? testResult : getResult(false));
37 + });
38 + };
39 +}
40 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _once = require('./once');
8 +
9 +var _once2 = _interopRequireDefault(_once);
10 +
11 +var _iterator = require('./iterator');
12 +
13 +var _iterator2 = _interopRequireDefault(_iterator);
14 +
15 +var _onlyOnce = require('./onlyOnce');
16 +
17 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
18 +
19 +var _wrapAsync = require('./wrapAsync');
20 +
21 +var _asyncEachOfLimit = require('./asyncEachOfLimit');
22 +
23 +var _asyncEachOfLimit2 = _interopRequireDefault(_asyncEachOfLimit);
24 +
25 +var _breakLoop = require('./breakLoop');
26 +
27 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
28 +
29 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30 +
31 +exports.default = limit => {
32 + return (obj, iteratee, callback) => {
33 + callback = (0, _once2.default)(callback);
34 + if (limit <= 0) {
35 + throw new RangeError('concurrency limit cannot be less than 1');
36 + }
37 + if (!obj) {
38 + return callback(null);
39 + }
40 + if ((0, _wrapAsync.isAsyncGenerator)(obj)) {
41 + return (0, _asyncEachOfLimit2.default)(obj, limit, iteratee, callback);
42 + }
43 + if ((0, _wrapAsync.isAsyncIterable)(obj)) {
44 + return (0, _asyncEachOfLimit2.default)(obj[Symbol.asyncIterator](), limit, iteratee, callback);
45 + }
46 + var nextElem = (0, _iterator2.default)(obj);
47 + var done = false;
48 + var canceled = false;
49 + var running = 0;
50 + var looping = false;
51 +
52 + function iterateeCallback(err, value) {
53 + if (canceled) return;
54 + running -= 1;
55 + if (err) {
56 + done = true;
57 + callback(err);
58 + } else if (err === false) {
59 + done = true;
60 + canceled = true;
61 + } else if (value === _breakLoop2.default || done && running <= 0) {
62 + done = true;
63 + return callback(null);
64 + } else if (!looping) {
65 + replenish();
66 + }
67 + }
68 +
69 + function replenish() {
70 + looping = true;
71 + while (running < limit && !done) {
72 + var elem = nextElem();
73 + if (elem === null) {
74 + done = true;
75 + if (running <= 0) {
76 + callback(null);
77 + }
78 + return;
79 + }
80 + running += 1;
81 + iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
82 + }
83 + looping = false;
84 + }
85 +
86 + replenish();
87 + };
88 +};
89 +
90 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = _filter;
7 +
8 +var _isArrayLike = require('./isArrayLike');
9 +
10 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
11 +
12 +var _wrapAsync = require('./wrapAsync');
13 +
14 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function filterArray(eachfn, arr, iteratee, callback) {
19 + var truthValues = new Array(arr.length);
20 + eachfn(arr, (x, index, iterCb) => {
21 + iteratee(x, (err, v) => {
22 + truthValues[index] = !!v;
23 + iterCb(err);
24 + });
25 + }, err => {
26 + if (err) return callback(err);
27 + var results = [];
28 + for (var i = 0; i < arr.length; i++) {
29 + if (truthValues[i]) results.push(arr[i]);
30 + }
31 + callback(null, results);
32 + });
33 +}
34 +
35 +function filterGeneric(eachfn, coll, iteratee, callback) {
36 + var results = [];
37 + eachfn(coll, (x, index, iterCb) => {
38 + iteratee(x, (err, v) => {
39 + if (err) return iterCb(err);
40 + if (v) {
41 + results.push({ index, value: x });
42 + }
43 + iterCb(err);
44 + });
45 + }, err => {
46 + if (err) return callback(err);
47 + callback(null, results.sort((a, b) => a.index - b.index).map(v => v.value));
48 + });
49 +}
50 +
51 +function _filter(eachfn, coll, iteratee, callback) {
52 + var filter = (0, _isArrayLike2.default)(coll) ? filterArray : filterGeneric;
53 + return filter(eachfn, coll, (0, _wrapAsync2.default)(iteratee), callback);
54 +}
55 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (coll) {
8 + return coll[Symbol.iterator] && coll[Symbol.iterator]();
9 +};
10 +
11 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +exports.default = function (fn) {
8 + return function (...args /*, callback*/) {
9 + var callback = args.pop();
10 + return fn.call(this, args, callback);
11 + };
12 +};
13 +
14 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = isArrayLike;
7 +function isArrayLike(value) {
8 + return value && typeof value.length === 'number' && value.length >= 0 && value.length % 1 === 0;
9 +}
10 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = createIterator;
7 +
8 +var _isArrayLike = require('./isArrayLike');
9 +
10 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
11 +
12 +var _getIterator = require('./getIterator');
13 +
14 +var _getIterator2 = _interopRequireDefault(_getIterator);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function createArrayIterator(coll) {
19 + var i = -1;
20 + var len = coll.length;
21 + return function next() {
22 + return ++i < len ? { value: coll[i], key: i } : null;
23 + };
24 +}
25 +
26 +function createES2015Iterator(iterator) {
27 + var i = -1;
28 + return function next() {
29 + var item = iterator.next();
30 + if (item.done) return null;
31 + i++;
32 + return { value: item.value, key: i };
33 + };
34 +}
35 +
36 +function createObjectIterator(obj) {
37 + var okeys = obj ? Object.keys(obj) : [];
38 + var i = -1;
39 + var len = okeys.length;
40 + return function next() {
41 + var key = okeys[++i];
42 + return i < len ? { value: obj[key], key } : null;
43 + };
44 +}
45 +
46 +function createIterator(coll) {
47 + if ((0, _isArrayLike2.default)(coll)) {
48 + return createArrayIterator(coll);
49 + }
50 +
51 + var iterator = (0, _getIterator2.default)(coll);
52 + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
53 +}
54 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = _asyncMap;
7 +
8 +var _wrapAsync = require('./wrapAsync');
9 +
10 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function _asyncMap(eachfn, arr, iteratee, callback) {
15 + arr = arr || [];
16 + var results = [];
17 + var counter = 0;
18 + var _iteratee = (0, _wrapAsync2.default)(iteratee);
19 +
20 + return eachfn(arr, (value, _, iterCb) => {
21 + var index = counter++;
22 + _iteratee(value, (err, v) => {
23 + results[index] = v;
24 + iterCb(err);
25 + });
26 + }, err => {
27 + callback(err, results);
28 + });
29 +}
30 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = once;
7 +function once(fn) {
8 + function wrapper(...args) {
9 + if (fn === null) return;
10 + var callFn = fn;
11 + fn = null;
12 + callFn.apply(this, args);
13 + }
14 + Object.assign(wrapper, fn);
15 + return wrapper;
16 +}
17 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = onlyOnce;
7 +function onlyOnce(fn) {
8 + return function (...args) {
9 + if (fn === null) throw new Error("Callback was already called.");
10 + var callFn = fn;
11 + fn = null;
12 + callFn.apply(this, args);
13 + };
14 +}
15 +module.exports = exports["default"];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _isArrayLike = require('./isArrayLike');
8 +
9 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
10 +
11 +var _wrapAsync = require('./wrapAsync');
12 +
13 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
14 +
15 +var _awaitify = require('./awaitify');
16 +
17 +var _awaitify2 = _interopRequireDefault(_awaitify);
18 +
19 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20 +
21 +exports.default = (0, _awaitify2.default)((eachfn, tasks, callback) => {
22 + var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
23 +
24 + eachfn(tasks, (task, key, taskCb) => {
25 + (0, _wrapAsync2.default)(task)((err, ...result) => {
26 + if (result.length < 2) {
27 + [result] = result;
28 + }
29 + results[key] = result;
30 + taskCb(err);
31 + });
32 + }, err => callback(err, results));
33 +}, 3);
34 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +const PROMISE_SYMBOL = Symbol('promiseCallback');
7 +
8 +function promiseCallback() {
9 + let resolve, reject;
10 + function callback(err, ...args) {
11 + if (err) return reject(err);
12 + resolve(args.length > 1 ? args : args[0]);
13 + }
14 +
15 + callback[PROMISE_SYMBOL] = new Promise((res, rej) => {
16 + resolve = res, reject = rej;
17 + });
18 +
19 + return callback;
20 +}
21 +
22 +exports.promiseCallback = promiseCallback;
23 +exports.PROMISE_SYMBOL = PROMISE_SYMBOL;
...\ No newline at end of file ...\ No newline at end of file
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = queue;
7 +
8 +var _onlyOnce = require('./onlyOnce');
9 +
10 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
11 +
12 +var _setImmediate = require('./setImmediate');
13 +
14 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
15 +
16 +var _DoublyLinkedList = require('./DoublyLinkedList');
17 +
18 +var _DoublyLinkedList2 = _interopRequireDefault(_DoublyLinkedList);
19 +
20 +var _wrapAsync = require('./wrapAsync');
21 +
22 +var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +function queue(worker, concurrency, payload) {
27 + if (concurrency == null) {
28 + concurrency = 1;
29 + } else if (concurrency === 0) {
30 + throw new RangeError('Concurrency must not be zero');
31 + }
32 +
33 + var _worker = (0, _wrapAsync2.default)(worker);
34 + var numRunning = 0;
35 + var workersList = [];
36 + const events = {
37 + error: [],
38 + drain: [],
39 + saturated: [],
40 + unsaturated: [],
41 + empty: []
42 + };
43 +
44 + function on(event, handler) {
45 + events[event].push(handler);
46 + }
47 +
48 + function once(event, handler) {
49 + const handleAndRemove = (...args) => {
50 + off(event, handleAndRemove);
51 + handler(...args);
52 + };
53 + events[event].push(handleAndRemove);
54 + }
55 +
56 + function off(event, handler) {
57 + if (!event) return Object.keys(events).forEach(ev => events[ev] = []);
58 + if (!handler) return events[event] = [];
59 + events[event] = events[event].filter(ev => ev !== handler);
60 + }
61 +
62 + function trigger(event, ...args) {
63 + events[event].forEach(handler => handler(...args));
64 + }
65 +
66 + var processingScheduled = false;
67 + function _insert(data, insertAtFront, rejectOnError, callback) {
68 + if (callback != null && typeof callback !== 'function') {
69 + throw new Error('task callback must be a function');
70 + }
71 + q.started = true;
72 +
73 + var res, rej;
74 + function promiseCallback(err, ...args) {
75 + // we don't care about the error, let the global error handler
76 + // deal with it
77 + if (err) return rejectOnError ? rej(err) : res();
78 + if (args.length <= 1) return res(args[0]);
79 + res(args);
80 + }
81 +
82 + var item = {
83 + data,
84 + callback: rejectOnError ? promiseCallback : callback || promiseCallback
85 + };
86 +
87 + if (insertAtFront) {
88 + q._tasks.unshift(item);
89 + } else {
90 + q._tasks.push(item);
91 + }
92 +
93 + if (!processingScheduled) {
94 + processingScheduled = true;
95 + (0, _setImmediate2.default)(() => {
96 + processingScheduled = false;
97 + q.process();
98 + });
99 + }
100 +
101 + if (rejectOnError || !callback) {
102 + return new Promise((resolve, reject) => {
103 + res = resolve;
104 + rej = reject;
105 + });
106 + }
107 + }
108 +
109 + function _createCB(tasks) {
110 + return function (err, ...args) {
111 + numRunning -= 1;
112 +
113 + for (var i = 0, l = tasks.length; i < l; i++) {
114 + var task = tasks[i];
115 +
116 + var index = workersList.indexOf(task);
117 + if (index === 0) {
118 + workersList.shift();
119 + } else if (index > 0) {
120 + workersList.splice(index, 1);
121 + }
122 +
123 + task.callback(err, ...args);
124 +
125 + if (err != null) {
126 + trigger('error', err, task.data);
127 + }
128 + }
129 +
130 + if (numRunning <= q.concurrency - q.buffer) {
131 + trigger('unsaturated');
132 + }
133 +
134 + if (q.idle()) {
135 + trigger('drain');
136 + }
137 + q.process();
138 + };
139 + }
140 +
141 + function _maybeDrain(data) {
142 + if (data.length === 0 && q.idle()) {
143 + // call drain immediately if there are no tasks
144 + (0, _setImmediate2.default)(() => trigger('drain'));
145 + return true;
146 + }
147 + return false;
148 + }
149 +
150 + const eventMethod = name => handler => {
151 + if (!handler) {
152 + return new Promise((resolve, reject) => {
153 + once(name, (err, data) => {
154 + if (err) return reject(err);
155 + resolve(data);
156 + });
157 + });
158 + }
159 + off(name);
160 + on(name, handler);
161 + };
162 +
163 + var isProcessing = false;
164 + var q = {
165 + _tasks: new _DoublyLinkedList2.default(),
166 + *[Symbol.iterator]() {
167 + yield* q._tasks[Symbol.iterator]();
168 + },
169 + concurrency,
170 + payload,
171 + buffer: concurrency / 4,
172 + started: false,
173 + paused: false,
174 + push(data, callback) {
175 + if (Array.isArray(data)) {
176 + if (_maybeDrain(data)) return;
177 + return data.map(datum => _insert(datum, false, false, callback));
178 + }
179 + return _insert(data, false, false, callback);
180 + },
181 + pushAsync(data, callback) {
182 + if (Array.isArray(data)) {
183 + if (_maybeDrain(data)) return;
184 + return data.map(datum => _insert(datum, false, true, callback));
185 + }
186 + return _insert(data, false, true, callback);
187 + },
188 + kill() {
189 + off();
190 + q._tasks.empty();
191 + },
192 + unshift(data, callback) {
193 + if (Array.isArray(data)) {
194 + if (_maybeDrain(data)) return;
195 + return data.map(datum => _insert(datum, true, false, callback));
196 + }
197 + return _insert(data, true, false, callback);
198 + },
199 + unshiftAsync(data, callback) {
200 + if (Array.isArray(data)) {
201 + if (_maybeDrain(data)) return;
202 + return data.map(datum => _insert(datum, true, true, callback));
203 + }
204 + return _insert(data, true, true, callback);
205 + },
206 + remove(testFn) {
207 + q._tasks.remove(testFn);
208 + },
209 + process() {
210 + // Avoid trying to start too many processing operations. This can occur
211 + // when callbacks resolve synchronously (#1267).
212 + if (isProcessing) {
213 + return;
214 + }
215 + isProcessing = true;
216 + while (!q.paused && numRunning < q.concurrency && q._tasks.length) {
217 + var tasks = [],
218 + data = [];
219 + var l = q._tasks.length;
220 + if (q.payload) l = Math.min(l, q.payload);
221 + for (var i = 0; i < l; i++) {
222 + var node = q._tasks.shift();
223 + tasks.push(node);
224 + workersList.push(node);
225 + data.push(node.data);
226 + }
227 +
228 + numRunning += 1;
229 +
230 + if (q._tasks.length === 0) {
231 + trigger('empty');
232 + }
233 +
234 + if (numRunning === q.concurrency) {
235 + trigger('saturated');
236 + }
237 +
238 + var cb = (0, _onlyOnce2.default)(_createCB(tasks));
239 + _worker(data, cb);
240 + }
241 + isProcessing = false;
242 + },
243 + length() {
244 + return q._tasks.length;
245 + },
246 + running() {
247 + return numRunning;
248 + },
249 + workersList() {
250 + return workersList;
251 + },
252 + idle() {
253 + return q._tasks.length + numRunning === 0;
254 + },
255 + pause() {
256 + q.paused = true;
257 + },
258 + resume() {
259 + if (q.paused === false) {
260 + return;
261 + }
262 + q.paused = false;
263 + (0, _setImmediate2.default)(q.process);
264 + }
265 + };
266 + // define these as fixed properties, so people get useful errors when updating
267 + Object.defineProperties(q, {
268 + saturated: {
269 + writable: false,
270 + value: eventMethod('saturated')
271 + },
272 + unsaturated: {
273 + writable: false,
274 + value: eventMethod('unsaturated')
275 + },
276 + empty: {
277 + writable: false,
278 + value: eventMethod('empty')
279 + },
280 + drain: {
281 + writable: false,
282 + value: eventMethod('drain')
283 + },
284 + error: {
285 + writable: false,
286 + value: eventMethod('error')
287 + }
288 + });
289 + return q;
290 +}
291 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.