index.js 19.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.doDuring = exports.during = exports.wrapSync = undefined;
exports.selectSeries = exports.selectLimit = exports.select = exports.foldr = exports.foldl = exports.inject = exports.forEachOfLimit = exports.forEachOfSeries = exports.forEachOf = exports.forEachLimit = exports.forEachSeries = exports.forEach = exports.flatMapSeries = exports.flatMapLimit = exports.flatMap = exports.findSeries = exports.findLimit = exports.find = exports.anySeries = exports.anyLimit = exports.any = exports.allSeries = exports.allLimit = exports.all = exports.whilst = exports.waterfall = exports.until = exports.unmemoize = exports.tryEach = exports.transform = exports.timesSeries = exports.timesLimit = exports.times = exports.timeout = exports.sortBy = exports.someSeries = exports.someLimit = exports.some = exports.setImmediate = exports.series = exports.seq = exports.retryable = exports.retry = exports.rejectSeries = exports.rejectLimit = exports.reject = exports.reflectAll = exports.reflect = exports.reduceRight = exports.reduce = exports.race = exports.queue = exports.priorityQueue = exports.parallelLimit = exports.parallel = exports.nextTick = exports.memoize = exports.mapValuesSeries = exports.mapValuesLimit = exports.mapValues = exports.mapSeries = exports.mapLimit = exports.map = exports.log = exports.groupBySeries = exports.groupByLimit = exports.groupBy = exports.forever = exports.filterSeries = exports.filterLimit = exports.filter = exports.everySeries = exports.everyLimit = exports.every = exports.ensureAsync = exports.eachSeries = exports.eachOfSeries = exports.eachOfLimit = exports.eachOf = exports.eachLimit = exports.each = exports.doWhilst = exports.doUntil = exports.dir = exports.detectSeries = exports.detectLimit = exports.detect = exports.constant = exports.concatSeries = exports.concatLimit = exports.concat = exports.compose = exports.cargoQueue = exports.cargo = exports.autoInject = exports.auto = exports.asyncify = exports.applyEachSeries = exports.applyEach = exports.apply = undefined;

var _apply = require('./apply');

var _apply2 = _interopRequireDefault(_apply);

var _applyEach = require('./applyEach');

var _applyEach2 = _interopRequireDefault(_applyEach);

var _applyEachSeries = require('./applyEachSeries');

var _applyEachSeries2 = _interopRequireDefault(_applyEachSeries);

var _asyncify = require('./asyncify');

var _asyncify2 = _interopRequireDefault(_asyncify);

var _auto = require('./auto');

var _auto2 = _interopRequireDefault(_auto);

var _autoInject = require('./autoInject');

var _autoInject2 = _interopRequireDefault(_autoInject);

var _cargo = require('./cargo');

var _cargo2 = _interopRequireDefault(_cargo);

var _cargoQueue = require('./cargoQueue');

var _cargoQueue2 = _interopRequireDefault(_cargoQueue);

var _compose = require('./compose');

var _compose2 = _interopRequireDefault(_compose);

var _concat = require('./concat');

var _concat2 = _interopRequireDefault(_concat);

var _concatLimit = require('./concatLimit');

var _concatLimit2 = _interopRequireDefault(_concatLimit);

var _concatSeries = require('./concatSeries');

var _concatSeries2 = _interopRequireDefault(_concatSeries);

var _constant = require('./constant');

var _constant2 = _interopRequireDefault(_constant);

var _detect = require('./detect');

var _detect2 = _interopRequireDefault(_detect);

var _detectLimit = require('./detectLimit');

var _detectLimit2 = _interopRequireDefault(_detectLimit);

var _detectSeries = require('./detectSeries');

var _detectSeries2 = _interopRequireDefault(_detectSeries);

var _dir = require('./dir');

var _dir2 = _interopRequireDefault(_dir);

var _doUntil = require('./doUntil');

var _doUntil2 = _interopRequireDefault(_doUntil);

var _doWhilst = require('./doWhilst');

var _doWhilst2 = _interopRequireDefault(_doWhilst);

var _each = require('./each');

var _each2 = _interopRequireDefault(_each);

var _eachLimit = require('./eachLimit');

