index.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.doDuring = exports.during = exports.wrapSync = undefined;
  6. 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;
  7. var _apply = require('./apply');
  8. var _apply2 = _interopRequireDefault(_apply);
  9. var _applyEach = require('./applyEach');
  10. var _applyEach2 = _interopRequireDefault(_applyEach);
  11. var _applyEachSeries = require('./applyEachSeries');
  12. var _applyEachSeries2 = _interopRequireDefault(_applyEachSeries);
  13. var _asyncify = require('./asyncify');
  14. var _asyncify2 = _interopRequireDefault(_asyncify);
  15. var _auto = require('./auto');
  16. var _auto2 = _interopRequireDefault(_auto);
  17. var _autoInject = require('./autoInject');
  18. var _autoInject2 = _interopRequireDefault(_autoInject);
  19. var _cargo = require('./cargo');
  20. var _cargo2 = _interopRequireDefault(_cargo);
  21. var _cargoQueue = require('./cargoQueue');
  22. var _cargoQueue2 = _interopRequireDefault(_cargoQueue);
  23. var _compose = require('./compose');
  24. var _compose2 = _interopRequireDefault(_compose);
  25. var _concat = require('./concat');
  26. var _concat2 = _interopRequireDefault(_concat);
  27. var _concatLimit = require('./concatLimit');
  28. var _concatLimit2 = _interopRequireDefault(_concatLimit);
  29. var _concatSeries = require('./concatSeries');
  30. var _concatSeries2 = _interopRequireDefault(_concatSeries);
  31. var _constant = require('./constant');
  32. var _constant2 = _interopRequireDefault(_constant);
  33. var _detect = require('./detect');
  34. var _detect2 = _interopRequireDefault(_detect);
  35. var _detectLimit = require('./detectLimit');
  36. var _detectLimit2 = _interopRequireDefault(_detectLimit);
  37. var _detectSeries = require('./detectSeries');
  38. var _detectSeries2 = _interopRequireDefault(_detectSeries);
  39. var _dir = require('./dir');
  40. var _dir2 = _interopRequireDefault(_dir);
  41. var _doUntil = require('./doUntil');
  42. var _doUntil2 = _interopRequireDefault(_doUntil);
  43. var _doWhilst = require('./doWhilst');
  44. var _doWhilst2 = _interopRequireDefault(_doWhilst);
  45. var _each = require('./each');
  46. var _each2 = _interopRequireDefault(_each);
  47. var _eachLimit = require('./eachLimit');
  48. var _eachLimit2 = _interopRequireDefault(_eachLimit);
  49. var _eachOf = require('./eachOf');
  50. var _eachOf2 = _interopRequireDefault(_eachOf);
  51. var _eachOfLimit = require('./eachOfLimit');
  52. var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
  53. var _eachOfSeries = require('./eachOfSeries');
  54. var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
  55. var _eachSeries = require('./eachSeries');
  56. var _eachSeries2 = _interopRequireDefault(_eachSeries);
  57. var _ensureAsync = require('./ensureAsync');
  58. var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
  59. var _every = require('./every');
  60. var _every2 = _interopRequireDefault(_every);
  61. var _everyLimit = require('./everyLimit');
  62. var _everyLimit2 = _interopRequireDefault(_everyLimit);
  63. var _everySeries = require('./everySeries');
  64. var _everySeries2 = _interopRequireDefault(_everySeries);
  65. var _filter = require('./filter');
  66. var _filter2 = _interopRequireDefault(_filter);
  67. var _filterLimit = require('./filterLimit');
  68. var _filterLimit2 = _interopRequireDefault(_filterLimit);
  69. var _filterSeries = require('./filterSeries');
  70. var _filterSeries2 = _interopRequireDefault(_filterSeries);
  71. var _forever = require('./forever');
  72. var _forever2 = _interopRequireDefault(_forever);
  73. var _groupBy = require('./groupBy');
  74. var _groupBy2 = _interopRequireDefault(_groupBy);
  75. var _groupByLimit = require('./groupByLimit');
  76. var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
  77. var _groupBySeries = require('./groupBySeries');
  78. var _groupBySeries2 = _interopRequireDefault(_groupBySeries);
  79. var _log = require('./log');
  80. var _log2 = _interopRequireDefault(_log);
  81. var _map = require('./map');
  82. var _map2 = _interopRequireDefault(_map);
  83. var _mapLimit = require('./mapLimit');
  84. var _mapLimit2 = _interopRequireDefault(_mapLimit);
  85. var _mapSeries = require('./mapSeries');
  86. var _mapSeries2 = _interopRequireDefault(_mapSeries);
  87. var _mapValues = require('./mapValues');
  88. var _mapValues2 = _interopRequireDefault(_mapValues);
  89. var _mapValuesLimit = require('./mapValuesLimit');
  90. var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
  91. var _mapValuesSeries = require('./mapValuesSeries');
  92. var _mapValuesSeries2 = _interopRequireDefault(_mapValuesSeries);
  93. var _memoize = require('./memoize');
  94. var _memoize2 = _interopRequireDefault(_memoize);
  95. var _nextTick = require('./nextTick');
  96. var _nextTick2 = _interopRequireDefault(_nextTick);
  97. var _parallel = require('./parallel');
  98. var _parallel2 = _interopRequireDefault(_parallel);
  99. var _parallelLimit = require('./parallelLimit');
  100. var _parallelLimit2 = _interopRequireDefault(_parallelLimit);
  101. var _priorityQueue = require('./priorityQueue');
  102. var _priorityQueue2 = _interopRequireDefault(_priorityQueue);
  103. var _queue = require('./queue');
  104. var _queue2 = _interopRequireDefault(_queue);
  105. var _race = require('./race');
  106. var _race2 = _interopRequireDefault(_race);
  107. var _reduce = require('./reduce');
  108. var _reduce2 = _interopRequireDefault(_reduce);
  109. var _reduceRight = require('./reduceRight');
  110. var _reduceRight2 = _interopRequireDefault(_reduceRight);
  111. var _reflect = require('./reflect');
  112. var _reflect2 = _interopRequireDefault(_reflect);
  113. var _reflectAll = require('./reflectAll');
  114. var _reflectAll2 = _interopRequireDefault(_reflectAll);
  115. var _reject = require('./reject');
  116. var _reject2 = _interopRequireDefault(_reject);
  117. var _rejectLimit = require('./rejectLimit');
  118. var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
  119. var _rejectSeries = require('./rejectSeries');
  120. var _rejectSeries2 = _interopRequireDefault(_rejectSeries);
  121. var _retry = require('./retry');
  122. var _retry2 = _interopRequireDefault(_retry);
  123. var _retryable = require('./retryable');
  124. var _retryable2 = _interopRequireDefault(_retryable);
  125. var _seq = require('./seq');
  126. var _seq2 = _interopRequireDefault(_seq);
  127. var _series = require('./series');
  128. var _series2 = _interopRequireDefault(_series);
  129. var _setImmediate = require('./setImmediate');
  130. var _setImmediate2 = _interopRequireDefault(_setImmediate);
  131. var _some = require('./some');
  132. var _some2 = _interopRequireDefault(_some);
  133. var _someLimit = require('./someLimit');
  134. var _someLimit2 = _interopRequireDefault(_someLimit);
  135. var _someSeries = require('./someSeries');
  136. var _someSeries2 = _interopRequireDefault(_someSeries);
  137. var _sortBy = require('./sortBy');
  138. var _sortBy2 = _interopRequireDefault(_sortBy);
  139. var _timeout = require('./timeout');
  140. var _timeout2 = _interopRequireDefault(_timeout);
  141. var _times = require('./times');
  142. var _times2 = _interopRequireDefault(_times);
  143. var _timesLimit = require('./timesLimit');
  144. var _timesLimit2 = _interopRequireDefault(_timesLimit);
  145. var _timesSeries = require('./timesSeries');
  146. var _timesSeries2 = _interopRequireDefault(_timesSeries);
  147. var _transform = require('./transform');
  148. var _transform2 = _interopRequireDefault(_transform);
  149. var _tryEach = require('./tryEach');
  150. var _tryEach2 = _interopRequireDefault(_tryEach);
  151. var _unmemoize = require('./unmemoize');
  152. var _unmemoize2 = _interopRequireDefault(_unmemoize);
  153. var _until = require('./until');
  154. var _until2 = _interopRequireDefault(_until);
  155. var _waterfall = require('./waterfall');
  156. var _waterfall2 = _interopRequireDefault(_waterfall);
  157. var _whilst = require('./whilst');
  158. var _whilst2 = _interopRequireDefault(_whilst);
  159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  160. /**
  161. * An "async function" in the context of Async is an asynchronous function with
  162. * a variable number of parameters, with the final parameter being a callback.
  163. * (`function (arg1, arg2, ..., callback) {}`)
  164. * The final callback is of the form `callback(err, results...)`, which must be
  165. * called once the function is completed. The callback should be called with a
  166. * Error as its first argument to signal that an error occurred.
  167. * Otherwise, if no error occurred, it should be called with `null` as the first
  168. * argument, and any additional `result` arguments that may apply, to signal
  169. * successful completion.
  170. * The callback must be called exactly once, ideally on a later tick of the
  171. * JavaScript event loop.
  172. *
  173. * This type of function is also referred to as a "Node-style async function",
  174. * or a "continuation passing-style function" (CPS). Most of the methods of this
  175. * library are themselves CPS/Node-style async functions, or functions that
  176. * return CPS/Node-style async functions.
  177. *
  178. * Wherever we accept a Node-style async function, we also directly accept an
  179. * [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function}.
  180. * In this case, the `async` function will not be passed a final callback
  181. * argument, and any thrown error will be used as the `err` argument of the
  182. * implicit callback, and the return value will be used as the `result` value.
  183. * (i.e. a `rejected` of the returned Promise becomes the `err` callback
  184. * argument, and a `resolved` value becomes the `result`.)
  185. *
  186. * Note, due to JavaScript limitations, we can only detect native `async`
  187. * functions and not transpilied implementations.
  188. * Your environment must have `async`/`await` support for this to work.
  189. * (e.g. Node > v7.6, or a recent version of a modern browser).
  190. * If you are using `async` functions through a transpiler (e.g. Babel), you
  191. * must still wrap the function with [asyncify]{@link module:Utils.asyncify},
  192. * because the `async function` will be compiled to an ordinary function that
  193. * returns a promise.
  194. *
  195. * @typedef {Function} AsyncFunction
  196. * @static
  197. */
  198. /**
  199. * Async is a utility module which provides straight-forward, powerful functions
  200. * for working with asynchronous JavaScript. Although originally designed for
  201. * use with [Node.js](http://nodejs.org) and installable via
  202. * `npm install --save async`, it can also be used directly in the browser.
  203. * @module async
  204. * @see AsyncFunction
  205. */
  206. /**
  207. * A collection of `async` functions for manipulating collections, such as
  208. * arrays and objects.
  209. * @module Collections
  210. */
  211. /**
  212. * A collection of `async` functions for controlling the flow through a script.
  213. * @module ControlFlow
  214. */
  215. /**
  216. * A collection of `async` utility functions.
  217. * @module Utils
  218. */
  219. exports.default = {
  220. apply: _apply2.default,
  221. applyEach: _applyEach2.default,
  222. applyEachSeries: _applyEachSeries2.default,
  223. asyncify: _asyncify2.default,
  224. auto: _auto2.default,
  225. autoInject: _autoInject2.default,
  226. cargo: _cargo2.default,
  227. cargoQueue: _cargoQueue2.default,
  228. compose: _compose2.default,
  229. concat: _concat2.default,
  230. concatLimit: _concatLimit2.default,
  231. concatSeries: _concatSeries2.default,
  232. constant: _constant2.default,
  233. detect: _detect2.default,
  234. detectLimit: _detectLimit2.default,
  235. detectSeries: _detectSeries2.default,
  236. dir: _dir2.default,
  237. doUntil: _doUntil2.default,
  238. doWhilst: _doWhilst2.default,
  239. each: _each2.default,
  240. eachLimit: _eachLimit2.default,
  241. eachOf: _eachOf2.default,
  242. eachOfLimit: _eachOfLimit2.default,
  243. eachOfSeries: _eachOfSeries2.default,
  244. eachSeries: _eachSeries2.default,
  245. ensureAsync: _ensureAsync2.default,
  246. every: _every2.default,
  247. everyLimit: _everyLimit2.default,
  248. everySeries: _everySeries2.default,
  249. filter: _filter2.default,
  250. filterLimit: _filterLimit2.default,
  251. filterSeries: _filterSeries2.default,
  252. forever: _forever2.default,
  253. groupBy: _groupBy2.default,
  254. groupByLimit: _groupByLimit2.default,
  255. groupBySeries: _groupBySeries2.default,
  256. log: _log2.default,
  257. map: _map2.default,
  258. mapLimit: _mapLimit2.default,
  259. mapSeries: _mapSeries2.default,
  260. mapValues: _mapValues2.default,
  261. mapValuesLimit: _mapValuesLimit2.default,
  262. mapValuesSeries: _mapValuesSeries2.default,
  263. memoize: _memoize2.default,
  264. nextTick: _nextTick2.default,
  265. parallel: _parallel2.default,
  266. parallelLimit: _parallelLimit2.default,
  267. priorityQueue: _priorityQueue2.default,
  268. queue: _queue2.default,
  269. race: _race2.default,
  270. reduce: _reduce2.default,
  271. reduceRight: _reduceRight2.default,
  272. reflect: _reflect2.default,
  273. reflectAll: _reflectAll2.default,
  274. reject: _reject2.default,
  275. rejectLimit: _rejectLimit2.default,
  276. rejectSeries: _rejectSeries2.default,
  277. retry: _retry2.default,
  278. retryable: _retryable2.default,
  279. seq: _seq2.default,
  280. series: _series2.default,
  281. setImmediate: _setImmediate2.default,
  282. some: _some2.default,
  283. someLimit: _someLimit2.default,
  284. someSeries: _someSeries2.default,
  285. sortBy: _sortBy2.default,
  286. timeout: _timeout2.default,
  287. times: _times2.default,
  288. timesLimit: _timesLimit2.default,
  289. timesSeries: _timesSeries2.default,
  290. transform: _transform2.default,
  291. tryEach: _tryEach2.default,
  292. unmemoize: _unmemoize2.default,
  293. until: _until2.default,
  294. waterfall: _waterfall2.default,
  295. whilst: _whilst2.default,
  296. // aliases
  297. all: _every2.default,
  298. allLimit: _everyLimit2.default,
  299. allSeries: _everySeries2.default,
  300. any: _some2.default,
  301. anyLimit: _someLimit2.default,
  302. anySeries: _someSeries2.default,
  303. find: _detect2.default,
  304. findLimit: _detectLimit2.default,
  305. findSeries: _detectSeries2.default,
  306. flatMap: _concat2.default,
  307. flatMapLimit: _concatLimit2.default,
  308. flatMapSeries: _concatSeries2.default,
  309. forEach: _each2.default,
  310. forEachSeries: _eachSeries2.default,
  311. forEachLimit: _eachLimit2.default,
  312. forEachOf: _eachOf2.default,
  313. forEachOfSeries: _eachOfSeries2.default,
  314. forEachOfLimit: _eachOfLimit2.default,
  315. inject: _reduce2.default,
  316. foldl: _reduce2.default,
  317. foldr: _reduceRight2.default,
  318. select: _filter2.default,
  319. selectLimit: _filterLimit2.default,
  320. selectSeries: _filterSeries2.default,
  321. wrapSync: _asyncify2.default,
  322. during: _whilst2.default,
  323. doDuring: _doWhilst2.default
  324. };
  325. exports.apply = _apply2.default;
  326. exports.applyEach = _applyEach2.default;
  327. exports.applyEachSeries = _applyEachSeries2.default;
  328. exports.asyncify = _asyncify2.default;
  329. exports.auto = _auto2.default;
  330. exports.autoInject = _autoInject2.default;
  331. exports.cargo = _cargo2.default;
  332. exports.cargoQueue = _cargoQueue2.default;
  333. exports.compose = _compose2.default;
  334. exports.concat = _concat2.default;
  335. exports.concatLimit = _concatLimit2.default;
  336. exports.concatSeries = _concatSeries2.default;
  337. exports.constant = _constant2.default;
  338. exports.detect = _detect2.default;
  339. exports.detectLimit = _detectLimit2.default;
  340. exports.detectSeries = _detectSeries2.default;
  341. exports.dir = _dir2.default;
  342. exports.doUntil = _doUntil2.default;
  343. exports.doWhilst = _doWhilst2.default;
  344. exports.each = _each2.default;
  345. exports.eachLimit = _eachLimit2.default;
  346. exports.eachOf = _eachOf2.default;
  347. exports.eachOfLimit = _eachOfLimit2.default;
  348. exports.eachOfSeries = _eachOfSeries2.default;
  349. exports.eachSeries = _eachSeries2.default;
  350. exports.ensureAsync = _ensureAsync2.default;
  351. exports.every = _every2.default;
  352. exports.everyLimit = _everyLimit2.default;
  353. exports.everySeries = _everySeries2.default;
  354. exports.filter = _filter2.default;
  355. exports.filterLimit = _filterLimit2.default;
  356. exports.filterSeries = _filterSeries2.default;
  357. exports.forever = _forever2.default;
  358. exports.groupBy = _groupBy2.default;
  359. exports.groupByLimit = _groupByLimit2.default;
  360. exports.groupBySeries = _groupBySeries2.default;
  361. exports.log = _log2.default;
  362. exports.map = _map2.default;
  363. exports.mapLimit = _mapLimit2.default;
  364. exports.mapSeries = _mapSeries2.default;
  365. exports.mapValues = _mapValues2.default;
  366. exports.mapValuesLimit = _mapValuesLimit2.default;
  367. exports.mapValuesSeries = _mapValuesSeries2.default;
  368. exports.memoize = _memoize2.default;
  369. exports.nextTick = _nextTick2.default;
  370. exports.parallel = _parallel2.default;
  371. exports.parallelLimit = _parallelLimit2.default;
  372. exports.priorityQueue = _priorityQueue2.default;
  373. exports.queue = _queue2.default;
  374. exports.race = _race2.default;
  375. exports.reduce = _reduce2.default;
  376. exports.reduceRight = _reduceRight2.default;
  377. exports.reflect = _reflect2.default;
  378. exports.reflectAll = _reflectAll2.default;
  379. exports.reject = _reject2.default;
  380. exports.rejectLimit = _rejectLimit2.default;
  381. exports.rejectSeries = _rejectSeries2.default;
  382. exports.retry = _retry2.default;
  383. exports.retryable = _retryable2.default;
  384. exports.seq = _seq2.default;
  385. exports.series = _series2.default;
  386. exports.setImmediate = _setImmediate2.default;
  387. exports.some = _some2.default;
  388. exports.someLimit = _someLimit2.default;
  389. exports.someSeries = _someSeries2.default;
  390. exports.sortBy = _sortBy2.default;
  391. exports.timeout = _timeout2.default;
  392. exports.times = _times2.default;
  393. exports.timesLimit = _timesLimit2.default;
  394. exports.timesSeries = _timesSeries2.default;
  395. exports.transform = _transform2.default;
  396. exports.tryEach = _tryEach2.default;
  397. exports.unmemoize = _unmemoize2.default;
  398. exports.until = _until2.default;
  399. exports.waterfall = _waterfall2.default;
  400. exports.whilst = _whilst2.default;
  401. exports.all = _every2.default;
  402. exports.allLimit = _everyLimit2.default;
  403. exports.allSeries = _everySeries2.default;
  404. exports.any = _some2.default;
  405. exports.anyLimit = _someLimit2.default;
  406. exports.anySeries = _someSeries2.default;
  407. exports.find = _detect2.default;
  408. exports.findLimit = _detectLimit2.default;
  409. exports.findSeries = _detectSeries2.default;
  410. exports.flatMap = _concat2.default;
  411. exports.flatMapLimit = _concatLimit2.default;
  412. exports.flatMapSeries = _concatSeries2.default;
  413. exports.forEach = _each2.default;
  414. exports.forEachSeries = _eachSeries2.default;
  415. exports.forEachLimit = _eachLimit2.default;
  416. exports.forEachOf = _eachOf2.default;
  417. exports.forEachOfSeries = _eachOfSeries2.default;
  418. exports.forEachOfLimit = _eachOfLimit2.default;
  419. exports.inject = _reduce2.default;
  420. exports.foldl = _reduce2.default;
  421. exports.foldr = _reduceRight2.default;
  422. exports.select = _filter2.default;
  423. exports.selectLimit = _filterLimit2.default;
  424. exports.selectSeries = _filterSeries2.default;
  425. exports.wrapSync = _asyncify2.default;
  426. exports.during = _whilst2.default;
  427. exports.doDuring = _doWhilst2.default;