I_Jemin

Package Dependencies

Showing 1000 changed files with 4698 additions and 0 deletions

Too many changes to show.

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

1 +../semver/bin/semver
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2010-2016 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 +[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
5 +[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
6 +[![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)
7 +
8 +Async is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript. Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
9 +
10 +For Documentation, visit <http://caolan.github.io/async/>
11 +
12 +*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +
7 +var _rest = require('./internal/rest');
8 +
9 +var _rest2 = _interopRequireDefault(_rest);
10 +
11 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12 +
13 +/**
14 + * Creates a continuation function with some arguments already applied.
15 + *
16 + * Useful as a shorthand when combined with other control flow functions. Any
17 + * arguments passed to the returned function are added to the arguments
18 + * originally passed to apply.
19 + *
20 + * @name apply
21 + * @static
22 + * @memberOf module:Utils
23 + * @method
24 + * @category Util
25 + * @param {Function} function - The function you want to eventually apply all
26 + * arguments to. Invokes with (arguments...).
27 + * @param {...*} arguments... - Any number of arguments to automatically apply
28 + * when the continuation is called.
29 + * @example
30 + *
31 + * // using apply
32 + * async.parallel([
33 + * async.apply(fs.writeFile, 'testfile1', 'test1'),
34 + * async.apply(fs.writeFile, 'testfile2', 'test2')
35 + * ]);
36 + *
37 + *
38 + * // the same process without using apply
39 + * async.parallel([
40 + * function(callback) {
41 + * fs.writeFile('testfile1', 'test1', callback);
42 + * },
43 + * function(callback) {
44 + * fs.writeFile('testfile2', 'test2', callback);
45 + * }
46 + * ]);
47 + *
48 + * // It's possible to pass any number of additional arguments when calling the
49 + * // continuation:
50 + *
51 + * node> var fn = async.apply(sys.puts, 'one');
52 + * node> fn('two', 'three');
53 + * one
54 + * two
55 + * three
56 + */
57 +exports.default = (0, _rest2.default)(function (fn, args) {
58 + return (0, _rest2.default)(function (callArgs) {
59 + return fn.apply(null, args.concat(callArgs));
60 + });
61 +});
62 +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 _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.
23 + *
24 + * @name applyEach
25 + * @static
26 + * @memberOf module:ControlFlow
27 + * @method
28 + * @category Control Flow
29 + * @param {Array|Iterable|Object} fns - A collection of asynchronous functions
30 + * to all call with the same arguments
31 + * @param {...*} [args] - any number of separate arguments to pass to the
32 + * function.
33 + * @param {Function} [callback] - the final argument should be the callback,
34 + * called when all functions have completed processing.
35 + * @returns {Function} - If only the first argument, `fns`, is provided, it will
36 + * return a function which lets you pass in the arguments as if it were a single
37 + * function call. The signature is `(..args, callback)`. If invoked with any
38 + * arguments, `callback` is required.
39 + * @example
40 + *
41 + * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
42 + *
43 + * // partial application example:
44 + * async.each(
45 + * buckets,
46 + * async.applyEach([enableSearch, updateSchema]),
47 + * callback
48 + * );
49 + */
50 +exports.default = (0, _applyEach2.default)(_map2.default);
51 +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|Object} fns - A collection of asynchronous functions 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 {Function} - If only the first argument is provided, it will return
33 + * a function which lets you pass in the arguments as if it were a single
34 + * function call.
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 _isObject = require('lodash/isObject');
9 +
10 +var _isObject2 = _interopRequireDefault(_isObject);
11 +
12 +var _initialParams = require('./internal/initialParams');
13 +
14 +var _initialParams2 = _interopRequireDefault(_initialParams);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Take a sync function and make it async, passing its return value to a
20 + * callback. This is useful for plugging sync functions into a waterfall,
21 + * series, or other async functions. Any arguments passed to the generated
22 + * function will be passed to the wrapped function (except for the final
23 + * callback argument). Errors thrown will be passed to the callback.
24 + *
25 + * If the function passed to `asyncify` returns a Promise, that promises's
26 + * resolved/rejected state will be used to call the callback, rather than simply
27 + * the synchronous return value.
28 + *
29 + * This also means you can asyncify ES2016 `async` functions.
30 + *
31 + * @name asyncify
32 + * @static
33 + * @memberOf module:Utils
34 + * @method
35 + * @alias wrapSync
36 + * @category Util
37 + * @param {Function} func - The synchronous function to convert to an
38 + * asynchronous function.
39 + * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with
40 + * (callback).
41 + * @example
42 + *
43 + * // passing a regular synchronous function
44 + * async.waterfall([
45 + * async.apply(fs.readFile, filename, "utf8"),
46 + * async.asyncify(JSON.parse),
47 + * function (data, next) {
48 + * // data is the result of parsing the text.
49 + * // If there was a parsing error, it would have been caught.
50 + * }
51 + * ], callback);
52 + *
53 + * // passing a function returning a promise
54 + * async.waterfall([
55 + * async.apply(fs.readFile, filename, "utf8"),
56 + * async.asyncify(function (contents) {
57 + * return db.model.create(contents);
58 + * }),
59 + * function (model, next) {
60 + * // `model` is the instantiated model object.
61 + * // If there was an error, this function would be skipped.
62 + * }
63 + * ], callback);
64 + *
65 + * // es6 example
66 + * var q = async.queue(async.asyncify(async function(file) {
67 + * var intermediateStep = await processFile(file);
68 + * return await somePromise(intermediateStep)
69 + * }));
70 + *
71 + * q.push(files);
72 + */
73 +function asyncify(func) {
74 + return (0, _initialParams2.default)(function (args, callback) {
75 + var result;
76 + try {
77 + result = func.apply(this, args);
78 + } catch (e) {
79 + return callback(e);
80 + }
81 + // if result is Promise object
82 + if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
83 + result.then(function (value) {
84 + callback(null, value);
85 + }, function (err) {
86 + callback(err.message ? err : new Error(err));
87 + });
88 + } else {
89 + callback(null, result);
90 + }
91 + });
92 +}
93 +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 (tasks, concurrency, callback) {
8 + if (typeof concurrency === 'function') {
9 + // concurrency is optional, shift the args.
10 + callback = concurrency;
11 + concurrency = null;
12 + }
13 + callback = (0, _once2.default)(callback || _noop2.default);
14 + var keys = (0, _keys2.default)(tasks);
15 + var numTasks = keys.length;
16 + if (!numTasks) {
17 + return callback(null);
18 + }
19 + if (!concurrency) {
20 + concurrency = numTasks;
21 + }
22 +
23 + var results = {};
24 + var runningTasks = 0;
25 + var hasError = false;
26 +
27 + var listeners = {};
28 +
29 + var readyTasks = [];
30 +
31 + // for cycle detection:
32 + var readyToCheck = []; // tasks that have been identified as reachable
33 + // without the possibility of returning to an ancestor task
34 + var uncheckedDependencies = {};
35 +
36 + (0, _baseForOwn2.default)(tasks, function (task, key) {
37 + if (!(0, _isArray2.default)(task)) {
38 + // no dependencies
39 + enqueueTask(key, [task]);
40 + readyToCheck.push(key);
41 + return;
42 + }
43 +
44 + var dependencies = task.slice(0, task.length - 1);
45 + var remainingDependencies = dependencies.length;
46 + if (remainingDependencies === 0) {
47 + enqueueTask(key, task);
48 + readyToCheck.push(key);
49 + return;
50 + }
51 + uncheckedDependencies[key] = remainingDependencies;
52 +
53 + (0, _arrayEach2.default)(dependencies, function (dependencyName) {
54 + if (!tasks[dependencyName]) {
55 + throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
56 + }
57 + addListener(dependencyName, function () {
58 + remainingDependencies--;
59 + if (remainingDependencies === 0) {
60 + enqueueTask(key, task);
61 + }
62 + });
63 + });
64 + });
65 +
66 + checkForDeadlocks();
67 + processQueue();
68 +
69 + function enqueueTask(key, task) {
70 + readyTasks.push(function () {
71 + runTask(key, task);
72 + });
73 + }
74 +
75 + function processQueue() {
76 + if (readyTasks.length === 0 && runningTasks === 0) {
77 + return callback(null, results);
78 + }
79 + while (readyTasks.length && runningTasks < concurrency) {
80 + var run = readyTasks.shift();
81 + run();
82 + }
83 + }
84 +
85 + function addListener(taskName, fn) {
86 + var taskListeners = listeners[taskName];
87 + if (!taskListeners) {
88 + taskListeners = listeners[taskName] = [];
89 + }
90 +
91 + taskListeners.push(fn);
92 + }
93 +
94 + function taskComplete(taskName) {
95 + var taskListeners = listeners[taskName] || [];
96 + (0, _arrayEach2.default)(taskListeners, function (fn) {
97 + fn();
98 + });
99 + processQueue();
100 + }
101 +
102 + function runTask(key, task) {
103 + if (hasError) return;
104 +
105 + var taskCallback = (0, _onlyOnce2.default)((0, _rest2.default)(function (err, args) {
106 + runningTasks--;
107 + if (args.length <= 1) {
108 + args = args[0];
109 + }
110 + if (err) {
111 + var safeResults = {};
112 + (0, _baseForOwn2.default)(results, function (val, rkey) {
113 + safeResults[rkey] = val;
114 + });
115 + safeResults[key] = args;
116 + hasError = true;
117 + listeners = [];
118 +
119 + callback(err, safeResults);
120 + } else {
121 + results[key] = args;
122 + taskComplete(key);
123 + }
124 + }));
125 +
126 + runningTasks++;
127 + var taskFn = task[task.length - 1];
128 + if (task.length > 1) {
129 + taskFn(results, taskCallback);
130 + } else {
131 + taskFn(taskCallback);
132 + }
133 + }
134 +
135 + function checkForDeadlocks() {
136 + // Kahn's algorithm
137 + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
138 + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
139 + var currentTask;
140 + var counter = 0;
141 + while (readyToCheck.length) {
142 + currentTask = readyToCheck.pop();
143 + counter++;
144 + (0, _arrayEach2.default)(getDependents(currentTask), function (dependent) {
145 + if (--uncheckedDependencies[dependent] === 0) {
146 + readyToCheck.push(dependent);
147 + }
148 + });
149 + }
150 +
151 + if (counter !== numTasks) {
152 + throw new Error('async.auto cannot execute tasks due to a recursive dependency');
153 + }
154 + }
155 +
156 + function getDependents(taskName) {
157 + var result = [];
158 + (0, _baseForOwn2.default)(tasks, function (task, key) {
159 + if ((0, _isArray2.default)(task) && (0, _baseIndexOf2.default)(task, taskName, 0) >= 0) {
160 + result.push(key);
161 + }
162 + });
163 + return result;
164 + }
165 +};
166 +
167 +var _arrayEach = require('lodash/_arrayEach');
168 +
169 +var _arrayEach2 = _interopRequireDefault(_arrayEach);
170 +
171 +var _baseForOwn = require('lodash/_baseForOwn');
172 +
173 +var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
174 +
175 +var _baseIndexOf = require('lodash/_baseIndexOf');
176 +
177 +var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
178 +
179 +var _isArray = require('lodash/isArray');
180 +
181 +var _isArray2 = _interopRequireDefault(_isArray);
182 +
183 +var _keys = require('lodash/keys');
184 +
185 +var _keys2 = _interopRequireDefault(_keys);
186 +
187 +var _noop = require('lodash/noop');
188 +
189 +var _noop2 = _interopRequireDefault(_noop);
190 +
191 +var _rest = require('./internal/rest');
192 +
193 +var _rest2 = _interopRequireDefault(_rest);
194 +
195 +var _once = require('./internal/once');
196 +
197 +var _once2 = _interopRequireDefault(_once);
198 +
199 +var _onlyOnce = require('./internal/onlyOnce');
200 +
201 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
202 +
203 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
204 +
205 +module.exports = exports['default'];
206 +
207 +/**
208 + * Determines the best order for running the functions in `tasks`, based on
209 + * their requirements. Each function can optionally depend on other functions
210 + * being completed first, and each function is run as soon as its requirements
211 + * are satisfied.
212 + *
213 + * If any of the functions pass an error to their callback, the `auto` sequence
214 + * will stop. Further tasks will not execute (so any other functions depending
215 + * on it will not run), and the main `callback` is immediately called with the
216 + * error.
217 + *
218 + * Functions also receive an object containing the results of functions which
219 + * have completed so far as the first argument, if they have dependencies. If a
220 + * task function has no dependencies, it will only be passed a callback.
221 + *
222 + * @name auto
223 + * @static
224 + * @memberOf module:ControlFlow
225 + * @method
226 + * @category Control Flow
227 + * @param {Object} tasks - An object. Each of its properties is either a
228 + * function or an array of requirements, with the function itself the last item
229 + * in the array. The object's key of a property serves as the name of the task
230 + * defined by that property, i.e. can be used when specifying requirements for
231 + * other tasks. The function receives one or two arguments:
232 + * * a `results` object, containing the results of the previously executed
233 + * functions, only passed if the task has any dependencies,
234 + * * a `callback(err, result)` function, which must be called when finished,
235 + * passing an `error` (which can be `null`) and the result of the function's
236 + * execution.
237 + * @param {number} [concurrency=Infinity] - An optional `integer` for
238 + * determining the maximum number of tasks that can be run in parallel. By
239 + * default, as many as possible.
240 + * @param {Function} [callback] - An optional callback which is called when all
241 + * the tasks have been completed. It receives the `err` argument if any `tasks`
242 + * pass an error to their callback. Results are always returned; however, if an
243 + * error occurs, no further `tasks` will be performed, and the results object
244 + * will only contain partial results. Invoked with (err, results).
245 + * @returns undefined
246 + * @example
247 + *
248 + * async.auto({
249 + * // this function will just be passed a callback
250 + * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
251 + * showData: ['readData', function(results, cb) {
252 + * // results.readData is the file's contents
253 + * // ...
254 + * }]
255 + * }, callback);
256 + *
257 + * async.auto({
258 + * get_data: function(callback) {
259 + * console.log('in get_data');
260 + * // async code to get some data
261 + * callback(null, 'data', 'converted to array');
262 + * },
263 + * make_folder: function(callback) {
264 + * console.log('in make_folder');
265 + * // async code to create a directory to store a file in
266 + * // this is run at the same time as getting the data
267 + * callback(null, 'folder');
268 + * },
269 + * write_file: ['get_data', 'make_folder', function(results, callback) {
270 + * console.log('in write_file', JSON.stringify(results));
271 + * // once there is some data and the directory exists,
272 + * // write the data to a file in the directory
273 + * callback(null, 'filename');
274 + * }],
275 + * email_link: ['write_file', function(results, callback) {
276 + * console.log('in email_link', JSON.stringify(results));
277 + * // once the file is written let's email a link to it...
278 + * // results.write_file contains the filename returned by write_file.
279 + * callback(null, {'file':results.write_file, 'email':'user@example.com'});
280 + * }]
281 + * }, function(err, results) {
282 + * console.log('err = ', err);
283 + * console.log('results = ', results);
284 + * });
285 + */
...\ 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 _baseForOwn = require('lodash/_baseForOwn');
13 +
14 +var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
15 +
16 +var _arrayMap = require('lodash/_arrayMap');
17 +
18 +var _arrayMap2 = _interopRequireDefault(_arrayMap);
19 +
20 +var _isArray = require('lodash/isArray');
21 +
22 +var _isArray2 = _interopRequireDefault(_isArray);
23 +
24 +var _trim = require('lodash/trim');
25 +
26 +var _trim2 = _interopRequireDefault(_trim);
27 +
28 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29 +
30 +var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
31 +var FN_ARG_SPLIT = /,/;
32 +var FN_ARG = /(=.+)?(\s*)$/;
33 +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
34 +
35 +function parseParams(func) {
36 + func = func.toString().replace(STRIP_COMMENTS, '');
37 + func = func.match(FN_ARGS)[2].replace(' ', '');
38 + func = func ? func.split(FN_ARG_SPLIT) : [];
39 + func = func.map(function (arg) {
40 + return (0, _trim2.default)(arg.replace(FN_ARG, ''));
41 + });
42 + return func;
43 +}
44 +
45 +/**
46 + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
47 + * tasks are specified as parameters to the function, after the usual callback
48 + * parameter, with the parameter names matching the names of the tasks it
49 + * depends on. This can provide even more readable task graphs which can be
50 + * easier to maintain.
51 + *
52 + * If a final callback is specified, the task results are similarly injected,
53 + * specified as named parameters after the initial error parameter.
54 + *
55 + * The autoInject function is purely syntactic sugar and its semantics are
56 + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
57 + *
58 + * @name autoInject
59 + * @static
60 + * @memberOf module:ControlFlow
61 + * @method
62 + * @see [async.auto]{@link module:ControlFlow.auto}
63 + * @category Control Flow
64 + * @param {Object} tasks - An object, each of whose properties is a function of
65 + * the form 'func([dependencies...], callback). The object's key of a property
66 + * serves as the name of the task defined by that property, i.e. can be used
67 + * when specifying requirements for other tasks.
68 + * * The `callback` parameter is a `callback(err, result)` which must be called
69 + * when finished, passing an `error` (which can be `null`) and the result of
70 + * the function's execution. The remaining parameters name other tasks on
71 + * which the task is dependent, and the results from those tasks are the
72 + * arguments of those parameters.
73 + * @param {Function} [callback] - An optional callback which is called when all
74 + * the tasks have been completed. It receives the `err` argument if any `tasks`
75 + * pass an error to their callback, and a `results` object with any completed
76 + * task results, similar to `auto`.
77 + * @example
78 + *
79 + * // The example from `auto` can be rewritten as follows:
80 + * async.autoInject({
81 + * get_data: function(callback) {
82 + * // async code to get some data
83 + * callback(null, 'data', 'converted to array');
84 + * },
85 + * make_folder: function(callback) {
86 + * // async code to create a directory to store a file in
87 + * // this is run at the same time as getting the data
88 + * callback(null, 'folder');
89 + * },
90 + * write_file: function(get_data, make_folder, callback) {
91 + * // once there is some data and the directory exists,
92 + * // write the data to a file in the directory
93 + * callback(null, 'filename');
94 + * },
95 + * email_link: function(write_file, callback) {
96 + * // once the file is written let's email a link to it...
97 + * // write_file contains the filename returned by write_file.
98 + * callback(null, {'file':write_file, 'email':'user@example.com'});
99 + * }
100 + * }, function(err, results) {
101 + * console.log('err = ', err);
102 + * console.log('email_link = ', results.email_link);
103 + * });
104 + *
105 + * // If you are using a JS minifier that mangles parameter names, `autoInject`
106 + * // will not work with plain functions, since the parameter names will be
107 + * // collapsed to a single letter identifier. To work around this, you can
108 + * // explicitly specify the names of the parameters your task function needs
109 + * // in an array, similar to Angular.js dependency injection.
110 + *
111 + * // This still has an advantage over plain `auto`, since the results a task
112 + * // depends on are still spread into arguments.
113 + * async.autoInject({
114 + * //...
115 + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
116 + * callback(null, 'filename');
117 + * }],
118 + * email_link: ['write_file', function(write_file, callback) {
119 + * callback(null, {'file':write_file, 'email':'user@example.com'});
120 + * }]
121 + * //...
122 + * }, function(err, results) {
123 + * console.log('err = ', err);
124 + * console.log('email_link = ', results.email_link);
125 + * });
126 + */
127 +function autoInject(tasks, callback) {
128 + var newTasks = {};
129 +
130 + (0, _baseForOwn2.default)(tasks, function (taskFn, key) {
131 + var params;
132 +
133 + if ((0, _isArray2.default)(taskFn)) {
134 + params = taskFn.slice(0, -1);
135 + taskFn = taskFn[taskFn.length - 1];
136 +
137 + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
138 + } else if (taskFn.length === 1) {
139 + // no dependencies, use the function as-is
140 + newTasks[key] = taskFn;
141 + } else {
142 + params = parseParams(taskFn);
143 + if (taskFn.length === 0 && params.length === 0) {
144 + throw new Error("autoInject task functions require explicit parameters.");
145 + }
146 +
147 + params.pop();
148 +
149 + newTasks[key] = params.concat(newTask);
150 + }
151 +
152 + function newTask(results, taskCb) {
153 + var newArgs = (0, _arrayMap2.default)(params, function (name) {
154 + return results[name];
155 + });
156 + newArgs.push(taskCb);
157 + taskFn.apply(null, newArgs);
158 + }
159 + });
160 +
161 + (0, _auto2.default)(newTasks, callback);
162 +}
163 +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 + "mocha_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 + * A cargo of tasks for the worker function to complete. Cargo inherits all of
16 + * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
17 + * @typedef {Object} CargoObject
18 + * @memberOf module:ControlFlow
19 + * @property {Function} length - A function returning the number of items
20 + * waiting to be processed. Invoke like `cargo.length()`.
21 + * @property {number} payload - An `integer` for determining how many tasks
22 + * should be process per round. This property can be changed after a `cargo` is
23 + * created to alter the payload on-the-fly.
24 + * @property {Function} push - Adds `task` to the `queue`. The callback is
25 + * called once the `worker` has finished processing the task. Instead of a
26 + * single task, an array of `tasks` can be submitted. The respective callback is
27 + * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
28 + * @property {Function} saturated - A callback that is called when the
29 + * `queue.length()` hits the concurrency and further tasks will be queued.
30 + * @property {Function} empty - A callback that is called when the last item
31 + * from the `queue` is given to a `worker`.
32 + * @property {Function} drain - A callback that is called when the last item
33 + * from the `queue` has returned from the `worker`.
34 + * @property {Function} idle - a function returning false if there are items
35 + * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
36 + * @property {Function} pause - a function that pauses the processing of tasks
37 + * until `resume()` is called. Invoke like `cargo.pause()`.
38 + * @property {Function} resume - a function that resumes the processing of
39 + * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
40 + * @property {Function} kill - a function that removes the `drain` callback and
41 + * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
42 + */
43 +
44 +/**
45 + * Creates a `cargo` object with the specified payload. Tasks added to the
46 + * cargo will be processed altogether (up to the `payload` limit). If the
47 + * `worker` is in progress, the task is queued until it becomes available. Once
48 + * the `worker` has completed some tasks, each callback of those tasks is
49 + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
50 + * for how `cargo` and `queue` work.
51 + *
52 + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
53 + * at a time, cargo passes an array of tasks to a single worker, repeating
54 + * when the worker is finished.
55 + *
56 + * @name cargo
57 + * @static
58 + * @memberOf module:ControlFlow
59 + * @method
60 + * @see [async.queue]{@link module:ControlFlow.queue}
61 + * @category Control Flow
62 + * @param {Function} worker - An asynchronous function for processing an array
63 + * of queued tasks, which must call its `callback(err)` argument when finished,
64 + * with an optional `err` argument. Invoked with `(tasks, callback)`.
65 + * @param {number} [payload=Infinity] - An optional `integer` for determining
66 + * how many tasks should be processed per round; if omitted, the default is
67 + * unlimited.
68 + * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
69 + * attached as certain properties to listen for specific events during the
70 + * lifecycle of the cargo and inner queue.
71 + * @example
72 + *
73 + * // create a cargo object with payload 2
74 + * var cargo = async.cargo(function(tasks, callback) {
75 + * for (var i=0; i<tasks.length; i++) {
76 + * console.log('hello ' + tasks[i].name);
77 + * }
78 + * callback();
79 + * }, 2);
80 + *
81 + * // add some items
82 + * cargo.push({name: 'foo'}, function(err) {
83 + * console.log('finished processing foo');
84 + * });
85 + * cargo.push({name: 'bar'}, function(err) {
86 + * console.log('finished processing bar');
87 + * });
88 + * cargo.push({name: 'baz'}, function(err) {
89 + * console.log('finished processing baz');
90 + * });
91 + */
92 +function cargo(worker, payload) {
93 + return (0, _queue2.default)(worker, 1, payload);
94 +}
95 +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 _seq = require('./seq');
8 +
9 +var _seq2 = _interopRequireDefault(_seq);
10 +
11 +var _rest = require('./internal/rest');
12 +
13 +var _rest2 = _interopRequireDefault(_rest);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Creates a function which is a composition of the passed asynchronous
19 + * functions. Each function consumes the return value of the function that
20 + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
21 + * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
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 {...Function} 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 +exports.default = (0, _rest2.default)(function (args) {
53 + return _seq2.default.apply(null, 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 _concat = require('./internal/concat');
8 +
9 +var _concat2 = _interopRequireDefault(_concat);
10 +
11 +var _doParallel = require('./internal/doParallel');
12 +
13 +var _doParallel2 = _interopRequireDefault(_doParallel);
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. There is no guarantee that the
21 + * results array will be returned in the original order of `coll` passed to the
22 + * `iteratee` function.
23 + *
24 + * @name concat
25 + * @static
26 + * @memberOf module:Collections
27 + * @method
28 + * @category Collection
29 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
30 + * @param {Function} iteratee - A function to apply to each item in `coll`.
31 + * The iteratee is passed a `callback(err, results)` which must be called once
32 + * it has completed with an error (which can be `null`) and an array of results.
33 + * Invoked with (item, callback).
34 + * @param {Function} [callback(err)] - A callback which is called after all the
35 + * `iteratee` functions have finished, or an error occurs. Results is an array
36 + * containing the concatenated results of the `iteratee` function. Invoked with
37 + * (err, results).
38 + * @example
39 + *
40 + * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
41 + * // files is now a list of filenames that exist in the 3 directories
42 + * });
43 + */
44 +exports.default = (0, _doParallel2.default)(_concat2.default);
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 _concat = require('./internal/concat');
8 +
9 +var _concat2 = _interopRequireDefault(_concat);
10 +
11 +var _doSeries = require('./internal/doSeries');
12 +
13 +var _doSeries2 = _interopRequireDefault(_doSeries);
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 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {Function} iteratee - A function to apply to each item in `coll`.
28 + * The iteratee is passed a `callback(err, results)` which must be called once
29 + * it has completed with an error (which can be `null`) and an array of results.
30 + * Invoked with (item, callback).
31 + * @param {Function} [callback(err)] - 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 + */
36 +exports.default = (0, _doSeries2.default)(_concat2.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 +
7 +var _rest = require('./internal/rest');
8 +
9 +var _rest2 = _interopRequireDefault(_rest);
10 +
11 +var _initialParams = require('./internal/initialParams');
12 +
13 +var _initialParams2 = _interopRequireDefault(_initialParams);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Returns a function that when called, calls-back with the values provided.
19 + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
20 + * [`auto`]{@link module:ControlFlow.auto}.
21 + *
22 + * @name constant
23 + * @static
24 + * @memberOf module:Utils
25 + * @method
26 + * @category Util
27 + * @param {...*} arguments... - Any number of arguments to automatically invoke
28 + * callback with.
29 + * @returns {Function} Returns a function that when invoked, automatically
30 + * invokes the callback with the previous given arguments.
31 + * @example
32 + *
33 + * async.waterfall([
34 + * async.constant(42),
35 + * function (value, next) {
36 + * // value === 42
37 + * },
38 + * //...
39 + * ], callback);
40 + *
41 + * async.waterfall([
42 + * async.constant(filename, "utf8"),
43 + * fs.readFile,
44 + * function (fileData, next) {
45 + * //...
46 + * }
47 + * //...
48 + * ], callback);
49 + *
50 + * async.auto({
51 + * hostname: async.constant("https://server.net/"),
52 + * port: findFreePort,
53 + * launchServer: ["hostname", "port", function (options, cb) {
54 + * startServer(options, cb);
55 + * }],
56 + * //...
57 + * }, callback);
58 + */
59 +exports.default = (0, _rest2.default)(function (values) {
60 + var args = [null].concat(values);
61 + return (0, _initialParams2.default)(function (ignoredArgs, callback) {
62 + return callback.apply(this, args);
63 + });
64 +});
65 +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 _identity = require('lodash/identity');
8 +
9 +var _identity2 = _interopRequireDefault(_identity);
10 +
11 +var _createTester = require('./internal/createTester');
12 +
13 +var _createTester2 = _interopRequireDefault(_createTester);
14 +
15 +var _eachOf = require('./eachOf');
16 +
17 +var _eachOf2 = _interopRequireDefault(_eachOf);
18 +
19 +var _findGetResult = require('./internal/findGetResult');
20 +
21 +var _findGetResult2 = _interopRequireDefault(_findGetResult);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * Returns the first value in `coll` that passes an async truth test. The
27 + * `iteratee` is applied in parallel, meaning the first iteratee to return
28 + * `true` will fire the detect `callback` with that result. That means the
29 + * result might not be the first item in the original `coll` (in terms of order)
30 + * that passes the test.
31 +
32 + * If order within the original `coll` is important, then look at
33 + * [`detectSeries`]{@link module:Collections.detectSeries}.
34 + *
35 + * @name detect
36 + * @static
37 + * @memberOf module:Collections
38 + * @method
39 + * @alias find
40 + * @category Collections
41 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
42 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
43 + * The iteratee is passed a `callback(err, truthValue)` which must be called
44 + * with a boolean argument once it has completed. Invoked with (item, callback).
45 + * @param {Function} [callback] - A callback which is called as soon as any
46 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
47 + * Result will be the first item in the array that passes the truth test
48 + * (iteratee) or the value `undefined` if none passed. Invoked with
49 + * (err, result).
50 + * @example
51 + *
52 + * async.detect(['file1','file2','file3'], function(filePath, callback) {
53 + * fs.access(filePath, function(err) {
54 + * callback(null, !err)
55 + * });
56 + * }, function(err, result) {
57 + * // result now equals the first file in the list that exists
58 + * });
59 + */
60 +exports.default = (0, _createTester2.default)(_eachOf2.default, _identity2.default, _findGetResult2.default);
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 _identity = require('lodash/identity');
8 +
9 +var _identity2 = _interopRequireDefault(_identity);
10 +
11 +var _createTester = require('./internal/createTester');
12 +
13 +var _createTester2 = _interopRequireDefault(_createTester);
14 +
15 +var _eachOfLimit = require('./eachOfLimit');
16 +
17 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
18 +
19 +var _findGetResult = require('./internal/findGetResult');
20 +
21 +var _findGetResult2 = _interopRequireDefault(_findGetResult);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
27 + * time.
28 + *
29 + * @name detectLimit
30 + * @static
31 + * @memberOf module:Collections
32 + * @method
33 + * @see [async.detect]{@link module:Collections.detect}
34 + * @alias findLimit
35 + * @category Collections
36 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
37 + * @param {number} limit - The maximum number of async operations at a time.
38 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
39 + * The iteratee is passed a `callback(err, truthValue)` which must be called
40 + * with a boolean argument once it has completed. 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 + */
47 +exports.default = (0, _createTester2.default)(_eachOfLimit2.default, _identity2.default, _findGetResult2.default);
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 _identity = require('lodash/identity');
8 +
9 +var _identity2 = _interopRequireDefault(_identity);
10 +
11 +var _createTester = require('./internal/createTester');
12 +
13 +var _createTester2 = _interopRequireDefault(_createTester);
14 +
15 +var _eachOfSeries = require('./eachOfSeries');
16 +
17 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
18 +
19 +var _findGetResult = require('./internal/findGetResult');
20 +
21 +var _findGetResult2 = _interopRequireDefault(_findGetResult);
22 +
23 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24 +
25 +/**
26 + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
27 + *
28 + * @name detectSeries
29 + * @static
30 + * @memberOf module:Collections
31 + * @method
32 + * @see [async.detect]{@link module:Collections.detect}
33 + * @alias findSeries
34 + * @category Collections
35 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
36 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
37 + * The iteratee is passed a `callback(err, truthValue)` which must be called
38 + * with a boolean argument once it has completed. Invoked with (item, callback).
39 + * @param {Function} [callback] - A callback which is called as soon as any
40 + * iteratee returns `true`, or after all the `iteratee` functions have finished.
41 + * Result will be the first item in the array that passes the truth test
42 + * (iteratee) or the value `undefined` if none passed. Invoked with
43 + * (err, result).
44 + */
45 +exports.default = (0, _createTester2.default)(_eachOfSeries2.default, _identity2.default, _findGetResult2.default);
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 _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 to the `console` using `console.dir`
15 + * to display the properties of the resulting object. Only works in Node.js or
16 + * in browsers that support `console.dir` and `console.error` (such as FF and
17 + * Chrome). If multiple arguments are returned from the async function,
18 + * `console.dir` is called on each argument in order.
19 + *
20 + * @name dir
21 + * @static
22 + * @memberOf module:Utils
23 + * @method
24 + * @category Util
25 + * @param {Function} function - The function you want to eventually apply all
26 + * arguments to.
27 + * @param {...*} arguments... - Any number of arguments to apply to the function.
28 + * @example
29 + *
30 + * // in a module
31 + * var hello = function(name, callback) {
32 + * setTimeout(function() {
33 + * callback(null, {hello: name});
34 + * }, 1000);
35 + * };
36 + *
37 + * // in the node repl
38 + * node> async.dir(hello, 'world');
39 + * {hello: 'world'}
40 + */
41 +exports.default = (0, _consoleFunc2.default)('dir');
42 +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.
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = doDuring;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _rest = require('./internal/rest');
13 +
14 +var _rest2 = _interopRequireDefault(_rest);
15 +
16 +var _onlyOnce = require('./internal/onlyOnce');
17 +
18 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
24 + * the order of operations, the arguments `test` and `fn` are switched.
25 + *
26 + * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
27 + * @name doDuring
28 + * @static
29 + * @memberOf module:ControlFlow
30 + * @method
31 + * @see [async.during]{@link module:ControlFlow.during}
32 + * @category Control Flow
33 + * @param {Function} fn - A function which is called each time `test` passes.
34 + * The function is passed a `callback(err)`, which must be called once it has
35 + * completed with an optional `err` argument. Invoked with (callback).
36 + * @param {Function} test - asynchronous truth test to perform before each
37 + * execution of `fn`. Invoked with (...args, callback), where `...args` are the
38 + * non-error args from the previous callback of `fn`.
39 + * @param {Function} [callback] - A callback which is called after the test
40 + * function has failed and repeated execution of `fn` has stopped. `callback`
41 + * will be passed an error if one occured, otherwise `null`.
42 + */
43 +function doDuring(fn, test, callback) {
44 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
45 +
46 + var next = (0, _rest2.default)(function (err, args) {
47 + if (err) return callback(err);
48 + args.push(check);
49 + test.apply(this, args);
50 + });
51 +
52 + function check(err, truth) {
53 + if (err) return callback(err);
54 + if (!truth) return callback(null);
55 + fn(next);
56 + }
57 +
58 + check(null, true);
59 +}
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 +exports.default = doUntil;
7 +
8 +var _doWhilst = require('./doWhilst');
9 +
10 +var _doWhilst2 = _interopRequireDefault(_doWhilst);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
16 + * argument ordering differs from `until`.
17 + *
18 + * @name doUntil
19 + * @static
20 + * @memberOf module:ControlFlow
21 + * @method
22 + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
23 + * @category Control Flow
24 + * @param {Function} fn - A function which is called each time `test` fails.
25 + * The function is passed a `callback(err)`, which must be called once it has
26 + * completed with an optional `err` argument. Invoked with (callback).
27 + * @param {Function} test - synchronous truth test to perform after each
28 + * execution of `fn`. Invoked with the non-error callback results of `fn`.
29 + * @param {Function} [callback] - A callback which is called after the test
30 + * function has passed and repeated execution of `fn` has stopped. `callback`
31 + * will be passed an error and any arguments passed to the final `fn`'s
32 + * callback. Invoked with (err, [results]);
33 + */
34 +function doUntil(fn, test, callback) {
35 + (0, _doWhilst2.default)(fn, function () {
36 + return !test.apply(this, arguments);
37 + }, callback);
38 +}
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 +exports.default = doWhilst;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _rest = require('./internal/rest');
13 +
14 +var _rest2 = _interopRequireDefault(_rest);
15 +
16 +var _onlyOnce = require('./internal/onlyOnce');
17 +
18 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
24 + * the order of operations, the arguments `test` and `iteratee` are switched.
25 + *
26 + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
27 + *
28 + * @name doWhilst
29 + * @static
30 + * @memberOf module:ControlFlow
31 + * @method
32 + * @see [async.whilst]{@link module:ControlFlow.whilst}
33 + * @category Control Flow
34 + * @param {Function} iteratee - A function which is called each time `test`
35 + * passes. The function is passed a `callback(err)`, which must be called once
36 + * it has completed with an optional `err` argument. Invoked with (callback).
37 + * @param {Function} test - synchronous truth test to perform after each
38 + * execution of `iteratee`. Invoked with the non-error callback results of
39 + * `iteratee`.
40 + * @param {Function} [callback] - A callback which is called after the test
41 + * function has failed and repeated execution of `iteratee` has stopped.
42 + * `callback` will be passed an error and any arguments passed to the final
43 + * `iteratee`'s callback. Invoked with (err, [results]);
44 + */
45 +function doWhilst(iteratee, test, callback) {
46 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
47 + var next = (0, _rest2.default)(function (err, args) {
48 + if (err) return callback(err);
49 + if (test.apply(this, args)) return iteratee(next);
50 + callback.apply(null, [null].concat(args));
51 + });
52 + iteratee(next);
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 = during;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _onlyOnce = require('./internal/onlyOnce');
13 +
14 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
20 + * is passed a callback in the form of `function (err, truth)`. If error is
21 + * passed to `test` or `fn`, the main callback is immediately called with the
22 + * value of the error.
23 + *
24 + * @name during
25 + * @static
26 + * @memberOf module:ControlFlow
27 + * @method
28 + * @see [async.whilst]{@link module:ControlFlow.whilst}
29 + * @category Control Flow
30 + * @param {Function} test - asynchronous truth test to perform before each
31 + * execution of `fn`. Invoked with (callback).
32 + * @param {Function} fn - A function which is called each time `test` passes.
33 + * The function is passed a `callback(err)`, which must be called once it has
34 + * completed with an optional `err` argument. Invoked with (callback).
35 + * @param {Function} [callback] - A callback which is called after the test
36 + * function has failed and repeated execution of `fn` has stopped. `callback`
37 + * will be passed an error, if one occured, otherwise `null`.
38 + * @example
39 + *
40 + * var count = 0;
41 + *
42 + * async.during(
43 + * function (callback) {
44 + * return callback(null, count < 5);
45 + * },
46 + * function (callback) {
47 + * count++;
48 + * setTimeout(callback, 1000);
49 + * },
50 + * function (err) {
51 + * // 5 seconds have passed
52 + * }
53 + * );
54 + */
55 +function during(test, fn, callback) {
56 + callback = (0, _onlyOnce2.default)(callback || _noop2.default);
57 +
58 + function next(err) {
59 + if (err) return callback(err);
60 + test(check);
61 + }
62 +
63 + function check(err, truth) {
64 + if (err) return callback(err);
65 + if (!truth) return callback(null);
66 + fn(next);
67 + }
68 +
69 + test(check);
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 = eachLimit;
7 +
8 +var _eachOf = require('./eachOf');
9 +
10 +var _eachOf2 = _interopRequireDefault(_eachOf);
11 +
12 +var _withoutIndex = require('./internal/withoutIndex');
13 +
14 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Applies the function `iteratee` to each item in `coll`, in parallel.
20 + * The `iteratee` is called with an item from the list, and a callback for when
21 + * it has finished. If the `iteratee` passes an error to its `callback`, the
22 + * main `callback` (for the `each` function) is immediately called with the
23 + * error.
24 + *
25 + * Note, that since this function applies `iteratee` to each item in parallel,
26 + * there is no guarantee that the iteratee functions will complete in order.
27 + *
28 + * @name each
29 + * @static
30 + * @memberOf module:Collections
31 + * @method
32 + * @alias forEach
33 + * @category Collection
34 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
35 + * @param {Function} iteratee - A function to apply to each item
36 + * in `coll`. The iteratee is passed a `callback(err)` which must be called once
37 + * it has completed. If no error has occurred, the `callback` should be run
38 + * without arguments or with an explicit `null` argument. The array index is not
39 + * passed to the iteratee. Invoked with (item, callback). If you need the index,
40 + * use `eachOf`.
41 + * @param {Function} [callback] - A callback which is called when all
42 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
43 + * @example
44 + *
45 + * // assuming openFiles is an array of file names and saveFile is a function
46 + * // to save the modified contents of that file:
47 + *
48 + * async.each(openFiles, saveFile, function(err){
49 + * // if any of the saves produced an error, err would equal that error
50 + * });
51 + *
52 + * // assuming openFiles is an array of file names
53 + * async.each(openFiles, function(file, callback) {
54 + *
55 + * // Perform operation on file here.
56 + * console.log('Processing file ' + file);
57 + *
58 + * if( file.length > 32 ) {
59 + * console.log('This file name is too long');
60 + * callback('File name too long');
61 + * } else {
62 + * // Do work to process file here
63 + * console.log('File processed');
64 + * callback();
65 + * }
66 + * }, function(err) {
67 + * // if any of the file processing produced an error, err would equal that error
68 + * if( err ) {
69 + * // One of the iterations produced an error.
70 + * // All processing will now stop.
71 + * console.log('A file failed to process');
72 + * } else {
73 + * console.log('All files have been processed successfully');
74 + * }
75 + * });
76 + */
77 +function eachLimit(coll, iteratee, callback) {
78 + (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)(iteratee), callback);
79 +}
80 +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 = eachLimit;
7 +
8 +var _eachOfLimit = require('./internal/eachOfLimit');
9 +
10 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
11 +
12 +var _withoutIndex = require('./internal/withoutIndex');
13 +
14 +var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
20 + *
21 + * @name eachLimit
22 + * @static
23 + * @memberOf module:Collections
24 + * @method
25 + * @see [async.each]{@link module:Collections.each}
26 + * @alias forEachLimit
27 + * @category Collection
28 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
29 + * @param {number} limit - The maximum number of async operations at a time.
30 + * @param {Function} iteratee - A function to apply to each item in `coll`. The
31 + * iteratee is passed a `callback(err)` which must be called once it has
32 + * completed. If no error has occurred, the `callback` should be run without
33 + * arguments or with an explicit `null` argument. The array index is not passed
34 + * to the iteratee. Invoked with (item, callback). If you need the index, use
35 + * `eachOfLimit`.
36 + * @param {Function} [callback] - A callback which is called when all
37 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
38 + */
39 +function eachLimit(coll, limit, iteratee, callback) {
40 + (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)(iteratee), callback);
41 +}
42 +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, iteratee, callback) {
8 + var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
9 + eachOfImplementation(coll, iteratee, callback);
10 +};
11 +
12 +var _isArrayLike = require('lodash/isArrayLike');
13 +
14 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
15 +
16 +var _eachOfLimit = require('./eachOfLimit');
17 +
18 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
19 +
20 +var _doLimit = require('./internal/doLimit');
21 +
22 +var _doLimit2 = _interopRequireDefault(_doLimit);
23 +
24 +var _noop = require('lodash/noop');
25 +
26 +var _noop2 = _interopRequireDefault(_noop);
27 +
28 +var _once = require('./internal/once');
29 +
30 +var _once2 = _interopRequireDefault(_once);
31 +
32 +var _onlyOnce = require('./internal/onlyOnce');
33 +
34 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
35 +
36 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37 +
38 +// eachOf implementation optimized for array-likes
39 +function eachOfArrayLike(coll, iteratee, callback) {
40 + callback = (0, _once2.default)(callback || _noop2.default);
41 + var index = 0,
42 + completed = 0,
43 + length = coll.length;
44 + if (length === 0) {
45 + callback(null);
46 + }
47 +
48 + function iteratorCallback(err) {
49 + if (err) {
50 + callback(err);
51 + } else if (++completed === length) {
52 + callback(null);
53 + }
54 + }
55 +
56 + for (; index < length; index++) {
57 + iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
58 + }
59 +}
60 +
61 +// a generic version of eachOf which can handle array, object, and iterator cases.
62 +var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
63 +
64 +/**
65 + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
66 + * to the iteratee.
67 + *
68 + * @name eachOf
69 + * @static
70 + * @memberOf module:Collections
71 + * @method
72 + * @alias forEachOf
73 + * @category Collection
74 + * @see [async.each]{@link module:Collections.each}
75 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
76 + * @param {Function} iteratee - A function to apply to each
77 + * item in `coll`. The `key` is the item's key, or index in the case of an
78 + * array. The iteratee is passed a `callback(err)` which must be called once it
79 + * has completed. If no error has occurred, the callback should be run without
80 + * arguments or with an explicit `null` argument. Invoked with
81 + * (item, key, callback).
82 + * @param {Function} [callback] - A callback which is called when all
83 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
84 + * @example
85 + *
86 + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
87 + * var configs = {};
88 + *
89 + * async.forEachOf(obj, function (value, key, callback) {
90 + * fs.readFile(__dirname + value, "utf8", function (err, data) {
91 + * if (err) return callback(err);
92 + * try {
93 + * configs[key] = JSON.parse(data);
94 + * } catch (e) {
95 + * return callback(e);
96 + * }
97 + * callback();
98 + * });
99 + * }, function (err) {
100 + * if (err) console.error(err.message);
101 + * // configs is now a map of JSON data
102 + * doSomethingWith(configs);
103 + * });
104 + */
105 +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 = eachOfLimit;
7 +
8 +var _eachOfLimit2 = require('./internal/eachOfLimit');
9 +
10 +var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
16 + * time.
17 + *
18 + * @name eachOfLimit
19 + * @static
20 + * @memberOf module:Collections
21 + * @method
22 + * @see [async.eachOf]{@link module:Collections.eachOf}
23 + * @alias forEachOfLimit
24 + * @category Collection
25 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
26 + * @param {number} limit - The maximum number of async operations at a time.
27 + * @param {Function} iteratee - A function to apply to each
28 + * item in `coll`. The `key` is the item's key, or index in the case of an
29 + * array. The iteratee is passed a `callback(err)` which must be called once it
30 + * has completed. If no error has occurred, the callback should be run without
31 + * arguments or with an explicit `null` argument. Invoked with
32 + * (item, key, callback).
33 + * @param {Function} [callback] - A callback which is called when all
34 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
35 + */
36 +function eachOfLimit(coll, limit, iteratee, callback) {
37 + (0, _eachOfLimit3.default)(limit)(coll, iteratee, callback);
38 +}
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 _eachOfLimit = require('./eachOfLimit');
8 +
9 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
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|Object} coll - A collection to iterate over.
28 + * @param {Function} iteratee - A function to apply to each item in `coll`. The
29 + * `key` is the item's key, or index in the case of an array. The iteratee is
30 + * passed a `callback(err)` which must be called once it has completed. If no
31 + * error has occurred, the callback should be run without arguments or with an
32 + * explicit `null` argument. Invoked with (item, key, callback).
33 + * @param {Function} [callback] - A callback which is called when all `iteratee`
34 + * functions have finished, or an error occurs. Invoked with (err).
35 + */
36 +exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1);
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 +
7 +var _eachLimit = require('./eachLimit');
8 +
9 +var _eachLimit2 = _interopRequireDefault(_eachLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
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 + * @name eachSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.each]{@link module:Collections.each}
25 + * @alias forEachSeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {Function} iteratee - A function to apply to each
29 + * item in `coll`. The iteratee is passed a `callback(err)` which must be called
30 + * once it has completed. If no error has occurred, the `callback` should be run
31 + * without arguments or with an explicit `null` argument. The array index is
32 + * not passed to the iteratee. Invoked with (item, callback). If you need the
33 + * index, use `eachOfSeries`.
34 + * @param {Function} [callback] - A callback which is called when all
35 + * `iteratee` functions have finished, or an error occurs. Invoked with (err).
36 + */
37 +exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1);
38 +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 _initialParams = require('./internal/initialParams');
13 +
14 +var _initialParams2 = _interopRequireDefault(_initialParams);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Wrap an async function and ensure it calls its callback on a later tick of
20 + * the event loop. If the function already calls its callback on a next tick,
21 + * no extra deferral is added. This is useful for preventing stack overflows
22 + * (`RangeError: Maximum call stack size exceeded`) and generally keeping
23 + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
24 + * contained.
25 + *
26 + * @name ensureAsync
27 + * @static
28 + * @memberOf module:Utils
29 + * @method
30 + * @category Util
31 + * @param {Function} fn - an async function, one that expects a node-style
32 + * callback as its last argument.
33 + * @returns {Function} Returns a wrapped function with the exact same call
34 + * signature as the function passed in.
35 + * @example
36 + *
37 + * function sometimesAsync(arg, callback) {
38 + * if (cache[arg]) {
39 + * return callback(null, cache[arg]); // this would be synchronous!!
40 + * } else {
41 + * doSomeIO(arg, callback); // this IO would be asynchronous
42 + * }
43 + * }
44 + *
45 + * // this has a risk of stack overflows if many results are cached in a row
46 + * async.mapSeries(args, sometimesAsync, done);
47 + *
48 + * // this will defer sometimesAsync's callback if necessary,
49 + * // preventing stack overflows
50 + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
51 + */
52 +function ensureAsync(fn) {
53 + return (0, _initialParams2.default)(function (args, callback) {
54 + var sync = true;
55 + args.push(function () {
56 + var innerArgs = arguments;
57 + if (sync) {
58 + (0, _setImmediate2.default)(function () {
59 + callback.apply(null, innerArgs);
60 + });
61 + } else {
62 + callback.apply(null, innerArgs);
63 + }
64 + });
65 + fn.apply(this, args);
66 + sync = false;
67 + });
68 +}
69 +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 _notId = require('./internal/notId');
16 +
17 +var _notId2 = _interopRequireDefault(_notId);
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|Object} coll - A collection to iterate over.
32 + * @param {Function} iteratee - A truth test to apply to each item in the
33 + * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
34 + * which must be called with a boolean argument once it has completed. Invoked
35 + * 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 + * @example
40 + *
41 + * async.every(['file1','file2','file3'], function(filePath, callback) {
42 + * fs.access(filePath, function(err) {
43 + * callback(null, !err)
44 + * });
45 + * }, function(err, result) {
46 + * // if result is true then every file exists
47 + * });
48 + */
49 +exports.default = (0, _createTester2.default)(_eachOf2.default, _notId2.default, _notId2.default);
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 _createTester = require('./internal/createTester');
8 +
9 +var _createTester2 = _interopRequireDefault(_createTester);
10 +
11 +var _eachOfLimit = require('./eachOfLimit');
12 +
13 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
14 +
15 +var _notId = require('./internal/notId');
16 +
17 +var _notId2 = _interopRequireDefault(_notId);
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|Object} coll - A collection to iterate over.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {Function} iteratee - A truth test to apply to each item in the
34 + * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
35 + * which must be called with a boolean argument once it has completed. Invoked
36 + * 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 + */
41 +exports.default = (0, _createTester2.default)(_eachOfLimit2.default, _notId2.default, _notId2.default);
42 +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 _everyLimit = require('./everyLimit');
8 +
9 +var _everyLimit2 = _interopRequireDefault(_everyLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
19 + *
20 + * @name everySeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.every]{@link module:Collections.every}
25 + * @alias allSeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {Function} iteratee - A truth test to apply to each item in the
29 + * collection in parallel. The iteratee is passed a `callback(err, truthValue)`
30 + * which must be called with a boolean argument once it has completed. Invoked
31 + * with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished. Result will be either `true` or `false`
34 + * depending on the values of the async tests. Invoked with (err, result).
35 + */
36 +exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
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 +
7 +var _filter = require('./internal/filter');
8 +
9 +var _filter2 = _interopRequireDefault(_filter);
10 +
11 +var _doParallel = require('./internal/doParallel');
12 +
13 +var _doParallel2 = _interopRequireDefault(_doParallel);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Returns a new array of all the values in `coll` which pass an async truth
19 + * test. This operation is performed in parallel, but the results array will be
20 + * in the same order as the original.
21 + *
22 + * @name filter
23 + * @static
24 + * @memberOf module:Collections
25 + * @method
26 + * @alias select
27 + * @category Collection
28 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
29 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
30 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
31 + * with a boolean argument once it has completed. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished. Invoked with (err, results).
34 + * @example
35 + *
36 + * async.filter(['file1','file2','file3'], function(filePath, callback) {
37 + * fs.access(filePath, function(err) {
38 + * callback(null, !err)
39 + * });
40 + * }, function(err, results) {
41 + * // results now equals an array of the existing files
42 + * });
43 + */
44 +exports.default = (0, _doParallel2.default)(_filter2.default);
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 _filter = require('./internal/filter');
8 +
9 +var _filter2 = _interopRequireDefault(_filter);
10 +
11 +var _doParallelLimit = require('./internal/doParallelLimit');
12 +
13 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
19 + * time.
20 + *
21 + * @name filterLimit
22 + * @static
23 + * @memberOf module:Collections
24 + * @method
25 + * @see [async.filter]{@link module:Collections.filter}
26 + * @alias selectLimit
27 + * @category Collection
28 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
29 + * @param {number} limit - The maximum number of async operations at a time.
30 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
31 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
32 + * with a boolean argument once it has completed. Invoked with (item, callback).
33 + * @param {Function} [callback] - A callback which is called after all the
34 + * `iteratee` functions have finished. Invoked with (err, results).
35 + */
36 +exports.default = (0, _doParallelLimit2.default)(_filter2.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 +
7 +var _filterLimit = require('./filterLimit');
8 +
9 +var _filterLimit2 = _interopRequireDefault(_filterLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
19 + *
20 + * @name filterSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.filter]{@link module:Collections.filter}
25 + * @alias selectSeries
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
29 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
30 + * with a boolean argument once it has completed. Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called after all the
32 + * `iteratee` functions have finished. Invoked with (err, results)
33 + */
34 +exports.default = (0, _doLimit2.default)(_filterLimit2.default, 1);
35 +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 = forever;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _onlyOnce = require('./internal/onlyOnce');
13 +
14 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
15 +
16 +var _ensureAsync = require('./ensureAsync');
17 +
18 +var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Calls the asynchronous function `fn` with a callback parameter that allows it
24 + * to call itself again, in series, indefinitely.
25 +
26 + * If an error is passed to the
27 + * callback then `errback` is called with the error, and execution stops,
28 + * otherwise it will never be called.
29 + *
30 + * @name forever
31 + * @static
32 + * @memberOf module:ControlFlow
33 + * @method
34 + * @category Control Flow
35 + * @param {Function} fn - a function to call repeatedly. Invoked with (next).
36 + * @param {Function} [errback] - when `fn` passes an error to it's callback,
37 + * this function will be called, and execution stops. Invoked with (err).
38 + * @example
39 + *
40 + * async.forever(
41 + * function(next) {
42 + * // next is suitable for passing to things that need a callback(err [, whatever]);
43 + * // it will result in this function being called again.
44 + * },
45 + * function(err) {
46 + * // if next is called with a value in its first parameter, it will appear
47 + * // in here as 'err', and execution will stop.
48 + * }
49 + * );
50 + */
51 +function forever(fn, errback) {
52 + var done = (0, _onlyOnce2.default)(errback || _noop2.default);
53 + var task = (0, _ensureAsync2.default)(fn);
54 +
55 + function next(err) {
56 + if (err) return done(err);
57 + task(next);
58 + }
59 + next();
60 +}
61 +module.exports = exports['default'];
...\ 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 +exports.default = DLL;
7 +// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
8 +// used for queues. This implementation assumes that the node provided by the user can be modified
9 +// to adjust the next and last properties. We implement only the minimal functionality
10 +// for queue support.
11 +function DLL() {
12 + this.head = this.tail = null;
13 + this.length = 0;
14 +}
15 +
16 +function setInitial(dll, node) {
17 + dll.length = 1;
18 + dll.head = dll.tail = node;
19 +}
20 +
21 +DLL.prototype.removeLink = function (node) {
22 + if (node.prev) node.prev.next = node.next;else this.head = node.next;
23 + if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
24 +
25 + node.prev = node.next = null;
26 + this.length -= 1;
27 + return node;
28 +};
29 +
30 +DLL.prototype.empty = DLL;
31 +
32 +DLL.prototype.insertAfter = function (node, newNode) {
33 + newNode.prev = node;
34 + newNode.next = node.next;
35 + if (node.next) node.next.prev = newNode;else this.tail = newNode;
36 + node.next = newNode;
37 + this.length += 1;
38 +};
39 +
40 +DLL.prototype.insertBefore = function (node, newNode) {
41 + newNode.prev = node.prev;
42 + newNode.next = node;
43 + if (node.prev) node.prev.next = newNode;else this.head = newNode;
44 + node.prev = newNode;
45 + this.length += 1;
46 +};
47 +
48 +DLL.prototype.unshift = function (node) {
49 + if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
50 +};
51 +
52 +DLL.prototype.push = function (node) {
53 + if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
54 +};
55 +
56 +DLL.prototype.shift = function () {
57 + return this.head && this.removeLink(this.head);
58 +};
59 +
60 +DLL.prototype.pop = function () {
61 + return this.tail && this.removeLink(this.tail);
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 = applyEach;
7 +
8 +var _rest = require('./rest');
9 +
10 +var _rest2 = _interopRequireDefault(_rest);
11 +
12 +var _initialParams = require('./initialParams');
13 +
14 +var _initialParams2 = _interopRequireDefault(_initialParams);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function applyEach(eachfn) {
19 + return (0, _rest2.default)(function (fns, args) {
20 + var go = (0, _initialParams2.default)(function (args, callback) {
21 + var that = this;
22 + return eachfn(fns, function (fn, cb) {
23 + fn.apply(that, args.concat([cb]));
24 + }, callback);
25 + });
26 + if (args.length) {
27 + return go.apply(this, args);
28 + } else {
29 + return go;
30 + }
31 + });
32 +}
33 +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 +exports.default = {};
9 +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 = concat;
7 +function concat(eachfn, arr, fn, callback) {
8 + var result = [];
9 + eachfn(arr, function (x, index, cb) {
10 + fn(x, function (err, y) {
11 + result = result.concat(y || []);
12 + cb(err);
13 + });
14 + }, function (err) {
15 + callback(err, result);
16 + });
17 +}
18 +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 _arrayEach = require('lodash/_arrayEach');
9 +
10 +var _arrayEach2 = _interopRequireDefault(_arrayEach);
11 +
12 +var _rest = require('./rest');
13 +
14 +var _rest2 = _interopRequireDefault(_rest);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function consoleFunc(name) {
19 + return (0, _rest2.default)(function (fn, args) {
20 + fn.apply(null, args.concat([(0, _rest2.default)(function (err, args) {
21 + if (typeof console === 'object') {
22 + if (err) {
23 + if (console.error) {
24 + console.error(err);
25 + }
26 + } else if (console[name]) {
27 + (0, _arrayEach2.default)(args, function (x) {
28 + console[name](x);
29 + });
30 + }
31 + }
32 + })]));
33 + });
34 +}
35 +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 _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _breakLoop = require('./breakLoop');
13 +
14 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +function _createTester(eachfn, check, getResult) {
19 + return function (arr, limit, iteratee, cb) {
20 + function done() {
21 + if (cb) {
22 + cb(null, getResult(false));
23 + }
24 + }
25 + function wrappedIteratee(x, _, callback) {
26 + if (!cb) return callback();
27 + iteratee(x, function (err, v) {
28 + // Check cb as another iteratee may have resolved with a
29 + // value or error since we started this iteratee
30 + if (cb && (err || check(v))) {
31 + if (err) cb(err);else cb(err, getResult(true, x));
32 + cb = iteratee = false;
33 + callback(err, _breakLoop2.default);
34 + } else {
35 + callback();
36 + }
37 + });
38 + }
39 + if (arguments.length > 3) {
40 + cb = cb || _noop2.default;
41 + eachfn(arr, limit, wrappedIteratee, done);
42 + } else {
43 + cb = iteratee;
44 + cb = cb || _noop2.default;
45 + iteratee = limit;
46 + eachfn(arr, wrappedIteratee, done);
47 + }
48 + };
49 +}
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 +exports.default = doLimit;
7 +function doLimit(fn, limit) {
8 + return function (iterable, iteratee, callback) {
9 + return fn(iterable, limit, iteratee, callback);
10 + };
11 +}
12 +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 = doParallel;
7 +
8 +var _eachOf = require('../eachOf');
9 +
10 +var _eachOf2 = _interopRequireDefault(_eachOf);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function doParallel(fn) {
15 + return function (obj, iteratee, callback) {
16 + return fn(_eachOf2.default, obj, iteratee, callback);
17 + };
18 +}
19 +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 = doParallelLimit;
7 +
8 +var _eachOfLimit = require('./eachOfLimit');
9 +
10 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function doParallelLimit(fn) {
15 + return function (obj, limit, iteratee, callback) {
16 + return fn((0, _eachOfLimit2.default)(limit), obj, iteratee, callback);
17 + };
18 +}
19 +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 = doSeries;
7 +
8 +var _eachOfSeries = require('../eachOfSeries');
9 +
10 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function doSeries(fn) {
15 + return function (obj, iteratee, callback) {
16 + return fn(_eachOfSeries2.default, obj, iteratee, callback);
17 + };
18 +}
19 +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 = _eachOfLimit;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _once = require('./once');
13 +
14 +var _once2 = _interopRequireDefault(_once);
15 +
16 +var _iterator = require('./iterator');
17 +
18 +var _iterator2 = _interopRequireDefault(_iterator);
19 +
20 +var _onlyOnce = require('./onlyOnce');
21 +
22 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
23 +
24 +var _breakLoop = require('./breakLoop');
25 +
26 +var _breakLoop2 = _interopRequireDefault(_breakLoop);
27 +
28 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29 +
30 +function _eachOfLimit(limit) {
31 + return function (obj, iteratee, callback) {
32 + callback = (0, _once2.default)(callback || _noop2.default);
33 + if (limit <= 0 || !obj) {
34 + return callback(null);
35 + }
36 + var nextElem = (0, _iterator2.default)(obj);
37 + var done = false;
38 + var running = 0;
39 +
40 + function iterateeCallback(err, value) {
41 + running -= 1;
42 + if (err) {
43 + done = true;
44 + callback(err);
45 + } else if (value === _breakLoop2.default || done && running <= 0) {
46 + done = true;
47 + return callback(null);
48 + } else {
49 + replenish();
50 + }
51 + }
52 +
53 + function replenish() {
54 + while (running < limit && !done) {
55 + var elem = nextElem();
56 + if (elem === null) {
57 + done = true;
58 + if (running <= 0) {
59 + callback(null);
60 + }
61 + return;
62 + }
63 + running += 1;
64 + iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
65 + }
66 + }
67 +
68 + replenish();
69 + };
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 = _filter;
7 +
8 +var _arrayMap = require('lodash/_arrayMap');
9 +
10 +var _arrayMap2 = _interopRequireDefault(_arrayMap);
11 +
12 +var _isArrayLike = require('lodash/isArrayLike');
13 +
14 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
15 +
16 +var _baseProperty = require('lodash/_baseProperty');
17 +
18 +var _baseProperty2 = _interopRequireDefault(_baseProperty);
19 +
20 +var _noop = require('lodash/noop');
21 +
22 +var _noop2 = _interopRequireDefault(_noop);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +function filterArray(eachfn, arr, iteratee, callback) {
27 + var truthValues = new Array(arr.length);
28 + eachfn(arr, function (x, index, callback) {
29 + iteratee(x, function (err, v) {
30 + truthValues[index] = !!v;
31 + callback(err);
32 + });
33 + }, function (err) {
34 + if (err) return callback(err);
35 + var results = [];
36 + for (var i = 0; i < arr.length; i++) {
37 + if (truthValues[i]) results.push(arr[i]);
38 + }
39 + callback(null, results);
40 + });
41 +}
42 +
43 +function filterGeneric(eachfn, coll, iteratee, callback) {
44 + var results = [];
45 + eachfn(coll, function (x, index, callback) {
46 + iteratee(x, function (err, v) {
47 + if (err) {
48 + callback(err);
49 + } else {
50 + if (v) {
51 + results.push({ index: index, value: x });
52 + }
53 + callback();
54 + }
55 + });
56 + }, function (err) {
57 + if (err) {
58 + callback(err);
59 + } else {
60 + callback(null, (0, _arrayMap2.default)(results.sort(function (a, b) {
61 + return a.index - b.index;
62 + }), (0, _baseProperty2.default)('value')));
63 + }
64 + });
65 +}
66 +
67 +function _filter(eachfn, coll, iteratee, callback) {
68 + var filter = (0, _isArrayLike2.default)(coll) ? filterArray : filterGeneric;
69 + filter(eachfn, coll, iteratee, callback || _noop2.default);
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 = _findGetResult;
7 +function _findGetResult(v, x) {
8 + return x;
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 +
7 +exports.default = function (coll) {
8 + return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
9 +};
10 +
11 +var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
12 +
13 +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 (0, _rest2.default)(function (args /*..., callback*/) {
9 + var callback = args.pop();
10 + fn.call(this, args, callback);
11 + });
12 +};
13 +
14 +var _rest = require('./rest');
15 +
16 +var _rest2 = _interopRequireDefault(_rest);
17 +
18 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19 +
20 +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 = iterator;
7 +
8 +var _isArrayLike = require('lodash/isArrayLike');
9 +
10 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
11 +
12 +var _getIterator = require('./getIterator');
13 +
14 +var _getIterator2 = _interopRequireDefault(_getIterator);
15 +
16 +var _keys = require('lodash/keys');
17 +
18 +var _keys2 = _interopRequireDefault(_keys);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +function createArrayIterator(coll) {
23 + var i = -1;
24 + var len = coll.length;
25 + return function next() {
26 + return ++i < len ? { value: coll[i], key: i } : null;
27 + };
28 +}
29 +
30 +function createES2015Iterator(iterator) {
31 + var i = -1;
32 + return function next() {
33 + var item = iterator.next();
34 + if (item.done) return null;
35 + i++;
36 + return { value: item.value, key: i };
37 + };
38 +}
39 +
40 +function createObjectIterator(obj) {
41 + var okeys = (0, _keys2.default)(obj);
42 + var i = -1;
43 + var len = okeys.length;
44 + return function next() {
45 + var key = okeys[++i];
46 + return i < len ? { value: obj[key], key: key } : null;
47 + };
48 +}
49 +
50 +function iterator(coll) {
51 + if ((0, _isArrayLike2.default)(coll)) {
52 + return createArrayIterator(coll);
53 + }
54 +
55 + var iterator = (0, _getIterator2.default)(coll);
56 + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
57 +}
58 +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 _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function _asyncMap(eachfn, arr, iteratee, callback) {
15 + callback = callback || _noop2.default;
16 + arr = arr || [];
17 + var results = [];
18 + var counter = 0;
19 +
20 + eachfn(arr, function (value, _, callback) {
21 + var index = counter++;
22 + iteratee(value, function (err, v) {
23 + results[index] = v;
24 + callback(err);
25 + });
26 + }, function (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 = notId;
7 +function notId(v) {
8 + return !v;
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 = once;
7 +function once(fn) {
8 + return function () {
9 + if (fn === null) return;
10 + var callFn = fn;
11 + fn = null;
12 + callFn.apply(this, arguments);
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 +exports.default = onlyOnce;
7 +function onlyOnce(fn) {
8 + return function () {
9 + if (fn === null) throw new Error("Callback was already called.");
10 + var callFn = fn;
11 + fn = null;
12 + callFn.apply(this, arguments);
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 +exports.default = _parallel;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _isArrayLike = require('lodash/isArrayLike');
13 +
14 +var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
15 +
16 +var _rest = require('./rest');
17 +
18 +var _rest2 = _interopRequireDefault(_rest);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +function _parallel(eachfn, tasks, callback) {
23 + callback = callback || _noop2.default;
24 + var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
25 +
26 + eachfn(tasks, function (task, key, callback) {
27 + task((0, _rest2.default)(function (err, args) {
28 + if (args.length <= 1) {
29 + args = args[0];
30 + }
31 + results[key] = args;
32 + callback(err);
33 + }));
34 + }, function (err) {
35 + callback(err, results);
36 + });
37 +}
38 +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 = queue;
7 +
8 +var _baseIndexOf = require('lodash/_baseIndexOf');
9 +
10 +var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
11 +
12 +var _isArray = require('lodash/isArray');
13 +
14 +var _isArray2 = _interopRequireDefault(_isArray);
15 +
16 +var _noop = require('lodash/noop');
17 +
18 +var _noop2 = _interopRequireDefault(_noop);
19 +
20 +var _rest = require('./rest');
21 +
22 +var _rest2 = _interopRequireDefault(_rest);
23 +
24 +var _onlyOnce = require('./onlyOnce');
25 +
26 +var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
27 +
28 +var _setImmediate = require('./setImmediate');
29 +
30 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
31 +
32 +var _DoublyLinkedList = require('./DoublyLinkedList');
33 +
34 +var _DoublyLinkedList2 = _interopRequireDefault(_DoublyLinkedList);
35 +
36 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37 +
38 +function queue(worker, concurrency, payload) {
39 + if (concurrency == null) {
40 + concurrency = 1;
41 + } else if (concurrency === 0) {
42 + throw new Error('Concurrency must not be zero');
43 + }
44 +
45 + function _insert(data, insertAtFront, callback) {
46 + if (callback != null && typeof callback !== 'function') {
47 + throw new Error('task callback must be a function');
48 + }
49 + q.started = true;
50 + if (!(0, _isArray2.default)(data)) {
51 + data = [data];
52 + }
53 + if (data.length === 0 && q.idle()) {
54 + // call drain immediately if there are no tasks
55 + return (0, _setImmediate2.default)(function () {
56 + q.drain();
57 + });
58 + }
59 +
60 + for (var i = 0, l = data.length; i < l; i++) {
61 + var item = {
62 + data: data[i],
63 + callback: callback || _noop2.default
64 + };
65 +
66 + if (insertAtFront) {
67 + q._tasks.unshift(item);
68 + } else {
69 + q._tasks.push(item);
70 + }
71 + }
72 + (0, _setImmediate2.default)(q.process);
73 + }
74 +
75 + function _next(tasks) {
76 + return (0, _rest2.default)(function (args) {
77 + workers -= 1;
78 +
79 + for (var i = 0, l = tasks.length; i < l; i++) {
80 + var task = tasks[i];
81 + var index = (0, _baseIndexOf2.default)(workersList, task, 0);
82 + if (index >= 0) {
83 + workersList.splice(index);
84 + }
85 +
86 + task.callback.apply(task, args);
87 +
88 + if (args[0] != null) {
89 + q.error(args[0], task.data);
90 + }
91 + }
92 +
93 + if (workers <= q.concurrency - q.buffer) {
94 + q.unsaturated();
95 + }
96 +
97 + if (q.idle()) {
98 + q.drain();
99 + }
100 + q.process();
101 + });
102 + }
103 +
104 + var workers = 0;
105 + var workersList = [];
106 + var q = {
107 + _tasks: new _DoublyLinkedList2.default(),
108 + concurrency: concurrency,
109 + payload: payload,
110 + saturated: _noop2.default,
111 + unsaturated: _noop2.default,
112 + buffer: concurrency / 4,
113 + empty: _noop2.default,
114 + drain: _noop2.default,
115 + error: _noop2.default,
116 + started: false,
117 + paused: false,
118 + push: function (data, callback) {
119 + _insert(data, false, callback);
120 + },
121 + kill: function () {
122 + q.drain = _noop2.default;
123 + q._tasks.empty();
124 + },
125 + unshift: function (data, callback) {
126 + _insert(data, true, callback);
127 + },
128 + process: function () {
129 + while (!q.paused && workers < q.concurrency && q._tasks.length) {
130 + var tasks = [],
131 + data = [];
132 + var l = q._tasks.length;
133 + if (q.payload) l = Math.min(l, q.payload);
134 + for (var i = 0; i < l; i++) {
135 + var node = q._tasks.shift();
136 + tasks.push(node);
137 + data.push(node.data);
138 + }
139 +
140 + if (q._tasks.length === 0) {
141 + q.empty();
142 + }
143 + workers += 1;
144 + workersList.push(tasks[0]);
145 +
146 + if (workers === q.concurrency) {
147 + q.saturated();
148 + }
149 +
150 + var cb = (0, _onlyOnce2.default)(_next(tasks));
151 + worker(data, cb);
152 + }
153 + },
154 + length: function () {
155 + return q._tasks.length;
156 + },
157 + running: function () {
158 + return workers;
159 + },
160 + workersList: function () {
161 + return workersList;
162 + },
163 + idle: function () {
164 + return q._tasks.length + workers === 0;
165 + },
166 + pause: function () {
167 + q.paused = true;
168 + },
169 + resume: function () {
170 + if (q.paused === false) {
171 + return;
172 + }
173 + q.paused = false;
174 + var resumeCount = Math.min(q.concurrency, q._tasks.length);
175 + // Need to call q.process once per concurrent
176 + // worker to preserve full concurrency after pause
177 + for (var w = 1; w <= resumeCount; w++) {
178 + (0, _setImmediate2.default)(q.process);
179 + }
180 + }
181 + };
182 + return q;
183 +}
184 +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 = reject;
7 +
8 +var _filter = require('./filter');
9 +
10 +var _filter2 = _interopRequireDefault(_filter);
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +function reject(eachfn, arr, iteratee, callback) {
15 + (0, _filter2.default)(eachfn, arr, function (value, cb) {
16 + iteratee(value, function (err, v) {
17 + cb(err, !v);
18 + });
19 + }, callback);
20 +}
21 +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 = rest;
7 +
8 +var _overRest2 = require('lodash/_overRest');
9 +
10 +var _overRest3 = _interopRequireDefault(_overRest2);
11 +
12 +var _identity = require('lodash/identity');
13 +
14 +var _identity2 = _interopRequireDefault(_identity);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +// Lodash rest function without function.toString()
19 +// remappings
20 +function rest(func, start) {
21 + return (0, _overRest3.default)(func, start, _identity2.default);
22 +}
23 +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.hasNextTick = exports.hasSetImmediate = undefined;
7 +exports.fallback = fallback;
8 +exports.wrap = wrap;
9 +
10 +var _rest = require('./rest');
11 +
12 +var _rest2 = _interopRequireDefault(_rest);
13 +
14 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15 +
16 +var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
17 +var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
18 +
19 +function fallback(fn) {
20 + setTimeout(fn, 0);
21 +}
22 +
23 +function wrap(defer) {
24 + return (0, _rest2.default)(function (fn, args) {
25 + defer(function () {
26 + fn.apply(null, args);
27 + });
28 + });
29 +}
30 +
31 +var _defer;
32 +
33 +if (hasSetImmediate) {
34 + _defer = setImmediate;
35 +} else if (hasNextTick) {
36 + _defer = process.nextTick;
37 +} else {
38 + _defer = fallback;
39 +}
40 +
41 +exports.default = wrap(_defer);
...\ 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 = _withoutIndex;
7 +function _withoutIndex(iteratee) {
8 + return function (value, index, callback) {
9 + return iteratee(value, callback);
10 + };
11 +}
12 +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 to the `console`. Only works in
15 + * Node.js or in browsers that support `console.log` and `console.error` (such
16 + * as FF and Chrome). If multiple arguments are returned from the async
17 + * function, `console.log` is called on each argument in order.
18 + *
19 + * @name log
20 + * @static
21 + * @memberOf module:Utils
22 + * @method
23 + * @category Util
24 + * @param {Function} function - The function you want to eventually apply all
25 + * arguments to.
26 + * @param {...*} arguments... - Any number of arguments to apply to the function.
27 + * @example
28 + *
29 + * // in a module
30 + * var hello = function(name, callback) {
31 + * setTimeout(function() {
32 + * callback(null, 'hello ' + name);
33 + * }, 1000);
34 + * };
35 + *
36 + * // in the node repl
37 + * node> async.log(hello, 'world');
38 + * 'hello world'
39 + */
40 +exports.default = (0, _consoleFunc2.default)('log');
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 _doParallel = require('./internal/doParallel');
8 +
9 +var _doParallel2 = _interopRequireDefault(_doParallel);
10 +
11 +var _map = require('./internal/map');
12 +
13 +var _map2 = _interopRequireDefault(_map);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * Produces a new collection of values by mapping each value in `coll` through
19 + * the `iteratee` function. The `iteratee` is called with an item from `coll`
20 + * and a callback for when it has finished processing. Each of these callback
21 + * takes 2 arguments: an `error`, and the transformed item from `coll`. If
22 + * `iteratee` passes an error to its callback, the main `callback` (for the
23 + * `map` function) is immediately called with the error.
24 + *
25 + * Note, that since this function applies the `iteratee` to each item in
26 + * parallel, there is no guarantee that the `iteratee` functions will complete
27 + * in order. However, the results array will be in the same order as the
28 + * original `coll`.
29 + *
30 + * If `map` is passed an Object, the results will be an Array. The results
31 + * will roughly be in the order of the original Objects' keys (but this can
32 + * vary across JavaScript engines)
33 + *
34 + * @name map
35 + * @static
36 + * @memberOf module:Collections
37 + * @method
38 + * @category Collection
39 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
40 + * @param {Function} iteratee - A function to apply to each item in `coll`.
41 + * The iteratee is passed a `callback(err, transformed)` which must be called
42 + * once it has completed with an error (which can be `null`) and a
43 + * transformed item. Invoked with (item, callback).
44 + * @param {Function} [callback] - A callback which is called when all `iteratee`
45 + * functions have finished, or an error occurs. Results is an Array of the
46 + * transformed items from the `coll`. Invoked with (err, results).
47 + * @example
48 + *
49 + * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
50 + * // results is now an array of stats for each file
51 + * });
52 + */
53 +exports.default = (0, _doParallel2.default)(_map2.default);
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 _doParallelLimit = require('./internal/doParallelLimit');
8 +
9 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
10 +
11 +var _map = require('./internal/map');
12 +
13 +var _map2 = _interopRequireDefault(_map);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
19 + *
20 + * @name mapLimit
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.map]{@link module:Collections.map}
25 + * @category Collection
26 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {number} limit - The maximum number of async operations at a time.
28 + * @param {Function} iteratee - A function to apply to each item in `coll`.
29 + * The iteratee is passed a `callback(err, transformed)` which must be called
30 + * once it has completed with an error (which can be `null`) and a transformed
31 + * item. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called when all `iteratee`
33 + * functions have finished, or an error occurs. Results is an array of the
34 + * transformed items from the `coll`. Invoked with (err, results).
35 + */
36 +exports.default = (0, _doParallelLimit2.default)(_map2.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 +
7 +var _mapLimit = require('./mapLimit');
8 +
9 +var _mapLimit2 = _interopRequireDefault(_mapLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
19 + *
20 + * @name mapSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.map]{@link module:Collections.map}
25 + * @category Collection
26 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {Function} iteratee - A function to apply to each item in `coll`.
28 + * The iteratee is passed a `callback(err, transformed)` which must be called
29 + * once it has completed with an error (which can be `null`) and a
30 + * transformed item. Invoked with (item, callback).
31 + * @param {Function} [callback] - A callback which is called when all `iteratee`
32 + * functions have finished, or an error occurs. Results is an array of the
33 + * transformed items from the `coll`. Invoked with (err, results).
34 + */
35 +exports.default = (0, _doLimit2.default)(_mapLimit2.default, 1);
36 +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 _mapValuesLimit = require('./mapValuesLimit');
8 +
9 +var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
19 + *
20 + * Produces a new Object by mapping each value of `obj` through the `iteratee`
21 + * function. The `iteratee` is called each `value` and `key` from `obj` and a
22 + * callback for when it has finished processing. Each of these callbacks takes
23 + * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
24 + * passes an error to its callback, the main `callback` (for the `mapValues`
25 + * function) is immediately called with the error.
26 + *
27 + * Note, the order of the keys in the result is not guaranteed. The keys will
28 + * be roughly in the order they complete, (but this is very engine-specific)
29 + *
30 + * @name mapValues
31 + * @static
32 + * @memberOf module:Collections
33 + * @method
34 + * @category Collection
35 + * @param {Object} obj - A collection to iterate over.
36 + * @param {Function} iteratee - A function to apply to each value and key in
37 + * `coll`. The iteratee is passed a `callback(err, transformed)` which must be
38 + * called once it has completed with an error (which can be `null`) and a
39 + * transformed value. Invoked with (value, key, callback).
40 + * @param {Function} [callback] - A callback which is called when all `iteratee`
41 + * functions have finished, or an error occurs. `result` is a new object consisting
42 + * of each key from `obj`, with each transformed value on the right-hand side.
43 + * Invoked with (err, result).
44 + * @example
45 + *
46 + * async.mapValues({
47 + * f1: 'file1',
48 + * f2: 'file2',
49 + * f3: 'file3'
50 + * }, function (file, key, callback) {
51 + * fs.stat(file, callback);
52 + * }, function(err, result) {
53 + * // result is now a map of stats for each file, e.g.
54 + * // {
55 + * // f1: [stats for file1],
56 + * // f2: [stats for file2],
57 + * // f3: [stats for file3]
58 + * // }
59 + * });
60 + */
61 +
62 +exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, Infinity);
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 = mapValuesLimit;
7 +
8 +var _eachOfLimit = require('./eachOfLimit');
9 +
10 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
11 +
12 +var _noop = require('lodash/noop');
13 +
14 +var _noop2 = _interopRequireDefault(_noop);
15 +
16 +var _once = require('./internal/once');
17 +
18 +var _once2 = _interopRequireDefault(_once);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
24 + * time.
25 + *
26 + * @name mapValuesLimit
27 + * @static
28 + * @memberOf module:Collections
29 + * @method
30 + * @see [async.mapValues]{@link module:Collections.mapValues}
31 + * @category Collection
32 + * @param {Object} obj - A collection to iterate over.
33 + * @param {number} limit - The maximum number of async operations at a time.
34 + * @param {Function} iteratee - A function to apply to each value in `obj`.
35 + * The iteratee is passed a `callback(err, transformed)` which must be called
36 + * once it has completed with an error (which can be `null`) and a
37 + * transformed value. Invoked with (value, key, callback).
38 + * @param {Function} [callback] - A callback which is called when all `iteratee`
39 + * functions have finished, or an error occurs. `result` is a new object consisting
40 + * of each key from `obj`, with each transformed value on the right-hand side.
41 + * Invoked with (err, result).
42 + */
43 +function mapValuesLimit(obj, limit, iteratee, callback) {
44 + callback = (0, _once2.default)(callback || _noop2.default);
45 + var newObj = {};
46 + (0, _eachOfLimit2.default)(obj, limit, function (val, key, next) {
47 + iteratee(val, key, function (err, result) {
48 + if (err) return next(err);
49 + newObj[key] = result;
50 + next();
51 + });
52 + }, function (err) {
53 + callback(err, newObj);
54 + });
55 +}
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 _mapValuesLimit = require('./mapValuesLimit');
8 +
9 +var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
19 + *
20 + * @name mapValuesSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.mapValues]{@link module:Collections.mapValues}
25 + * @category Collection
26 + * @param {Object} obj - A collection to iterate over.
27 + * @param {Function} iteratee - A function to apply to each value in `obj`.
28 + * The iteratee is passed a `callback(err, transformed)` which must be called
29 + * once it has completed with an error (which can be `null`) and a
30 + * transformed value. Invoked with (value, key, callback).
31 + * @param {Function} [callback] - A callback which is called when all `iteratee`
32 + * functions have finished, or an error occurs. `result` is a new object consisting
33 + * of each key from `obj`, with each transformed value on the right-hand side.
34 + * Invoked with (err, result).
35 + */
36 +exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, 1);
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 = memoize;
7 +
8 +var _identity = require('lodash/identity');
9 +
10 +var _identity2 = _interopRequireDefault(_identity);
11 +
12 +var _rest = require('./internal/rest');
13 +
14 +var _rest2 = _interopRequireDefault(_rest);
15 +
16 +var _setImmediate = require('./internal/setImmediate');
17 +
18 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
19 +
20 +var _initialParams = require('./internal/initialParams');
21 +
22 +var _initialParams2 = _interopRequireDefault(_initialParams);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +function has(obj, key) {
27 + return key in obj;
28 +}
29 +
30 +/**
31 + * Caches the results of an `async` function. When creating a hash to store
32 + * function results against, the callback is omitted from the hash and an
33 + * optional hash function can be used.
34 + *
35 + * If no hash function is specified, the first argument is used as a hash key,
36 + * which may work reasonably if it is a string or a data type that converts to a
37 + * distinct string. Note that objects and arrays will not behave reasonably.
38 + * Neither will cases where the other arguments are significant. In such cases,
39 + * specify your own hash function.
40 + *
41 + * The cache of results is exposed as the `memo` property of the function
42 + * returned by `memoize`.
43 + *
44 + * @name memoize
45 + * @static
46 + * @memberOf module:Utils
47 + * @method
48 + * @category Util
49 + * @param {Function} fn - The function to proxy and cache results from.
50 + * @param {Function} hasher - An optional function for generating a custom hash
51 + * for storing results. It has all the arguments applied to it apart from the
52 + * callback, and must be synchronous.
53 + * @returns {Function} a memoized version of `fn`
54 + * @example
55 + *
56 + * var slow_fn = function(name, callback) {
57 + * // do something
58 + * callback(null, result);
59 + * };
60 + * var fn = async.memoize(slow_fn);
61 + *
62 + * // fn can now be used as if it were slow_fn
63 + * fn('some name', function() {
64 + * // callback
65 + * });
66 + */
67 +function memoize(fn, hasher) {
68 + var memo = Object.create(null);
69 + var queues = Object.create(null);
70 + hasher = hasher || _identity2.default;
71 + var memoized = (0, _initialParams2.default)(function memoized(args, callback) {
72 + var key = hasher.apply(null, args);
73 + if (has(memo, key)) {
74 + (0, _setImmediate2.default)(function () {
75 + callback.apply(null, memo[key]);
76 + });
77 + } else if (has(queues, key)) {
78 + queues[key].push(callback);
79 + } else {
80 + queues[key] = [callback];
81 + fn.apply(null, args.concat([(0, _rest2.default)(function (args) {
82 + memo[key] = args;
83 + var q = queues[key];
84 + delete queues[key];
85 + for (var i = 0, l = q.length; i < l; i++) {
86 + q[i].apply(null, args);
87 + }
88 + })]));
89 + }
90 + });
91 + memoized.memo = memo;
92 + memoized.unmemoized = fn;
93 + return memoized;
94 +}
95 +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 _setImmediate = require('./internal/setImmediate');
8 +
9 +/**
10 + * Calls `callback` on a later loop around the event loop. In Node.js this just
11 + * calls `setImmediate`. In the browser it will use `setImmediate` if
12 + * available, otherwise `setTimeout(callback, 0)`, which means other higher
13 + * priority events may precede the execution of `callback`.
14 + *
15 + * This is used internally for browser-compatibility purposes.
16 + *
17 + * @name nextTick
18 + * @static
19 + * @memberOf module:Utils
20 + * @method
21 + * @alias setImmediate
22 + * @category Util
23 + * @param {Function} callback - The function to call on a later loop around
24 + * the event loop. Invoked with (args...).
25 + * @param {...*} args... - any number of additional arguments to pass to the
26 + * callback on the next tick.
27 + * @example
28 + *
29 + * var call_order = [];
30 + * async.nextTick(function() {
31 + * call_order.push('two');
32 + * // call_order now equals ['one','two']
33 + * });
34 + * call_order.push('one');
35 + *
36 + * async.setImmediate(function (a, b, c) {
37 + * // a, b, and c equal 1, 2, and 3
38 + * }, 1, 2, 3);
39 + */
40 +var _defer;
41 +
42 +if (_setImmediate.hasNextTick) {
43 + _defer = process.nextTick;
44 +} else if (_setImmediate.hasSetImmediate) {
45 + _defer = setImmediate;
46 +} else {
47 + _defer = _setImmediate.fallback;
48 +}
49 +
50 +exports.default = (0, _setImmediate.wrap)(_defer);
51 +module.exports = exports['default'];
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "_from": "async@2.1.4",
3 + "_id": "async@2.1.4",
4 + "_inBundle": false,
5 + "_integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
6 + "_location": "/async",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "async@2.1.4",
12 + "name": "async",
13 + "escapedName": "async",
14 + "rawSpec": "2.1.4",
15 + "saveSpec": null,
16 + "fetchSpec": "2.1.4"
17 + },
18 + "_requiredBy": [
19 + "/mongoose"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
22 + "_shasum": "2d2160c7788032e4dd6cbe2502f1f9a2c8f6cde4",
23 + "_spec": "async@2.1.4",
24 + "_where": "/Users/jeminlee/git-projects/node-practice/npm-demo/node_modules/mongoose",
25 + "author": {
26 + "name": "Caolan McMahon"
27 + },
28 + "bugs": {
29 + "url": "https://github.com/caolan/async/issues"
30 + },
31 + "bundleDependencies": false,
32 + "dependencies": {
33 + "lodash": "^4.14.0"
34 + },
35 + "deprecated": false,
36 + "description": "Higher-order functions and common patterns for asynchronous code",
37 + "devDependencies": {
38 + "babel-cli": "^6.16.0",
39 + "babel-core": "^6.3.26",
40 + "babel-plugin-add-module-exports": "^0.2.1",
41 + "babel-plugin-istanbul": "^2.0.1",
42 + "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16",
43 + "babel-preset-es2015": "^6.3.13",
44 + "babelify": "^7.2.0",
45 + "benchmark": "^2.1.1",
46 + "bluebird": "^3.4.6",
47 + "chai": "^3.1.0",
48 + "cheerio": "^0.22.0",
49 + "coveralls": "^2.11.2",
50 + "es6-promise": "^2.3.0",
51 + "eslint": "^2.13.1",
52 + "fs-extra": "^0.26.7",
53 + "gh-pages-deploy": "^0.4.2",
54 + "jsdoc": "^3.4.0",
55 + "karma": "^1.3.0",
56 + "karma-browserify": "^5.1.0",
57 + "karma-firefox-launcher": "^1.0.0",
58 + "karma-mocha": "^1.2.0",
59 + "karma-mocha-reporter": "^2.2.0",
60 + "mocha": "^3.1.2",
61 + "native-promise-only": "^0.8.0-a",
62 + "nyc": "^7.0.0",
63 + "recursive-readdir": "^1.3.0",
64 + "rimraf": "^2.5.0",
65 + "rollup": "^0.36.3",
66 + "rollup-plugin-node-resolve": "^2.0.0",
67 + "rollup-plugin-npm": "^2.0.0",
68 + "rsvp": "^3.0.18",
69 + "semver": "^4.3.6",
70 + "uglify-js": "~2.7.3",
71 + "vinyl-buffer": "^1.0.0",
72 + "vinyl-source-stream": "^1.1.0",
73 + "watchify": "^3.7.0",
74 + "yargs": "~3.9.1"
75 + },
76 + "gh-pages-deploy": {
77 + "staticpath": "docs"
78 + },
79 + "homepage": "https://github.com/caolan/async#readme",
80 + "keywords": [
81 + "async",
82 + "callback",
83 + "module",
84 + "utility"
85 + ],
86 + "license": "MIT",
87 + "main": "dist/async.js",
88 + "name": "async",
89 + "nyc": {
90 + "exclude": [
91 + "mocha_test"
92 + ]
93 + },
94 + "repository": {
95 + "type": "git",
96 + "url": "git+https://github.com/caolan/async.git"
97 + },
98 + "scripts": {
99 + "coverage": "nyc npm run mocha-node-test -- --grep @nycinvalid --invert",
100 + "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
101 + "jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js",
102 + "lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/build/ support/*.js karma.conf.js",
103 + "mocha-browser-test": "karma start",
104 + "mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
105 + "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
106 + "test": "npm run lint && npm run mocha-node-test"
107 + },
108 + "version": "2.1.4"
109 +}
1 +'use strict';
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = parallelLimit;
7 +
8 +var _eachOf = require('./eachOf');
9 +
10 +var _eachOf2 = _interopRequireDefault(_eachOf);
11 +
12 +var _parallel = require('./internal/parallel');
13 +
14 +var _parallel2 = _interopRequireDefault(_parallel);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Run the `tasks` collection of functions in parallel, without waiting until
20 + * the previous function has completed. If any of the functions pass an error to
21 + * its callback, the main `callback` is immediately called with the value of the
22 + * error. Once the `tasks` have completed, the results are passed to the final
23 + * `callback` as an array.
24 + *
25 + * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
26 + * parallel execution of code. If your tasks do not use any timers or perform
27 + * any I/O, they will actually be executed in series. Any synchronous setup
28 + * sections for each task will happen one after the other. JavaScript remains
29 + * single-threaded.
30 + *
31 + * It is also possible to use an object instead of an array. Each property will
32 + * be run as a function and the results will be passed to the final `callback`
33 + * as an object instead of an array. This can be a more readable way of handling
34 + * results from {@link async.parallel}.
35 + *
36 + * @name parallel
37 + * @static
38 + * @memberOf module:ControlFlow
39 + * @method
40 + * @category Control Flow
41 + * @param {Array|Iterable|Object} tasks - A collection containing functions to run.
42 + * Each function is passed a `callback(err, result)` which it must call on
43 + * completion with an error `err` (which can be `null`) and an optional `result`
44 + * value.
45 + * @param {Function} [callback] - An optional callback to run once all the
46 + * functions have completed successfully. This function gets a results array
47 + * (or object) containing all the result arguments passed to the task callbacks.
48 + * Invoked with (err, results).
49 + * @example
50 + * async.parallel([
51 + * function(callback) {
52 + * setTimeout(function() {
53 + * callback(null, 'one');
54 + * }, 200);
55 + * },
56 + * function(callback) {
57 + * setTimeout(function() {
58 + * callback(null, 'two');
59 + * }, 100);
60 + * }
61 + * ],
62 + * // optional callback
63 + * function(err, results) {
64 + * // the results array will equal ['one','two'] even though
65 + * // the second function had a shorter timeout.
66 + * });
67 + *
68 + * // an example using an object instead of an array
69 + * async.parallel({
70 + * one: function(callback) {
71 + * setTimeout(function() {
72 + * callback(null, 1);
73 + * }, 200);
74 + * },
75 + * two: function(callback) {
76 + * setTimeout(function() {
77 + * callback(null, 2);
78 + * }, 100);
79 + * }
80 + * }, function(err, results) {
81 + * // results is now equals to: {one: 1, two: 2}
82 + * });
83 + */
84 +function parallelLimit(tasks, callback) {
85 + (0, _parallel2.default)(_eachOf2.default, tasks, callback);
86 +}
87 +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 = parallelLimit;
7 +
8 +var _eachOfLimit = require('./internal/eachOfLimit');
9 +
10 +var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
11 +
12 +var _parallel = require('./internal/parallel');
13 +
14 +var _parallel2 = _interopRequireDefault(_parallel);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
20 + * time.
21 + *
22 + * @name parallelLimit
23 + * @static
24 + * @memberOf module:ControlFlow
25 + * @method
26 + * @see [async.parallel]{@link module:ControlFlow.parallel}
27 + * @category Control Flow
28 + * @param {Array|Collection} tasks - A collection containing functions to run.
29 + * Each function is passed a `callback(err, result)` which it must call on
30 + * completion with an error `err` (which can be `null`) and an optional `result`
31 + * value.
32 + * @param {number} limit - The maximum number of async operations at a time.
33 + * @param {Function} [callback] - An optional callback to run once all the
34 + * functions have completed successfully. This function gets a results array
35 + * (or object) containing all the result arguments passed to the task callbacks.
36 + * Invoked with (err, results).
37 + */
38 +function parallelLimit(tasks, limit, callback) {
39 + (0, _parallel2.default)((0, _eachOfLimit2.default)(limit), tasks, 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 +exports.default = function (worker, concurrency) {
8 + // Start with a normal queue
9 + var q = (0, _queue2.default)(worker, concurrency);
10 +
11 + // Override push to accept second parameter representing priority
12 + q.push = function (data, priority, callback) {
13 + if (callback == null) callback = _noop2.default;
14 + if (typeof callback !== 'function') {
15 + throw new Error('task callback must be a function');
16 + }
17 + q.started = true;
18 + if (!(0, _isArray2.default)(data)) {
19 + data = [data];
20 + }
21 + if (data.length === 0) {
22 + // call drain immediately if there are no tasks
23 + return (0, _setImmediate2.default)(function () {
24 + q.drain();
25 + });
26 + }
27 +
28 + priority = priority || 0;
29 + var nextNode = q._tasks.head;
30 + while (nextNode && priority >= nextNode.priority) {
31 + nextNode = nextNode.next;
32 + }
33 +
34 + for (var i = 0, l = data.length; i < l; i++) {
35 + var item = {
36 + data: data[i],
37 + priority: priority,
38 + callback: callback
39 + };
40 +
41 + if (nextNode) {
42 + q._tasks.insertBefore(nextNode, item);
43 + } else {
44 + q._tasks.push(item);
45 + }
46 + }
47 + (0, _setImmediate2.default)(q.process);
48 + };
49 +
50 + // Remove unshift function
51 + delete q.unshift;
52 +
53 + return q;
54 +};
55 +
56 +var _isArray = require('lodash/isArray');
57 +
58 +var _isArray2 = _interopRequireDefault(_isArray);
59 +
60 +var _noop = require('lodash/noop');
61 +
62 +var _noop2 = _interopRequireDefault(_noop);
63 +
64 +var _setImmediate = require('./setImmediate');
65 +
66 +var _setImmediate2 = _interopRequireDefault(_setImmediate);
67 +
68 +var _queue = require('./queue');
69 +
70 +var _queue2 = _interopRequireDefault(_queue);
71 +
72 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
73 +
74 +module.exports = exports['default'];
75 +
76 +/**
77 + * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
78 + * completed in ascending priority order.
79 + *
80 + * @name priorityQueue
81 + * @static
82 + * @memberOf module:ControlFlow
83 + * @method
84 + * @see [async.queue]{@link module:ControlFlow.queue}
85 + * @category Control Flow
86 + * @param {Function} worker - An asynchronous function for processing a queued
87 + * task, which must call its `callback(err)` argument when finished, with an
88 + * optional `error` as an argument. If you want to handle errors from an
89 + * individual task, pass a callback to `q.push()`. Invoked with
90 + * (task, callback).
91 + * @param {number} concurrency - An `integer` for determining how many `worker`
92 + * functions should be run in parallel. If omitted, the concurrency defaults to
93 + * `1`. If the concurrency is `0`, an error is thrown.
94 + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
95 + * differences between `queue` and `priorityQueue` objects:
96 + * * `push(task, priority, [callback])` - `priority` should be a number. If an
97 + * array of `tasks` is given, all tasks will be assigned the same priority.
98 + * * The `unshift` method was removed.
99 + */
...\ 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 (worker, concurrency) {
8 + return (0, _queue2.default)(function (items, cb) {
9 + worker(items[0], cb);
10 + }, concurrency, 1);
11 +};
12 +
13 +var _queue = require('./internal/queue');
14 +
15 +var _queue2 = _interopRequireDefault(_queue);
16 +
17 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18 +
19 +module.exports = exports['default'];
20 +
21 +/**
22 + * A queue of tasks for the worker function to complete.
23 + * @typedef {Object} QueueObject
24 + * @memberOf module:ControlFlow
25 + * @property {Function} length - a function returning the number of items
26 + * waiting to be processed. Invoke with `queue.length()`.
27 + * @property {boolean} started - a boolean indicating whether or not any
28 + * items have been pushed and processed by the queue.
29 + * @property {Function} running - a function returning the number of items
30 + * currently being processed. Invoke with `queue.running()`.
31 + * @property {Function} workersList - a function returning the array of items
32 + * currently being processed. Invoke with `queue.workersList()`.
33 + * @property {Function} idle - a function returning false if there are items
34 + * waiting or being processed, or true if not. Invoke with `queue.idle()`.
35 + * @property {number} concurrency - an integer for determining how many `worker`
36 + * functions should be run in parallel. This property can be changed after a
37 + * `queue` is created to alter the concurrency on-the-fly.
38 + * @property {Function} push - add a new task to the `queue`. Calls `callback`
39 + * once the `worker` has finished processing the task. Instead of a single task,
40 + * a `tasks` array can be submitted. The respective callback is used for every
41 + * task in the list. Invoke with `queue.push(task, [callback])`,
42 + * @property {Function} unshift - add a new task to the front of the `queue`.
43 + * Invoke with `queue.unshift(task, [callback])`.
44 + * @property {Function} saturated - a callback that is called when the number of
45 + * running workers hits the `concurrency` limit, and further tasks will be
46 + * queued.
47 + * @property {Function} unsaturated - a callback that is called when the number
48 + * of running workers is less than the `concurrency` & `buffer` limits, and
49 + * further tasks will not be queued.
50 + * @property {number} buffer - A minimum threshold buffer in order to say that
51 + * the `queue` is `unsaturated`.
52 + * @property {Function} empty - a callback that is called when the last item
53 + * from the `queue` is given to a `worker`.
54 + * @property {Function} drain - a callback that is called when the last item
55 + * from the `queue` has returned from the `worker`.
56 + * @property {Function} error - a callback that is called when a task errors.
57 + * Has the signature `function(error, task)`.
58 + * @property {boolean} paused - a boolean for determining whether the queue is
59 + * in a paused state.
60 + * @property {Function} pause - a function that pauses the processing of tasks
61 + * until `resume()` is called. Invoke with `queue.pause()`.
62 + * @property {Function} resume - a function that resumes the processing of
63 + * queued tasks when the queue is paused. Invoke with `queue.resume()`.
64 + * @property {Function} kill - a function that removes the `drain` callback and
65 + * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
66 + */
67 +
68 +/**
69 + * Creates a `queue` object with the specified `concurrency`. Tasks added to the
70 + * `queue` are processed in parallel (up to the `concurrency` limit). If all
71 + * `worker`s are in progress, the task is queued until one becomes available.
72 + * Once a `worker` completes a `task`, that `task`'s callback is called.
73 + *
74 + * @name queue
75 + * @static
76 + * @memberOf module:ControlFlow
77 + * @method
78 + * @category Control Flow
79 + * @param {Function} worker - An asynchronous function for processing a queued
80 + * task, which must call its `callback(err)` argument when finished, with an
81 + * optional `error` as an argument. If you want to handle errors from an
82 + * individual task, pass a callback to `q.push()`. Invoked with
83 + * (task, callback).
84 + * @param {number} [concurrency=1] - An `integer` for determining how many
85 + * `worker` functions should be run in parallel. If omitted, the concurrency
86 + * defaults to `1`. If the concurrency is `0`, an error is thrown.
87 + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
88 + * attached as certain properties to listen for specific events during the
89 + * lifecycle of the queue.
90 + * @example
91 + *
92 + * // create a queue object with concurrency 2
93 + * var q = async.queue(function(task, callback) {
94 + * console.log('hello ' + task.name);
95 + * callback();
96 + * }, 2);
97 + *
98 + * // assign a callback
99 + * q.drain = function() {
100 + * console.log('all items have been processed');
101 + * };
102 + *
103 + * // add some items to the queue
104 + * q.push({name: 'foo'}, function(err) {
105 + * console.log('finished processing foo');
106 + * });
107 + * q.push({name: 'bar'}, function (err) {
108 + * console.log('finished processing bar');
109 + * });
110 + *
111 + * // add some items to the queue (batch-wise)
112 + * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
113 + * console.log('finished processing item');
114 + * });
115 + *
116 + * // add some items to the front of the queue
117 + * q.unshift({name: 'bar'}, function (err) {
118 + * console.log('finished processing bar');
119 + * });
120 + */
...\ 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 = race;
7 +
8 +var _isArray = require('lodash/isArray');
9 +
10 +var _isArray2 = _interopRequireDefault(_isArray);
11 +
12 +var _noop = require('lodash/noop');
13 +
14 +var _noop2 = _interopRequireDefault(_noop);
15 +
16 +var _once = require('./internal/once');
17 +
18 +var _once2 = _interopRequireDefault(_once);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Runs the `tasks` array of functions in parallel, without waiting until the
24 + * previous function has completed. Once any of the `tasks` complete or pass an
25 + * error to its callback, the main `callback` is immediately called. It's
26 + * equivalent to `Promise.race()`.
27 + *
28 + * @name race
29 + * @static
30 + * @memberOf module:ControlFlow
31 + * @method
32 + * @category Control Flow
33 + * @param {Array} tasks - An array containing functions to run. Each function
34 + * is passed a `callback(err, result)` which it must call on completion with an
35 + * error `err` (which can be `null`) and an optional `result` value.
36 + * @param {Function} callback - A callback to run once any of the functions have
37 + * completed. This function gets an error or result from the first function that
38 + * completed. Invoked with (err, result).
39 + * @returns undefined
40 + * @example
41 + *
42 + * async.race([
43 + * function(callback) {
44 + * setTimeout(function() {
45 + * callback(null, 'one');
46 + * }, 200);
47 + * },
48 + * function(callback) {
49 + * setTimeout(function() {
50 + * callback(null, 'two');
51 + * }, 100);
52 + * }
53 + * ],
54 + * // main callback
55 + * function(err, result) {
56 + * // the result will be equal to 'two' as it finishes earlier
57 + * });
58 + */
59 +function race(tasks, callback) {
60 + callback = (0, _once2.default)(callback || _noop2.default);
61 + if (!(0, _isArray2.default)(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
62 + if (!tasks.length) return callback();
63 + for (var i = 0, l = tasks.length; i < l; i++) {
64 + tasks[i](callback);
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 +exports.default = reduce;
7 +
8 +var _eachOfSeries = require('./eachOfSeries');
9 +
10 +var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
11 +
12 +var _noop = require('lodash/noop');
13 +
14 +var _noop2 = _interopRequireDefault(_noop);
15 +
16 +var _once = require('./internal/once');
17 +
18 +var _once2 = _interopRequireDefault(_once);
19 +
20 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21 +
22 +/**
23 + * Reduces `coll` into a single value using an async `iteratee` to return each
24 + * successive step. `memo` is the initial state of the reduction. This function
25 + * only operates in series.
26 + *
27 + * For performance reasons, it may make sense to split a call to this function
28 + * into a parallel map, and then use the normal `Array.prototype.reduce` on the
29 + * results. This function is for situations where each step in the reduction
30 + * needs to be async; if you can get the data before reducing it, then it's
31 + * probably a good idea to do so.
32 + *
33 + * @name reduce
34 + * @static
35 + * @memberOf module:Collections
36 + * @method
37 + * @alias inject
38 + * @alias foldl
39 + * @category Collection
40 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
41 + * @param {*} memo - The initial state of the reduction.
42 + * @param {Function} iteratee - A function applied to each item in the
43 + * array to produce the next step in the reduction. The `iteratee` is passed a
44 + * `callback(err, reduction)` which accepts an optional error as its first
45 + * argument, and the state of the reduction as the second. If an error is
46 + * passed to the callback, the reduction is stopped and the main `callback` is
47 + * immediately called with the error. Invoked with (memo, item, callback).
48 + * @param {Function} [callback] - A callback which is called after all the
49 + * `iteratee` functions have finished. Result is the reduced value. Invoked with
50 + * (err, result).
51 + * @example
52 + *
53 + * async.reduce([1,2,3], 0, function(memo, item, callback) {
54 + * // pointless async:
55 + * process.nextTick(function() {
56 + * callback(null, memo + item)
57 + * });
58 + * }, function(err, result) {
59 + * // result is now equal to the last value of memo, which is 6
60 + * });
61 + */
62 +function reduce(coll, memo, iteratee, callback) {
63 + callback = (0, _once2.default)(callback || _noop2.default);
64 + (0, _eachOfSeries2.default)(coll, function (x, i, callback) {
65 + iteratee(memo, x, function (err, v) {
66 + memo = v;
67 + callback(err);
68 + });
69 + }, function (err) {
70 + callback(err, memo);
71 + });
72 +}
73 +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 +var slice = Array.prototype.slice;
15 +
16 +/**
17 + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
18 + *
19 + * @name reduceRight
20 + * @static
21 + * @memberOf module:Collections
22 + * @method
23 + * @see [async.reduce]{@link module:Collections.reduce}
24 + * @alias foldr
25 + * @category Collection
26 + * @param {Array} array - A collection to iterate over.
27 + * @param {*} memo - The initial state of the reduction.
28 + * @param {Function} iteratee - A function applied to each item in the
29 + * array to produce the next step in the reduction. The `iteratee` is passed a
30 + * `callback(err, reduction)` which accepts an optional error as its first
31 + * argument, and the state of the reduction as the second. If an error is
32 + * passed to the callback, the reduction is stopped and the main `callback` is
33 + * immediately called with the error. Invoked with (memo, item, callback).
34 + * @param {Function} [callback] - A callback which is called after all the
35 + * `iteratee` functions have finished. Result is the reduced value. Invoked with
36 + * (err, result).
37 + */
38 +function reduceRight(array, memo, iteratee, callback) {
39 + var reversed = slice.call(array).reverse();
40 + (0, _reduce2.default)(reversed, memo, iteratee, callback);
41 +}
42 +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 = reflect;
7 +
8 +var _initialParams = require('./internal/initialParams');
9 +
10 +var _initialParams2 = _interopRequireDefault(_initialParams);
11 +
12 +var _rest = require('./internal/rest');
13 +
14 +var _rest2 = _interopRequireDefault(_rest);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Wraps the function in another function that always returns data even when it
20 + * errors.
21 + *
22 + * The object returned has either the property `error` or `value`.
23 + *
24 + * @name reflect
25 + * @static
26 + * @memberOf module:Utils
27 + * @method
28 + * @category Util
29 + * @param {Function} fn - The function you want to wrap
30 + * @returns {Function} - A function that always passes null to it's callback as
31 + * the error. The second argument to the callback will be an `object` with
32 + * either an `error` or a `value` property.
33 + * @example
34 + *
35 + * async.parallel([
36 + * async.reflect(function(callback) {
37 + * // do some stuff ...
38 + * callback(null, 'one');
39 + * }),
40 + * async.reflect(function(callback) {
41 + * // do some more stuff but error ...
42 + * callback('bad stuff happened');
43 + * }),
44 + * async.reflect(function(callback) {
45 + * // do some more stuff ...
46 + * callback(null, 'two');
47 + * })
48 + * ],
49 + * // optional callback
50 + * function(err, results) {
51 + * // values
52 + * // results[0].value = 'one'
53 + * // results[1].error = 'bad stuff happened'
54 + * // results[2].value = 'two'
55 + * });
56 + */
57 +function reflect(fn) {
58 + return (0, _initialParams2.default)(function reflectOn(args, reflectCallback) {
59 + args.push((0, _rest2.default)(function callback(err, cbArgs) {
60 + if (err) {
61 + reflectCallback(null, {
62 + error: err
63 + });
64 + } else {
65 + var value = null;
66 + if (cbArgs.length === 1) {
67 + value = cbArgs[0];
68 + } else if (cbArgs.length > 1) {
69 + value = cbArgs;
70 + }
71 + reflectCallback(null, {
72 + value: value
73 + });
74 + }
75 + }));
76 +
77 + return fn.apply(this, args);
78 + });
79 +}
80 +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 = reflectAll;
7 +
8 +var _reflect = require('./reflect');
9 +
10 +var _reflect2 = _interopRequireDefault(_reflect);
11 +
12 +var _isArray = require('lodash/isArray');
13 +
14 +var _isArray2 = _interopRequireDefault(_isArray);
15 +
16 +var _arrayMap2 = require('lodash/_arrayMap');
17 +
18 +var _arrayMap3 = _interopRequireDefault(_arrayMap2);
19 +
20 +var _baseForOwn = require('lodash/_baseForOwn');
21 +
22 +var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
23 +
24 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25 +
26 +/**
27 + * A helper function that wraps an array or an object of functions with reflect.
28 + *
29 + * @name reflectAll
30 + * @static
31 + * @memberOf module:Utils
32 + * @method
33 + * @see [async.reflect]{@link module:Utils.reflect}
34 + * @category Util
35 + * @param {Array} tasks - The array of functions to wrap in `async.reflect`.
36 + * @returns {Array} Returns an array of functions, each function wrapped in
37 + * `async.reflect`
38 + * @example
39 + *
40 + * let tasks = [
41 + * function(callback) {
42 + * setTimeout(function() {
43 + * callback(null, 'one');
44 + * }, 200);
45 + * },
46 + * function(callback) {
47 + * // do some more stuff but error ...
48 + * callback(new Error('bad stuff happened'));
49 + * },
50 + * function(callback) {
51 + * setTimeout(function() {
52 + * callback(null, 'two');
53 + * }, 100);
54 + * }
55 + * ];
56 + *
57 + * async.parallel(async.reflectAll(tasks),
58 + * // optional callback
59 + * function(err, results) {
60 + * // values
61 + * // results[0].value = 'one'
62 + * // results[1].error = Error('bad stuff happened')
63 + * // results[2].value = 'two'
64 + * });
65 + *
66 + * // an example using an object instead of an array
67 + * let tasks = {
68 + * one: function(callback) {
69 + * setTimeout(function() {
70 + * callback(null, 'one');
71 + * }, 200);
72 + * },
73 + * two: function(callback) {
74 + * callback('two');
75 + * },
76 + * three: function(callback) {
77 + * setTimeout(function() {
78 + * callback(null, 'three');
79 + * }, 100);
80 + * }
81 + * };
82 + *
83 + * async.parallel(async.reflectAll(tasks),
84 + * // optional callback
85 + * function(err, results) {
86 + * // values
87 + * // results.one.value = 'one'
88 + * // results.two.error = 'two'
89 + * // results.three.value = 'three'
90 + * });
91 + */
92 +function reflectAll(tasks) {
93 + var results;
94 + if ((0, _isArray2.default)(tasks)) {
95 + results = (0, _arrayMap3.default)(tasks, _reflect2.default);
96 + } else {
97 + results = {};
98 + (0, _baseForOwn2.default)(tasks, function (task, key) {
99 + results[key] = _reflect2.default.call(this, task);
100 + });
101 + }
102 + return results;
103 +}
104 +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 _reject = require('./internal/reject');
8 +
9 +var _reject2 = _interopRequireDefault(_reject);
10 +
11 +var _doParallel = require('./internal/doParallel');
12 +
13 +var _doParallel2 = _interopRequireDefault(_doParallel);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
19 + *
20 + * @name reject
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.filter]{@link module:Collections.filter}
25 + * @category Collection
26 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
28 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
29 + * with a boolean argument once it has completed. Invoked with (item, callback).
30 + * @param {Function} [callback] - A callback which is called after all the
31 + * `iteratee` functions have finished. Invoked with (err, results).
32 + * @example
33 + *
34 + * async.reject(['file1','file2','file3'], function(filePath, callback) {
35 + * fs.access(filePath, function(err) {
36 + * callback(null, !err)
37 + * });
38 + * }, function(err, results) {
39 + * // results now equals an array of missing files
40 + * createFiles(results);
41 + * });
42 + */
43 +exports.default = (0, _doParallel2.default)(_reject2.default);
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 _reject = require('./internal/reject');
8 +
9 +var _reject2 = _interopRequireDefault(_reject);
10 +
11 +var _doParallelLimit = require('./internal/doParallelLimit');
12 +
13 +var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
19 + * time.
20 + *
21 + * @name rejectLimit
22 + * @static
23 + * @memberOf module:Collections
24 + * @method
25 + * @see [async.reject]{@link module:Collections.reject}
26 + * @category Collection
27 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
28 + * @param {number} limit - The maximum number of async operations at a time.
29 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
30 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
31 + * with a boolean argument once it has completed. Invoked with (item, callback).
32 + * @param {Function} [callback] - A callback which is called after all the
33 + * `iteratee` functions have finished. Invoked with (err, results).
34 + */
35 +exports.default = (0, _doParallelLimit2.default)(_reject2.default);
36 +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 _rejectLimit = require('./rejectLimit');
8 +
9 +var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
10 +
11 +var _doLimit = require('./internal/doLimit');
12 +
13 +var _doLimit2 = _interopRequireDefault(_doLimit);
14 +
15 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16 +
17 +/**
18 + * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
19 + *
20 + * @name rejectSeries
21 + * @static
22 + * @memberOf module:Collections
23 + * @method
24 + * @see [async.reject]{@link module:Collections.reject}
25 + * @category Collection
26 + * @param {Array|Iterable|Object} coll - A collection to iterate over.
27 + * @param {Function} iteratee - A truth test to apply to each item in `coll`.
28 + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
29 + * with a boolean argument once it has completed. Invoked with (item, callback).
30 + * @param {Function} [callback] - A callback which is called after all the
31 + * `iteratee` functions have finished. Invoked with (err, results).
32 + */
33 +exports.default = (0, _doLimit2.default)(_rejectLimit2.default, 1);
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 +exports.default = retry;
7 +
8 +var _noop = require('lodash/noop');
9 +
10 +var _noop2 = _interopRequireDefault(_noop);
11 +
12 +var _constant = require('lodash/constant');
13 +
14 +var _constant2 = _interopRequireDefault(_constant);
15 +
16 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17 +
18 +/**
19 + * Attempts to get a successful response from `task` no more than `times` times
20 + * before returning an error. If the task is successful, the `callback` will be
21 + * passed the result of the successful task. If all attempts fail, the callback
22 + * will be passed the error and result (if any) of the final attempt.
23 + *
24 + * @name retry
25 + * @static
26 + * @memberOf module:ControlFlow
27 + * @method
28 + * @category Control Flow
29 + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
30 + * object with `times` and `interval` or a number.
31 + * * `times` - The number of attempts to make before giving up. The default
32 + * is `5`.
33 + * * `interval` - The time to wait between retries, in milliseconds. The
34 + * default is `0`. The interval may also be specified as a function of the
35 + * retry count (see example).
36 + * * `errorFilter` - An optional synchronous function that is invoked on
37 + * erroneous result. If it returns `true` the retry attempts will continue;
38 + * if the function returns `false` the retry flow is aborted with the current
39 + * attempt's error and result being returned to the final callback.
40 + * Invoked with (err).
41 + * * If `opts` is a number, the number specifies the number of times to retry,
42 + * with the default interval of `0`.
43 + * @param {Function} task - A function which receives two arguments: (1) a
44 + * `callback(err, result)` which must be called when finished, passing `err`
45 + * (which can be `null`) and the `result` of the function's execution, and (2)
46 + * a `results` object, containing the results of the previously executed
47 + * functions (if nested inside another control flow). Invoked with
48 + * (callback, results).
49 + * @param {Function} [callback] - An optional callback which is called when the
50 + * task has succeeded, or after the final failed attempt. It receives the `err`
51 + * and `result` arguments of the last attempt at completing the `task`. Invoked
52 + * with (err, results).
53 + * @example
54 + *
55 + * // The `retry` function can be used as a stand-alone control flow by passing
56 + * // a callback, as shown below:
57 + *
58 + * // try calling apiMethod 3 times
59 + * async.retry(3, apiMethod, function(err, result) {
60 + * // do something with the result
61 + * });
62 + *
63 + * // try calling apiMethod 3 times, waiting 200 ms between each retry
64 + * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
65 + * // do something with the result
66 + * });
67 + *
68 + * // try calling apiMethod 10 times with exponential backoff
69 + * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
70 + * async.retry({
71 + * times: 10,
72 + * interval: function(retryCount) {
73 + * return 50 * Math.pow(2, retryCount);
74 + * }
75 + * }, apiMethod, function(err, result) {
76 + * // do something with the result
77 + * });
78 + *
79 + * // try calling apiMethod the default 5 times no delay between each retry
80 + * async.retry(apiMethod, function(err, result) {
81 + * // do something with the result
82 + * });
83 + *
84 + * // try calling apiMethod only when error condition satisfies, all other
85 + * // errors will abort the retry control flow and return to final callback
86 + * async.retry({
87 + * errorFilter: function(err) {
88 + * return err.message === 'Temporary error'; // only retry on a specific error
89 + * }
90 + * }, apiMethod, function(err, result) {
91 + * // do something with the result
92 + * });
93 + *
94 + * // It can also be embedded within other control flow functions to retry
95 + * // individual methods that are not as reliable, like this:
96 + * async.auto({
97 + * users: api.getUsers.bind(api),
98 + * payments: async.retry(3, api.getPayments.bind(api))
99 + * }, function(err, results) {
100 + * // do something with the results
101 + * });
102 + *
103 + */
104 +function retry(opts, task, callback) {
105 + var DEFAULT_TIMES = 5;
106 + var DEFAULT_INTERVAL = 0;
107 +
108 + var options = {
109 + times: DEFAULT_TIMES,
110 + intervalFunc: (0, _constant2.default)(DEFAULT_INTERVAL)
111 + };
112 +
113 + function parseTimes(acc, t) {
114 + if (typeof t === 'object') {
115 + acc.times = +t.times || DEFAULT_TIMES;
116 +
117 + acc.intervalFunc = typeof t.interval === 'function' ? t.interval : (0, _constant2.default)(+t.interval || DEFAULT_INTERVAL);
118 +
119 + acc.errorFilter = t.errorFilter;
120 + } else if (typeof t === 'number' || typeof t === 'string') {
121 + acc.times = +t || DEFAULT_TIMES;
122 + } else {
123 + throw new Error("Invalid arguments for async.retry");
124 + }
125 + }
126 +
127 + if (arguments.length < 3 && typeof opts === 'function') {
128 + callback = task || _noop2.default;
129 + task = opts;
130 + } else {
131 + parseTimes(options, opts);
132 + callback = callback || _noop2.default;
133 + }
134 +
135 + if (typeof task !== 'function') {
136 + throw new Error("Invalid arguments for async.retry");
137 + }
138 +
139 + var attempt = 1;
140 + function retryAttempt() {
141 + task(function (err) {
142 + if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
143 + setTimeout(retryAttempt, options.intervalFunc(attempt));
144 + } else {
145 + callback.apply(null, arguments);
146 + }
147 + });
148 + }
149 +
150 + retryAttempt();
151 +}
152 +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 (opts, task) {
8 + if (!task) {
9 + task = opts;
10 + opts = null;
11 + }
12 + return (0, _initialParams2.default)(function (args, callback) {
13 + function taskFn(cb) {
14 + task.apply(null, args.concat([cb]));
15 + }
16 +
17 + if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
18 + });
19 +};
20 +
21 +var _retry = require('./retry');
22 +
23 +var _retry2 = _interopRequireDefault(_retry);
24 +
25 +var _initialParams = require('./internal/initialParams');
26 +
27 +var _initialParams2 = _interopRequireDefault(_initialParams);
28 +
29 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30 +
31 +module.exports = exports['default'];
32 +
33 +/**
34 + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it
35 + * retryable, rather than immediately calling it with retries.
36 + *
37 + * @name retryable
38 + * @static
39 + * @memberOf module:ControlFlow
40 + * @method
41 + * @see [async.retry]{@link module:ControlFlow.retry}
42 + * @category Control Flow
43 + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
44 + * options, exactly the same as from `retry`
45 + * @param {Function} task - the asynchronous function to wrap
46 + * @returns {Functions} The wrapped function, which when invoked, will retry on
47 + * an error, based on the parameters specified in `opts`.
48 + * @example
49 + *
50 + * async.auto({
51 + * dep1: async.retryable(3, getFromFlakyService),
52 + * process: ["dep1", async.retryable(3, function (results, cb) {
53 + * maybeProcessData(results.dep1, cb);
54 + * })]
55 + * }, callback);
56 + */
...\ 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 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff 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 is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.