var _eachLimit2 = _interopRequireDefault(_eachLimit);

var _eachOf = require('./eachOf');

var _eachOf2 = _interopRequireDefault(_eachOf);

var _eachOfLimit = require('./eachOfLimit');

var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);

var _eachOfSeries = require('./eachOfSeries');

var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);

var _eachSeries = require('./eachSeries');

var _eachSeries2 = _interopRequireDefault(_eachSeries);

var _ensureAsync = require('./ensureAsync');

var _ensureAsync2 = _interopRequireDefault(_ensureAsync);

var _every = require('./every');

var _every2 = _interopRequireDefault(_every);

var _everyLimit = require('./everyLimit');

var _everyLimit2 = _interopRequireDefault(_everyLimit);

var _everySeries = require('./everySeries');

var _everySeries2 = _interopRequireDefault(_everySeries);

var _filter = require('./filter');

var _filter2 = _interopRequireDefault(_filter);

var _filterLimit = require('./filterLimit');

var _filterLimit2 = _interopRequireDefault(_filterLimit);

var _filterSeries = require('./filterSeries');

var _filterSeries2 = _interopRequireDefault(_filterSeries);

var _forever = require('./forever');

var _forever2 = _interopRequireDefault(_forever);

var _groupBy = require('./groupBy');

var _groupBy2 = _interopRequireDefault(_groupBy);

var _groupByLimit = require('./groupByLimit');

var _groupByLimit2 = _interopRequireDefault(_groupByLimit);

var _groupBySeries = require('./groupBySeries');

var _groupBySeries2 = _interopRequireDefault(_groupBySeries);

var _log = require('./log');

var _log2 = _interopRequireDefault(_log);

var _map = require('./map');

var _map2 = _interopRequireDefault(_map);

var _mapLimit = require('./mapLimit');

var _mapLimit2 = _interopRequireDefault(_mapLimit);

var _mapSeries = require('./mapSeries');

var _mapSeries2 = _interopRequireDefault(_mapSeries);

var _mapValues = require('./mapValues');

var _mapValues2 = _interopRequireDefault(_mapValues);

var _mapValuesLimit = require('./mapValuesLimit');

var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);

var _mapValuesSeries = require('./mapValuesSeries');

var _mapValuesSeries2 = _interopRequireDefault(_mapValuesSeries);

var _memoize = require('./memoize');

var _memoize2 = _interopRequireDefault(_memoize);

var _nextTick = require('./nextTick');

var _nextTick2 = _interopRequireDefault(_nextTick);

var _parallel = require('./parallel');

var _parallel2 = _interopRequireDefault(_parallel);

var _parallelLimit = require('./parallelLimit');

var _parallelLimit2 = _interopRequireDefault(_parallelLimit);

var _priorityQueue = require('./priorityQueue');

var _priorityQueue2 = _interopRequireDefault(_priorityQueue);

var _queue = require('./queue');

var _queue2 = _interopRequireDefault(_queue);

var _race = require('./race');

var _race2 = _interopRequireDefault(_race);

var _reduce = require('./reduce');

var _reduce2 = _interopRequireDefault(_reduce);

var _reduceRight = require('./reduceRight');

var _reduceRight2 = _interopRequireDefault(_reduceRight);

var _reflect = require('./reflect');

var _reflect2 = _interopRequireDefault(_reflect);

var _reflectAll = require('./reflectAll');

var _reflectAll2 = _interopRequireDefault(_reflectAll);

var _reject = require('./reject');

var _reject2 = _interopRequireDefault(_reject);

var _rejectLimit = require('./rejectLimit');

var _rejectLimit2 = _interopRequireDefault(_rejectLimit);

var _rejectSeries = require('./rejectSeries');

var _rejectSeries2 = _interopRequireDefault(_rejectSeries);

var _retry = require('./retry');

var _retry2 = _interopRequireDefault(_retry);

var _retryable = require('./retryable');

var _retryable2 = _interopRequireDefault(_retryable);

var _seq = require('./seq');

var _seq2 = _interopRequireDefault(_seq);

var _series = require('./series');

var _series2 = _interopRequireDefault(_series);

var _setImmediate = require('./setImmediate');

var _setImmediate2 = _interopRequireDefault(_setImmediate);

var _some = require('./some');

var _some2 = _interopRequireDefault(_some);

var _someLimit = require('./someLimit');

var _someLimit2 = _interopRequireDefault(_someLimit);

var _someSeries = require('./someSeries');

var _someSeries2 = _interopRequireDefault(_someSeries);

var _sortBy = require('./sortBy');

var _sortBy2 = _interopRequireDefault(_sortBy);

var _timeout = require('./timeout');

var _timeout2 = _interopRequireDefault(_timeout);

var _times = require('./times');

var _times2 = _interopRequireDefault(_times);

var _timesLimit = require('./timesLimit');

var _timesLimit2 = _interopRequireDefault(_timesLimit);

var _timesSeries = require('./timesSeries');

var _timesSeries2 = _interopRequireDefault(_timesSeries);

var _transform = require('./transform');

var _transform2 = _interopRequireDefault(_transform);

var _tryEach = require('./tryEach');

var _tryEach2 = _interopRequireDefault(_tryEach);

var _unmemoize = require('./unmemoize');

var _unmemoize2 = _interopRequireDefault(_unmemoize);

var _until = require('./until');

var _until2 = _interopRequireDefault(_until);

var _waterfall = require('./waterfall');

var _waterfall2 = _interopRequireDefault(_waterfall);

var _whilst = require('./whilst');

var _whilst2 = _interopRequireDefault(_whilst);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * An "async function" in the context of Async is an asynchronous function with
 * a variable number of parameters, with the final parameter being a callback.
 * (`function (arg1, arg2, ..., callback) {}`)
 * The final callback is of the form `callback(err, results...)`, which must be
 * called once the function is completed.  The callback should be called with a
 * Error as its first argument to signal that an error occurred.
 * Otherwise, if no error occurred, it should be called with `null` as the first
 * argument, and any additional `result` arguments that may apply, to signal
 * successful completion.
 * The callback must be called exactly once, ideally on a later tick of the
 * JavaScript event loop.
 *
 * This type of function is also referred to as a "Node-style async function",
 * or a "continuation passing-style function" (CPS). Most of the methods of this
 * library are themselves CPS/Node-style async functions, or functions that
 * return CPS/Node-style async functions.
 *
 * Wherever we accept a Node-style async function, we also directly accept an
 * [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function}.
 * In this case, the `async` function will not be passed a final callback
 * argument, and any thrown error will be used as the `err` argument of the
 * implicit callback, and the return value will be used as the `result` value.
 * (i.e. a `rejected` of the returned Promise becomes the `err` callback
 * argument, and a `resolved` value becomes the `result`.)
 *
 * Note, due to JavaScript limitations, we can only detect native `async`
 * functions and not transpilied implementations.
 * Your environment must have `async`/`await` support for this to work.
 * (e.g. Node > v7.6, or a recent version of a modern browser).
 * If you are using `async` functions through a transpiler (e.g. Babel), you
 * must still wrap the function with [asyncify]{@link module:Utils.asyncify},
 * because the `async function` will be compiled to an ordinary function that
 * returns a promise.
 *
 * @typedef {Function} AsyncFunction
 * @static
 */

/**
 * Async is a utility module which provides straight-forward, powerful functions
 * for working with asynchronous JavaScript. Although originally designed for
 * use with [Node.js](http://nodejs.org) and installable via
 * `npm install --save async`, it can also be used directly in the browser.
 * @module async
 * @see AsyncFunction
 */

/**
 * A collection of `async` functions for manipulating collections, such as
 * arrays and objects.
 * @module Collections
 */

/**
 * A collection of `async` functions for controlling the flow through a script.
 * @module ControlFlow
 */

/**
 * A collection of `async` utility functions.
 * @module Utils
 */

exports.default = {
  apply: _apply2.default,
  applyEach: _applyEach2.default,
  applyEachSeries: _applyEachSeries2.default,
  asyncify: _asyncify2.default,
  auto: _auto2.default,
  autoInject: _autoInject2.default,
  cargo: _cargo2.default,
  cargoQueue: _cargoQueue2.default,
  compose: _compose2.default,
  concat: _concat2.default,
  concatLimit: _concatLimit2.default,
  concatSeries: _concatSeries2.default,
  constant: _constant2.default,
  detect: _detect2.default,
  detectLimit: _detectLimit2.default,
  detectSeries: _detectSeries2.default,
  dir: _dir2.default,
  doUntil: _doUntil2.default,
  doWhilst: _doWhilst2.default,
  each: _each2.default,
  eachLimit: _eachLimit2.default,
  eachOf: _eachOf2.default,
  eachOfLimit: _eachOfLimit2.default,
  eachOfSeries: _eachOfSeries2.default,
  eachSeries: _eachSeries2.default,
  ensureAsync: _ensureAsync2.default,
  every: _every2.default,
  everyLimit: _everyLimit2.default,
  everySeries: _everySeries2.default,
  filter: _filter2.default,
  filterLimit: _filterLimit2.default,
  filterSeries: _filterSeries2.default,
  forever: _forever2.default,
  groupBy: _groupBy2.default,
  groupByLimit: _groupByLimit2.default,
  groupBySeries: _groupBySeries2.default,
  log: _log2.default,
  map: _map2.default,
  mapLimit: _mapLimit2.default,
  mapSeries: _mapSeries2.default,
  mapValues: _mapValues2.default,
  mapValuesLimit: _mapValuesLimit2.default,
  mapValuesSeries: _mapValuesSeries2.default,
  memoize: _memoize2.default,
  nextTick: _nextTick2.default,
  parallel: _parallel2.default,
  parallelLimit: _parallelLimit2.default,
  priorityQueue: _priorityQueue2.default,
  queue: _queue2.default,
  race: _race2.default,
  reduce: _reduce2.default,
  reduceRight: _reduceRight2.default,
  reflect: _reflect2.default,
  reflectAll: _reflectAll2.default,
  reject: _reject2.default,
  rejectLimit: _rejectLimit2.default,
  rejectSeries: _rejectSeries2.default,
  retry: _retry2.default,
  retryable: _retryable2.default,
  seq: _seq2.default,
  series: _series2.default,
  setImmediate: _setImmediate2.default,
  some: _some2.default,
  someLimit: _someLimit2.default,
  someSeries: _someSeries2.default,
  sortBy: _sortBy2.default,
  timeout: _timeout2.default,
  times: _times2.default,
  timesLimit: _timesLimit2.default,
  timesSeries: _timesSeries2.default,
  transform: _transform2.default,
  tryEach: _tryEach2.default,
  unmemoize: _unmemoize2.default,
  until: _until2.default,
  waterfall: _waterfall2.default,
  whilst: _whilst2.default,

  // aliases
  all: _every2.default,
  allLimit: _everyLimit2.default,
  allSeries: _everySeries2.default,
  any: _some2.default,
  anyLimit: _someLimit2.default,
  anySeries: _someSeries2.default,
  find: _detect2.default,
  findLimit: _detectLimit2.default,
  findSeries: _detectSeries2.default,
  flatMap: _concat2.default,
  flatMapLimit: _concatLimit2.default,
  flatMapSeries: _concatSeries2.default,
  forEach: _each2.default,
  forEachSeries: _eachSeries2.default,
  forEachLimit: _eachLimit2.default,
  forEachOf: _eachOf2.default,
  forEachOfSeries: _eachOfSeries2.default,
  forEachOfLimit: _eachOfLimit2.default,
  inject: _reduce2.default,
  foldl: _reduce2.default,
  foldr: _reduceRight2.default,
  select: _filter2.default,
  selectLimit: _filterLimit2.default,
  selectSeries: _filterSeries2.default,
  wrapSync: _asyncify2.default,
  during: _whilst2.default,
  doDuring: _doWhilst2.default
};
exports.apply = _apply2.default;
exports.applyEach = _applyEach2.default;
exports.applyEachSeries = _applyEachSeries2.default;
exports.asyncify = _asyncify2.default;
exports.auto = _auto2.default;
exports.autoInject = _autoInject2.default;
exports.cargo = _cargo2.default;
exports.cargoQueue = _cargoQueue2.default;
exports.compose = _compose2.default;
exports.concat = _concat2.default;
exports.concatLimit = _concatLimit2.default;
exports.concatSeries = _concatSeries2.default;
exports.constant = _constant2.default;
exports.detect = _detect2.default;
exports.detectLimit = _detectLimit2.default;
exports.detectSeries = _detectSeries2.default;
exports.dir = _dir2.default;
exports.doUntil = _doUntil2.default;
exports.doWhilst = _doWhilst2.default;
exports.each = _each2.default;
exports.eachLimit = _eachLimit2.default;
exports.eachOf = _eachOf2.default;
exports.eachOfLimit = _eachOfLimit2.default;
exports.eachOfSeries = _eachOfSeries2.default;
exports.eachSeries = _eachSeries2.default;
exports.ensureAsync = _ensureAsync2.default;
exports.every = _every2.default;
exports.everyLimit = _everyLimit2.default;
exports.everySeries = _everySeries2.default;
exports.filter = _filter2.default;
exports.filterLimit = _filterLimit2.default;
exports.filterSeries = _filterSeries2.default;
exports.forever = _forever2.default;
exports.groupBy = _groupBy2.default;
exports.groupByLimit = _groupByLimit2.default;
exports.groupBySeries = _groupBySeries2.default;
exports.log = _log2.default;
exports.map = _map2.default;
exports.mapLimit = _mapLimit2.default;
exports.mapSeries = _mapSeries2.default;
exports.mapValues = _mapValues2.default;
exports.mapValuesLimit = _mapValuesLimit2.default;
exports.mapValuesSeries = _mapValuesSeries2.default;
exports.memoize = _memoize2.default;
exports.nextTick = _nextTick2.default;
exports.parallel = _parallel2.default;
exports.parallelLimit = _parallelLimit2.default;
exports.priorityQueue = _priorityQueue2.default;
exports.queue = _queue2.default;
exports.race = _race2.default;
exports.reduce = _reduce2.default;
exports.reduceRight = _reduceRight2.default;
exports.reflect = _reflect2.default;
exports.reflectAll = _reflectAll2.default;
exports.reject = _reject2.default;
exports.rejectLimit = _rejectLimit2.default;
exports.rejectSeries = _rejectSeries2.default;
exports.retry = _retry2.default;
exports.retryable = _retryable2.default;
exports.seq = _seq2.default;
exports.series = _series2.default;
exports.setImmediate = _setImmediate2.default;
exports.some = _some2.default;
exports.someLimit = _someLimit2.default;
exports.someSeries = _someSeries2.default;
exports.sortBy = _sortBy2.default;
exports.timeout = _timeout2.default;
exports.times = _times2.default;
exports.timesLimit = _timesLimit2.default;
exports.timesSeries = _timesSeries2.default;
exports.transform = _transform2.default;
exports.tryEach = _tryEach2.default;
exports.unmemoize = _unmemoize2.default;
exports.until = _until2.default;
exports.waterfall = _waterfall2.default;
exports.whilst = _whilst2.default;
exports.all = _every2.default;
exports.allLimit = _everyLimit2.default;
exports.allSeries = _everySeries2.default;
exports.any = _some2.default;
exports.anyLimit = _someLimit2.default;
exports.anySeries = _someSeries2.default;
exports.find = _detect2.default;
exports.findLimit = _detectLimit2.default;
exports.findSeries = _detectSeries2.default;
exports.flatMap = _concat2.default;
exports.flatMapLimit = _concatLimit2.default;
exports.flatMapSeries = _concatSeries2.default;
exports.forEach = _each2.default;
exports.forEachSeries = _eachSeries2.default;
exports.forEachLimit = _eachLimit2.default;
exports.forEachOf = _eachOf2.default;
exports.forEachOfSeries = _eachOfSeries2.default;
exports.forEachOfLimit = _eachOfLimit2.default;
exports.inject = _reduce2.default;
exports.foldl = _reduce2.default;
exports.foldr = _reduceRight2.default;
exports.select = _filter2.default;
exports.selectLimit = _filterLimit2.default;
exports.selectSeries = _filterSeries2.default;
exports.wrapSync = _asyncify2.default;
exports.during = _whilst2.default;
exports.doDuring = _doWhilst2.default;