diff --git a/.babelrc b/.babelrc index 3a1b0d44a..911ec28ad 100644 --- a/.babelrc +++ b/.babelrc @@ -1,6 +1,8 @@ { - "presets": ["es2015"], - + "plugins": [ + "transform-es2015-modules-commonjs", + "syntax-async-generators" + ], "env": { "test": { "plugins": ["istanbul"] diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..0426025b7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +dist/ +docs/ +support/jsdoc/theme/ diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 2644f5cc6..000000000 --- a/.eslintrc +++ /dev/null @@ -1,41 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "mocha": true, - "es6": true - }, - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module" - }, - "rules": { - "eqeqeq": 0, - "guard-for-in": 2, - "indent": [ - 2, - 4, - { - "SwitchCase": 1 - } - ], - "no-caller": 2, - "no-undef": 2, - "no-unused-vars": 2, - "no-eval": 2, - "comma-style": [ - 2, - "last" - ], - "semi": 0, - "no-eq-null": 0, - "no-unused-expressions": 0, - "no-loop-func": 2, - "dot-notation": 0, - "valid-jsdoc": ["error", { - "requireReturn": false, - "requireReturnDescription": false, - "requireReturnType": false - }] - } -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..af0335656 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,60 @@ +{ + "env": { + "browser": true, + "node": true, + "es2021": true + }, + "parser": "@babel/eslint-parser", + "parserOptions": { + "ecmaVersion": 8, + "sourceType": "module", + "babelOptions": { + "configFile": "./.babelrc" + } + }, + "extends": "eslint:recommended", + "rules": { + "guard-for-in": 2, + "indent": [ + 2, + 4, + { + "SwitchCase": 1 + } + ], + "no-caller": 2, + "no-undef": 2, + "no-unused-vars": 2, + "no-shadow": 2, + "no-eval": 2, + "comma-style": [ + 2, + "last" + ], + "prefer-arrow-callback": 2, + "arrow-spacing": 2, + "object-shorthand": 2, + "prefer-destructuring": 2, + "no-loop-func": 2, + "no-trailing-spaces": 2, + "valid-jsdoc": [ + "error", + { + "requireReturn": false, + "requireReturnDescription": false, + "requireReturnType": false + } + ] + }, + "overrides": [ + { + "files": [ + "support/build.test.js", + "test/**/*.js" + ], + "env": { + "mocha": true + } + } + ] +} diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index a63550f43..dd0715252 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -4,9 +4,11 @@ This template is for bug reports. If you are reporting a bug, please continue on **What version of async are you using?** -**Which environment did the issue occur in (Node version/browser version)** +**Which environment did the issue occur in (Node/browser/Babel/Typescript version)?** -**What did you do? Please include a minimal reproducable case illustrating issue.** +**Is there a compiler in your toolchain? If so, is it targeting ES2017 or later and preserving `async` functions?** + +**What did you do? Please include a minimal reproducible case illustrating issue.** **What did you expect to happen?** diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..abad457ef --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: '/' + schedule: + interval: monthly + open-pull-requests-limit: 99 + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + open-pull-requests-limit: 99 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..1a10ea8d3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: CI + +on: + push: + branches-ignore: + - "dependabot/**" + pull_request: + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + matrix: + node: + - 20 + steps: + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@v5 + + - name: โŽ” Setup node ${{ matrix.node }} + uses: actions/setup-node@v5 + with: + cache: npm + + - name: ๐Ÿ“ฅ Download deps + run: npm ci + + - name: ๐Ÿงช Run lint + run: npm run lint + + build: + permissions: + actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows + checks: write # for coverallsapp/github-action to create new checks + contents: read # for actions/checkout to fetch code + runs-on: ${{ matrix.os }} + needs: lint + strategy: + fail-fast: false + matrix: + node: + - 18 + - 20 + - 21 + os: [ubuntu-latest] + browser: + - FirefoxHeadless + include: + - os: windows-latest + node: 20 + browser: FirefoxHeadless + + steps: + - name: ๐Ÿ›‘ Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: โฌ‡๏ธ Checkout + uses: actions/checkout@v5 + + - name: โŽ” Setup node ${{ matrix.node }} + uses: actions/setup-node@v5 + with: + node-version: ${{ matrix.node }} + cache: npm + + - name: ๐Ÿ“ฅ Download deps + run: npm ci + + - name: Run coverage + run: npm test + + - name: Run browser tests + if: matrix.node == 20 + run: npm run mocha-browser-test -- --browsers ${{ matrix.browser }} --timeout 10000 + env: + DISPLAY: :99.0 + + - name: Coverage + if: matrix.os == 'ubuntu-latest' && matrix.node == '20' + run: npm run coverage && npx nyc report --reporter=lcov + + - name: Coveralls + if: matrix.os == 'ubuntu-latest' && matrix.node == '20' + uses: coverallsapp/github-action@v2.3.6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 6faca0fe3..9add602a3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ tmp build build-es .idea -docs \ No newline at end of file +*test-results.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9feb56afe..000000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: node_js -node_js: - - "0.10" - - "0.12" - - "4" - - "6" -sudo: false -after_success: npm run coveralls - -# Needed to run Karma with Firefox on Travis -# http://karma-runner.github.io/0.13/plus/travis.html -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start diff --git a/CHANGELOG.md b/CHANGELOG.md index 94cf2cab4..ce990a51c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,149 @@ +# v3.2.5 +- Ensure `Error` objects such as `AggregateError` are propagated without modification (#1920) + +# v3.2.4 +- Fix a bug in `priorityQueue` where it didn't wait for the result. (#1725) +- Fix a bug where `unshiftAsync` was included in `priorityQueue`. (#1790) + +# v3.2.3 +- Fix bugs in comment parsing in `autoInject`. (#1767, #1780) + +# v3.2.2 +- Fix potential prototype pollution exploit + +# v3.2.1 +- Use `queueMicrotask` if available to the environment (#1761) +- Minor perf improvement in `priorityQueue` (#1727) +- More examples in documentation (#1726) +- Various doc fixes (#1708, #1712, #1717, #1740, #1739, #1749, #1756) +- Improved test coverage (#1754) + +# v3.2.0 +- Fix a bug in Safari related to overwriting `func.name` +- Remove built-in browserify configuration (#1653) +- Varios doc fixes (#1688, #1703, #1704) + +# v3.1.1 +- Allow redefining `name` property on wrapped functions. + +# v3.1.0 + +- Added `q.pushAsync` and `q.unshiftAsync`, analagous to `q.push` and `q.unshift`, except they always do not accept a callback, and reject if processing the task errors. (#1659) +- Promises returned from `q.push` and `q.unshift` when a callback is not passed now resolve even if an error ocurred. (#1659) +- Fixed a parsing bug in `autoInject` with complicated function bodies (#1663) +- Added ES6+ configuration for Browserify bundlers (#1653) +- Various doc fixes (#1664, #1658, #1665, #1652) + +# v3.0.1 + +## Bug fixes +- Fixed a regression where arrays passed to `queue` and `cargo` would be completely flattened. (#1645) +- Clarified Async's browser support (#1643) + + +# v3.0.0 + +The `async`/`await` release! + +There are a lot of new features and subtle breaking changes in this major version, but the biggest feature is that most Async methods return a Promise if you omit the callback, meaning you can `await` them from within an `async` function. + +```js +const results = await async.mapLimit(urls, 5, async url => { + const resp = await fetch(url) + return resp.body +}) +``` + +## Breaking Changes +- Most Async methods return a Promise when the final callback is omitted, making them `await`-able! (#1572) +- We are now making heavy use of ES2015 features, this means we have dropped out-of-the-box support for Node 4 and earlier, and many old versions of browsers. (#1541, #1553) +- In `queue`, `priorityQueue`, `cargo` and `cargoQueue`, the "event"-style methods, like `q.drain` and `q.saturated` are now methods that register a callback, rather than properties you assign a callback to. They are now of the form `q.drain(callback)`. If you do not pass a callback a Promise will be returned for the next occurrence of the event, making them `await`-able, e.g. `await q.drain()`. (#1586, #1641) +- Calling `callback(false)` will cancel an async method, preventing further iteration and callback calls. This is useful for preventing memory leaks when you break out of an async flow by calling an outer callback. (#1064, #1542) +- `during` and `doDuring` have been removed, and instead `whilst`, `doWhilst`, `until` and `doUntil` now have asynchronous `test` functions. (#850, #1557) +- `limits` of less than 1 now cause an error to be thrown in queues and collection methods. (#1249, #1552) +- `memoize` no longer memoizes errors (#1465, #1466) +- `applyEach`/`applyEachSeries` have a simpler interface, to make them more easily type-able. It always returns a function that takes in a single callback argument. If that callback is omitted, a promise is returned, making it awaitable. (#1228, #1640) + +## New Features +- Async generators are now supported in all the Collection methods. (#1560) +- Added `cargoQueue`, a queue with both `concurrency` and `payload` size parameters. (#1567) +- Queue objects returned from `queue` now have a `Symbol.iterator` method, meaning they can be iterated over to inspect the current list of items in the queue. (#1459, #1556) +- A ESM-flavored `async.mjs` is included in the `async` package. This is described in the `package.json` `"module"` field, meaning it should be automatically used by Webpack and other compatible bundlers. + +## Bug fixes +- Better handle arbitrary error objects in `asyncify` (#1568, #1569) + +## Other +- Removed Lodash as a dependency (#1283, #1528) +- Miscellaneous docs fixes (#1393, #1501, #1540, #1543, #1558, #1563, #1564, #1579, #1581) +- Miscellaneous test fixes (#1538) + +------- + +# v2.6.1 +- Updated lodash to prevent `npm audit` warnings. (#1532, #1533) +- Made `async-es` more optimized for webpack users (#1517) +- Fixed a stack overflow with large collections and a synchronous iterator (#1514) +- Various small fixes/chores (#1505, #1511, #1527, #1530) + +# v2.6.0 +- Added missing aliases for many methods. Previously, you could not (e.g.) `require('async/find')` or use `async.anyLimit`. (#1483) +- Improved `queue` performance. (#1448, #1454) +- Add missing sourcemap (#1452, #1453) +- Various doc updates (#1448, #1471, #1483) + +# v2.5.0 +- Added `concatLimit`, the `Limit` equivalent of [`concat`](https://caolan.github.io/async/docs.html#concat) ([#1426](https://github.com/caolan/async/issues/1426), [#1430](https://github.com/caolan/async/pull/1430)) +- `concat` improvements: it now preserves order, handles falsy values and the `iteratee` callback takes a variable number of arguments ([#1437](https://github.com/caolan/async/issues/1437), [#1436](https://github.com/caolan/async/pull/1436)) +- Fixed an issue in `queue` where there was a size discrepancy between `workersList().length` and `running()` ([#1428](https://github.com/caolan/async/issues/1428), [#1429](https://github.com/caolan/async/pull/1429)) +- Various doc fixes ([#1422](https://github.com/caolan/async/issues/1422), [#1424](https://github.com/caolan/async/pull/1424)) + +# v2.4.1 +- Fixed a bug preventing functions wrapped with `timeout()` from being re-used. ([#1418](https://github.com/caolan/async/issues/1418), [#1419](https://github.com/caolan/async/issues/1419)) + +# v2.4.0 +- Added `tryEach`, for running async functions in parallel, where you only expect one to succeed. ([#1365](https://github.com/caolan/async/issues/1365), [#687](https://github.com/caolan/async/issues/687)) +- Improved performance, most notably in `parallel` and `waterfall` ([#1395](https://github.com/caolan/async/issues/1395)) +- Added `queue.remove()`, for removing items in a `queue` ([#1397](https://github.com/caolan/async/issues/1397), [#1391](https://github.com/caolan/async/issues/1391)) +- Fixed using `eval`, preventing Async from running in pages with Content Security Policy ([#1404](https://github.com/caolan/async/issues/1404), [#1403](https://github.com/caolan/async/issues/1403)) +- Fixed errors thrown in an `asyncify`ed function's callback being caught by the underlying Promise ([#1408](https://github.com/caolan/async/issues/1408)) +- Fixed timing of `queue.empty()` ([#1367](https://github.com/caolan/async/issues/1367)) +- Various doc fixes ([#1314](https://github.com/caolan/async/issues/1314), [#1394](https://github.com/caolan/async/issues/1394), [#1412](https://github.com/caolan/async/issues/1412)) + +# v2.3.0 +- Added support for ES2017 `async` functions. Wherever you can pass a Node-style/CPS function that uses a callback, you can also pass an `async` function. Previously, you had to wrap `async` functions with `asyncify`. The caveat is that it will only work if `async` functions are supported natively in your environment, transpiled implementations can't be detected. ([#1386](https://github.com/caolan/async/issues/1386), [#1390](https://github.com/caolan/async/issues/1390)) +- Small doc fix ([#1392](https://github.com/caolan/async/issues/1392)) + +# v2.2.0 +- Added `groupBy`, and the `Series`/`Limit` equivalents, analogous to [`_.groupBy`](http://lodash.com/docs#groupBy) ([#1364](https://github.com/caolan/async/issues/1364)) +- Fixed `transform` bug when `callback` was not passed ([#1381](https://github.com/caolan/async/issues/1381)) +- Added note about `reflect` to `parallel` docs ([#1385](https://github.com/caolan/async/issues/1385)) + +# v2.1.5 +- Fix `auto` bug when function names collided with Array.prototype ([#1358](https://github.com/caolan/async/issues/1358)) +- Improve some error messages ([#1349](https://github.com/caolan/async/issues/1349)) +- Avoid stack overflow case in queue +- Fixed an issue in `some`, `every` and `find` where processing would continue after the result was determined. +- Cleanup implementations of `some`, `every` and `find` + +# v2.1.3 +- Make bundle size smaller +- Create optimized hotpath for `filter` in array case. + +# v2.1.2 +- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs ([#1293](https://github.com/caolan/async/issues/1293)). + +# v2.1.0 + +- `retry` and `retryable` now support an optional `errorFilter` function that determines if the `task` should retry on the error ([#1256](https://github.com/caolan/async/issues/1256), [#1261](https://github.com/caolan/async/issues/1261)) +- Optimized array iteration in `race`, `cargo`, `queue`, and `priorityQueue` ([#1253](https://github.com/caolan/async/issues/1253)) +- Added alias documentation to doc site ([#1251](https://github.com/caolan/async/issues/1251), [#1254](https://github.com/caolan/async/issues/1254)) +- Added [BootStrap scrollspy](http://getbootstrap.com/javascript/#scrollspy) to docs to highlight in the sidebar the current method being viewed ([#1289](https://github.com/caolan/async/issues/1289), [#1300](https://github.com/caolan/async/issues/1300)) +- Various minor doc fixes ([#1263](https://github.com/caolan/async/issues/1263), [#1264](https://github.com/caolan/async/issues/1264), [#1271](https://github.com/caolan/async/issues/1271), [#1278](https://github.com/caolan/async/issues/1278), [#1280](https://github.com/caolan/async/issues/1280), [#1282](https://github.com/caolan/async/issues/1282), [#1302](https://github.com/caolan/async/issues/1302)) + # v2.0.1 -- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc (#1245, #1246, #1247). +- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc ([#1245](https://github.com/caolan/async/issues/1245), [#1246](https://github.com/caolan/async/issues/1246), [#1247](https://github.com/caolan/async/issues/1247)). # v2.0.0 @@ -23,7 +166,7 @@ Another one of the general themes of the 2.0 release is standardization of what 5. Any number of result arguments can be passed after the "error" argument 6. The callback is called once and exactly once, either on the same tick or later tick of the JavaScript event loop. -There were several cases where Async accepted some functions that did not strictly have these properties, most notably `auto`, `every`, `some`, and `filter`. +There were several cases where Async accepted some functions that did not strictly have these properties, most notably `auto`, `every`, `some`, `filter`, `reject` and `detect`. Another theme is performance. We have eliminated internal deferrals in all cases where they make sense. For example, in `waterfall` and `auto`, there was a `setImmediate` between each task -- these deferrals have been removed. A `setImmediate` call can add up to 1ms of delay. This might not seem like a lot, but it can add up if you are using many Async functions in the course of processing a HTTP request, for example. Nearly all asynchronous functions that do I/O already have some sort of deferral built in, so the extra deferral is unnecessary. The trade-off of this change is removing our built-in stack-overflow defense. Many synchronous callback calls in series can quickly overflow the JS call stack. If you do have a function that is sometimes synchronous (calling its callback on the same tick), and are running into stack overflows, wrap it with `async.ensureAsync()`. @@ -31,96 +174,96 @@ Another big performance win has been re-implementing `queue`, `cargo`, and `prio ## New Features -- Async is now modularized. Individual functions can be `require()`d from the main package. (`require('async/auto')`) (#984, #996) -- Async is also available as a collection of ES2015 modules in the new `async-es` package. (`import {forEachSeries} from 'async-es'`) (#984, #996) -- Added `race`, analogous to `Promise.race()`. It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. (#568, #1038) -- Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to `each`, `map`, `parallel`, etc.. (#579, #839, #1074) -- Added `mapValues`, for mapping over the properties of an object and returning an object with the same keys. (#1157, #1177) -- Added `timeout`, a wrapper for an async function that will make the task time-out after the specified time. (#1007, #1027) -- Added `reflect` and `reflectAll`, analagous to [`Promise.reflect()`](http://bluebirdjs.com/docs/api/reflect.html), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. (#942, #1012, #1095) -- `constant` supports dynamic arguments -- it will now always use its last argument as the callback. (#1016, #1052) -- `setImmediate` and `nextTick` now support arguments to partially apply to the deferred function, like the node-native versions do. (#940, #1053) -- `auto` now supports resolving cyclic dependencies using [Kahn's algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) (#1140). -- Added `autoInject`, a relative of `auto` that automatically spreads a task's dependencies as arguments to the task function. (#608, #1055, #1099, #1100) -- You can now limit the concurrency of `auto` tasks. (#635, #637) -- Added `retryable`, a relative of `retry` that wraps an async function, making it retry when called. (#1058) -- `retry` now supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies. (#1161) -- `retry` will now pass all of the arguments the task function was resolved with to the callback (#1231). -- Added `q.unsaturated` -- callback called when a `queue`'s number of running workers falls below a threshold. (#868, #1030, #1033, #1034) -- Added `q.error` -- a callback called whenever a `queue` task calls its callback with an error. (#1170) -- `applyEach` and `applyEachSeries` now pass results to the final callback. (#1088) +- Async is now modularized. Individual functions can be `require()`d from the main package. (`require('async/auto')`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996)) +- Async is also available as a collection of ES2015 modules in the new `async-es` package. (`import {forEachSeries} from 'async-es'`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996)) +- Added `race`, analogous to `Promise.race()`. It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. ([#568](https://github.com/caolan/async/issues/568), [#1038](https://github.com/caolan/async/issues/1038)) +- Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to `each`, `map`, `parallel`, etc.. ([#579](https://github.com/caolan/async/issues/579), [#839](https://github.com/caolan/async/issues/839), [#1074](https://github.com/caolan/async/issues/1074)) +- Added `mapValues`, for mapping over the properties of an object and returning an object with the same keys. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177)) +- Added `timeout`, a wrapper for an async function that will make the task time-out after the specified time. ([#1007](https://github.com/caolan/async/issues/1007), [#1027](https://github.com/caolan/async/issues/1027)) +- Added `reflect` and `reflectAll`, analagous to [`Promise.reflect()`](http://bluebirdjs.com/docs/api/reflect.html), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. ([#942](https://github.com/caolan/async/issues/942), [#1012](https://github.com/caolan/async/issues/1012), [#1095](https://github.com/caolan/async/issues/1095)) +- `constant` supports dynamic arguments -- it will now always use its last argument as the callback. ([#1016](https://github.com/caolan/async/issues/1016), [#1052](https://github.com/caolan/async/issues/1052)) +- `setImmediate` and `nextTick` now support arguments to partially apply to the deferred function, like the node-native versions do. ([#940](https://github.com/caolan/async/issues/940), [#1053](https://github.com/caolan/async/issues/1053)) +- `auto` now supports resolving cyclic dependencies using [Kahn's algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) ([#1140](https://github.com/caolan/async/issues/1140)). +- Added `autoInject`, a relative of `auto` that automatically spreads a task's dependencies as arguments to the task function. ([#608](https://github.com/caolan/async/issues/608), [#1055](https://github.com/caolan/async/issues/1055), [#1099](https://github.com/caolan/async/issues/1099), [#1100](https://github.com/caolan/async/issues/1100)) +- You can now limit the concurrency of `auto` tasks. ([#635](https://github.com/caolan/async/issues/635), [#637](https://github.com/caolan/async/issues/637)) +- Added `retryable`, a relative of `retry` that wraps an async function, making it retry when called. ([#1058](https://github.com/caolan/async/issues/1058)) +- `retry` now supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies. ([#1161](https://github.com/caolan/async/issues/1161)) +- `retry` will now pass all of the arguments the task function was resolved with to the callback ([#1231](https://github.com/caolan/async/issues/1231)). +- Added `q.unsaturated` -- callback called when a `queue`'s number of running workers falls below a threshold. ([#868](https://github.com/caolan/async/issues/868), [#1030](https://github.com/caolan/async/issues/1030), [#1033](https://github.com/caolan/async/issues/1033), [#1034](https://github.com/caolan/async/issues/1034)) +- Added `q.error` -- a callback called whenever a `queue` task calls its callback with an error. ([#1170](https://github.com/caolan/async/issues/1170)) +- `applyEach` and `applyEachSeries` now pass results to the final callback. ([#1088](https://github.com/caolan/async/issues/1088)) ## Breaking changes -- Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in `waterfall`. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. (#814, #815, #1048, #1050) -- `auto` task functions now always take the callback as the last argument. If a task has dependencies, the `results` object will be passed as the first argument. To migrate old task functions, wrap them with [`_.flip`](https://lodash.com/docs#flip) (#1036, #1042) -- Internal `setImmediate` calls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. Use `ensureAsync` to work around this. (#696, #704, #1049, #1050) -- `map` used to return an object when iterating over an object. `map` now always returns an array, like in other libraries. The previous object behavior has been split out into `mapValues`. (#1157, #1177) -- `filter`, `reject`, `some`, `every`, and related functions now expect an error as the first callback argument, rather than just a simple boolean. Pass `null` as the first argument, or use `fs.access` instead of `fs.exists`. (#118, #774, #1028, #1041) -- `{METHOD}` and `{METHOD}Series` are now implemented in terms of `{METHOD}Limit`. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. (#778, #847) -- `retry`'s callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task to `series` or `auto`. The partially applied "control-flow" behavior has been separated out into `retryable`. (#1054, #1058) -- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function (#1217, #1224) -- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs (#1205). -- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. (#724, #1078) -- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays (#1237) -- Dropped support for Component, Jam, SPM, and Volo (#1175, ##176) +- Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in `waterfall`. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. ([#814](https://github.com/caolan/async/issues/814), [#815](https://github.com/caolan/async/issues/815), [#1048](https://github.com/caolan/async/issues/1048), [#1050](https://github.com/caolan/async/issues/1050)) +- `auto` task functions now always take the callback as the last argument. If a task has dependencies, the `results` object will be passed as the first argument. To migrate old task functions, wrap them with [`_.flip`](https://lodash.com/docs#flip) ([#1036](https://github.com/caolan/async/issues/1036), [#1042](https://github.com/caolan/async/issues/1042)) +- Internal `setImmediate` calls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. Use `ensureAsync` to work around this. ([#696](https://github.com/caolan/async/issues/696), [#704](https://github.com/caolan/async/issues/704), [#1049](https://github.com/caolan/async/issues/1049), [#1050](https://github.com/caolan/async/issues/1050)) +- `map` used to return an object when iterating over an object. `map` now always returns an array, like in other libraries. The previous object behavior has been split out into `mapValues`. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177)) +- `filter`, `reject`, `some`, `every`, `detect` and their families like `{METHOD}Series` and `{METHOD}Limit` now expect an error as the first callback argument, rather than just a simple boolean. Pass `null` as the first argument, or use `fs.access` instead of `fs.exists`. ([#118](https://github.com/caolan/async/issues/118), [#774](https://github.com/caolan/async/issues/774), [#1028](https://github.com/caolan/async/issues/1028), [#1041](https://github.com/caolan/async/issues/1041)) +- `{METHOD}` and `{METHOD}Series` are now implemented in terms of `{METHOD}Limit`. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. ([#778](https://github.com/caolan/async/issues/778), [#847](https://github.com/caolan/async/issues/847)) +- `retry`'s callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task to `series` or `auto`. The partially applied "control-flow" behavior has been separated out into `retryable`. ([#1054](https://github.com/caolan/async/issues/1054), [#1058](https://github.com/caolan/async/issues/1058)) +- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function ([#1217](https://github.com/caolan/async/issues/1217), [#1224](https://github.com/caolan/async/issues/1224)) +- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs ([#1205](https://github.com/caolan/async/issues/1205)). +- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. ([#724](https://github.com/caolan/async/issues/724), [#1078](https://github.com/caolan/async/issues/1078)) +- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays ([#1237](https://github.com/caolan/async/issues/1237)) +- Dropped support for Component, Jam, SPM, and Volo ([#1175](https://github.com/caolan/async/issues/1175), #[#176](https://github.com/caolan/async/issues/176)) ## Bug Fixes -- Improved handling of no dependency cases in `auto` & `autoInject` (#1147). -- Fixed a bug where the callback generated by `asyncify` with `Promises` could resolve twice (#1197). -- Fixed several documented optional callbacks not actually being optional (#1223). +- Improved handling of no dependency cases in `auto` & `autoInject` ([#1147](https://github.com/caolan/async/issues/1147)). +- Fixed a bug where the callback generated by `asyncify` with `Promises` could resolve twice ([#1197](https://github.com/caolan/async/issues/1197)). +- Fixed several documented optional callbacks not actually being optional ([#1223](https://github.com/caolan/async/issues/1223)). ## Other - Added `someSeries` and `everySeries` for symmetry, as well as a complete set of `any`/`anyLimit`/`anySeries` and `all`/`/allLmit`/`allSeries` aliases. - Added `find` as an alias for `detect. (as well as `findLimit` and `findSeries`). -- Various doc fixes (#1005, #1008, #1010, #1015, #1021, #1037, #1039, #1051, #1102, #1107, #1121, #1123, #1129, #1135, #1138, #1141, #1153, #1216, #1217, #1232, #1233, #1236, #1238) +- Various doc fixes ([#1005](https://github.com/caolan/async/issues/1005), [#1008](https://github.com/caolan/async/issues/1008), [#1010](https://github.com/caolan/async/issues/1010), [#1015](https://github.com/caolan/async/issues/1015), [#1021](https://github.com/caolan/async/issues/1021), [#1037](https://github.com/caolan/async/issues/1037), [#1039](https://github.com/caolan/async/issues/1039), [#1051](https://github.com/caolan/async/issues/1051), [#1102](https://github.com/caolan/async/issues/1102), [#1107](https://github.com/caolan/async/issues/1107), [#1121](https://github.com/caolan/async/issues/1121), [#1123](https://github.com/caolan/async/issues/1123), [#1129](https://github.com/caolan/async/issues/1129), [#1135](https://github.com/caolan/async/issues/1135), [#1138](https://github.com/caolan/async/issues/1138), [#1141](https://github.com/caolan/async/issues/1141), [#1153](https://github.com/caolan/async/issues/1153), [#1216](https://github.com/caolan/async/issues/1216), [#1217](https://github.com/caolan/async/issues/1217), [#1232](https://github.com/caolan/async/issues/1232), [#1233](https://github.com/caolan/async/issues/1233), [#1236](https://github.com/caolan/async/issues/1236), [#1238](https://github.com/caolan/async/issues/1238)) Thank you [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for taking the lead on version 2 of async. ------------------------------------------ # v1.5.2 -- Allow using `"constructor"` as an argument in `memoize` (#998) -- Give a better error messsage when `auto` dependency checking fails (#994) -- Various doc updates (#936, #956, #979, #1002) +- Allow using `"constructor"` as an argument in `memoize` ([#998](https://github.com/caolan/async/issues/998)) +- Give a better error messsage when `auto` dependency checking fails ([#994](https://github.com/caolan/async/issues/994)) +- Various doc updates ([#936](https://github.com/caolan/async/issues/936), [#956](https://github.com/caolan/async/issues/956), [#979](https://github.com/caolan/async/issues/979), [#1002](https://github.com/caolan/async/issues/1002)) # v1.5.1 -- Fix issue with `pause` in `queue` with concurrency enabled (#946) -- `while` and `until` now pass the final result to callback (#963) -- `auto` will properly handle concurrency when there is no callback (#966) -- `auto` will no. properly stop execution when an error occurs (#988, #993) -- Various doc fixes (#971, #980) +- Fix issue with `pause` in `queue` with concurrency enabled ([#946](https://github.com/caolan/async/issues/946)) +- `while` and `until` now pass the final result to callback ([#963](https://github.com/caolan/async/issues/963)) +- `auto` will properly handle concurrency when there is no callback ([#966](https://github.com/caolan/async/issues/966)) +- `auto` will no. properly stop execution when an error occurs ([#988](https://github.com/caolan/async/issues/988), [#993](https://github.com/caolan/async/issues/993)) +- Various doc fixes ([#971](https://github.com/caolan/async/issues/971), [#980](https://github.com/caolan/async/issues/980)) # v1.5.0 -- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) (#892) -- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. (#873) -- `auto` now accepts an optional `concurrency` argument to limit the number o. running tasks (#637) -- Added `queue#workersList()`, to retrieve the lis. of currently running tasks. (#891) -- Various code simplifications (#896, #904) -- Various doc fixes :scroll: (#890, #894, #903, #905, #912) +- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) ([#892](https://github.com/caolan/async/issues/892)) +- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. ([#873](https://github.com/caolan/async/issues/873)) +- `auto` now accepts an optional `concurrency` argument to limit the number o. running tasks ([#637](https://github.com/caolan/async/issues/637)) +- Added `queue#workersList()`, to retrieve the lis. of currently running tasks. ([#891](https://github.com/caolan/async/issues/891)) +- Various code simplifications ([#896](https://github.com/caolan/async/issues/896), [#904](https://github.com/caolan/async/issues/904)) +- Various doc fixes :scroll: ([#890](https://github.com/caolan/async/issues/890), [#894](https://github.com/caolan/async/issues/894), [#903](https://github.com/caolan/async/issues/903), [#905](https://github.com/caolan/async/issues/905), [#912](https://github.com/caolan/async/issues/912)) # v1.4.2 -- Ensure coverage files don't get published on npm (#879) +- Ensure coverage files don't get published on npm ([#879](https://github.com/caolan/async/issues/879)) # v1.4.1 -- Add in overlooked `detectLimit` method (#866) -- Removed unnecessary files from npm releases (#861) -- Removed usage of a reserved word to prevent :boom: in older environments (#870) +- Add in overlooked `detectLimit` method ([#866](https://github.com/caolan/async/issues/866)) +- Removed unnecessary files from npm releases ([#861](https://github.com/caolan/async/issues/861)) +- Removed usage of a reserved word to prevent :boom: in older environments ([#870](https://github.com/caolan/async/issues/870)) # v1.4.0 -- `asyncify` now supports promises (#840) -- Added `Limit` versions of `filter` and `reject` (#836) -- Add `Limit` versions of `detect`, `some` and `every` (#828, #829) -- `some`, `every` and `detect` now short circuit early (#828, #829) -- Improve detection of the global object (#804), enabling use in WebWorkers -- `whilst` now called with arguments from iterator (#823) -- `during` now gets called with arguments from iterator (#824) +- `asyncify` now supports promises ([#840](https://github.com/caolan/async/issues/840)) +- Added `Limit` versions of `filter` and `reject` ([#836](https://github.com/caolan/async/issues/836)) +- Add `Limit` versions of `detect`, `some` and `every` ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829)) +- `some`, `every` and `detect` now short circuit early ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829)) +- Improve detection of the global object ([#804](https://github.com/caolan/async/issues/804)), enabling use in WebWorkers +- `whilst` now called with arguments from iterator ([#823](https://github.com/caolan/async/issues/823)) +- `during` now gets called with arguments from iterator ([#824](https://github.com/caolan/async/issues/824)) - Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0)) @@ -128,42 +271,42 @@ Thank you [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac New Features: - Added `constant` -- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. (#671, #806) -- Added `during` and `doDuring`, which are like `whilst` with an async truth test. (#800) -- `retry` now accepts an `interval` parameter to specify a delay between retries. (#793) -- `async` should work better in Web Workers due to better `root` detection (#804) -- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` (#642) -- Various internal updates (#786, #801, #802, #803) -- Various doc fixes (#790, #794) +- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. ([#671](https://github.com/caolan/async/issues/671), [#806](https://github.com/caolan/async/issues/806)) +- Added `during` and `doDuring`, which are like `whilst` with an async truth test. ([#800](https://github.com/caolan/async/issues/800)) +- `retry` now accepts an `interval` parameter to specify a delay between retries. ([#793](https://github.com/caolan/async/issues/793)) +- `async` should work better in Web Workers due to better `root` detection ([#804](https://github.com/caolan/async/issues/804)) +- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` ([#642](https://github.com/caolan/async/issues/642)) +- Various internal updates ([#786](https://github.com/caolan/async/issues/786), [#801](https://github.com/caolan/async/issues/801), [#802](https://github.com/caolan/async/issues/802), [#803](https://github.com/caolan/async/issues/803)) +- Various doc fixes ([#790](https://github.com/caolan/async/issues/790), [#794](https://github.com/caolan/async/issues/794)) Bug Fixes: -- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. (#740, #744, #783) +- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. ([#740](https://github.com/caolan/async/issues/740), [#744](https://github.com/caolan/async/issues/744), [#783](https://github.com/caolan/async/issues/783)) # v1.2.1 Bug Fix: -- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782) +- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782)) # v1.2.0 New Features: -- Added `timesLimit` (#743) -- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. (#747, #772) +- Added `timesLimit` ([#743](https://github.com/caolan/async/issues/743)) +- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. ([#747](https://github.com/caolan/async/issues/747), [#772](https://github.com/caolan/async/issues/772)) Bug Fixes: -- Fixed a regression in `each` and family with empty arrays that have additional properties. (#775, #777) +- Fixed a regression in `each` and family with empty arrays that have additional properties. ([#775](https://github.com/caolan/async/issues/775), [#777](https://github.com/caolan/async/issues/777)) # v1.1.1 Bug Fix: -- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. (#782) +- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782)) # v1.1.0 @@ -171,23 +314,23 @@ Bug Fix: New Features: - `cargo` now supports all of the same methods and event callbacks as `queue`. -- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. (#769) +- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. ([#769](https://github.com/caolan/async/issues/769)) - Optimized `map`, `eachOf`, and `waterfall` families of functions -- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array (#667). -- The callback is now optional for the composed results of `compose` and `seq`. (#618) +- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array ([#667](https://github.com/caolan/async/issues/667)). +- The callback is now optional for the composed results of `compose` and `seq`. ([#618](https://github.com/caolan/async/issues/618)) - Reduced file size by 4kb, (minified version by 1kb) -- Added code coverage through `nyc` and `coveralls` (#768) +- Added code coverage through `nyc` and `coveralls` ([#768](https://github.com/caolan/async/issues/768)) Bug Fixes: -- `forever` will no longer stack overflow with a synchronous iterator (#622) -- `eachLimit` and other limit functions will stop iterating once an error occurs (#754) -- Always pass `null` in callbacks when there is no error (#439) -- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue (#668) -- `each` and family will properly handle an empty array (#578) -- `eachSeries` and family will finish if the underlying array is modified during execution (#557) -- `queue` will throw if a non-function is passed to `q.push()` (#593) -- Doc fixes (#629, #766) +- `forever` will no longer stack overflow with a synchronous iterator ([#622](https://github.com/caolan/async/issues/622)) +- `eachLimit` and other limit functions will stop iterating once an error occurs ([#754](https://github.com/caolan/async/issues/754)) +- Always pass `null` in callbacks when there is no error ([#439](https://github.com/caolan/async/issues/439)) +- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue ([#668](https://github.com/caolan/async/issues/668)) +- `each` and family will properly handle an empty array ([#578](https://github.com/caolan/async/issues/578)) +- `eachSeries` and family will finish if the underlying array is modified during execution ([#557](https://github.com/caolan/async/issues/557)) +- `queue` will throw if a non-function is passed to `q.push()` ([#593](https://github.com/caolan/async/issues/593)) +- Doc fixes ([#629](https://github.com/caolan/async/issues/629), [#766](https://github.com/caolan/async/issues/766)) # v1.0.0 @@ -197,12 +340,12 @@ No known breaking changes, we are simply complying with semver from here on out. Changes: - Start using a changelog! -- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) (#168 #704 #321) -- Detect deadlocks in `auto` (#663) -- Better support for require.js (#527) -- Throw if queue created with concurrency `0` (#714) -- Fix unneeded iteration in `queue.resume()` (#758) -- Guard against timer mocking overriding `setImmediate` (#609 #611) -- Miscellaneous doc fixes (#542 #596 #615 #628 #631 #690 #729) -- Use single noop function internally (#546) +- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) ([#168](https://github.com/caolan/async/issues/168) [#704](https://github.com/caolan/async/issues/704) [#321](https://github.com/caolan/async/issues/321)) +- Detect deadlocks in `auto` ([#663](https://github.com/caolan/async/issues/663)) +- Better support for require.js ([#527](https://github.com/caolan/async/issues/527)) +- Throw if queue created with concurrency `0` ([#714](https://github.com/caolan/async/issues/714)) +- Fix unneeded iteration in `queue.resume()` ([#758](https://github.com/caolan/async/issues/758)) +- Guard against timer mocking overriding `setImmediate` ([#609](https://github.com/caolan/async/issues/609) [#611](https://github.com/caolan/async/issues/611)) +- Miscellaneous doc fixes ([#542](https://github.com/caolan/async/issues/542) [#596](https://github.com/caolan/async/issues/596) [#615](https://github.com/caolan/async/issues/615) [#628](https://github.com/caolan/async/issues/628) [#631](https://github.com/caolan/async/issues/631) [#690](https://github.com/caolan/async/issues/690) [#729](https://github.com/caolan/async/issues/729)) +- Use single noop function internally ([#546](https://github.com/caolan/async/issues/546)) - Optimize internal `_each`, `_map` and `_keys` functions. diff --git a/LICENSE b/LICENSE index 9fe85b9d8..b18aed692 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2016 Caolan McMahon +Copyright (c) 2010-2018 Caolan McMahon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index deeb78b83..ec36a9114 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# This makefile is meant to be run on OSX/Linux. Make sure any artifacts +# This makefile is meant to be run on OSX/Linux. Make sure any dist/ artifacts # created here are checked in so people on all platforms can run npm scripts. # This build should be run once per release. @@ -7,25 +7,47 @@ export PATH := ./node_modules/.bin/:$(PATH):./bin/ PACKAGE = asyncjs REQUIRE_NAME = async -BABEL_NODE = babel-node -UGLIFY = uglifyjs XYZ = support/xyz.sh --repo git@github.com:caolan/async.git BUILDDIR = build BUILD_ES = build-es DIST = dist -SRC = lib/index.js +JS_INDEX = lib/index.js SCRIPTS = ./support -JS_SRC = $(shell find lib/ -type f -name '*.js') -LINT_FILES = lib/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) $(shell find support/ -maxdepth 2 -type f -name "*.js") karma.conf.js - -UMD_BUNDLE = $(BUILDDIR)/dist/async.js -UMD_BUNDLE_MIN = $(BUILDDIR)/dist/async.min.js -CJS_BUNDLE = $(BUILDDIR)/index.js -ES_MODULES = $(patsubst lib/%.js, build-es/%.js, $(JS_SRC)) - - -all: clean lint build test +JS_SRC := $(shell find lib/ -type f -name '*.js') lib/index.js lib/asyncify.js +INDEX_SRC := $(filter-out $(JS_INDEX),$(JS_SRC)) $(SCRIPTS)/index-template.js $(SCRIPTS)/aliases.txt ${SCRIPTS}/generate-index.js +LINT_FILES := lib/ test/ $(shell find perf/ -maxdepth 2 -type f) $(shell find support/ -maxdepth 2 -type f -name "*.js") karma.conf.js + +UMD_BUNDLE := $(BUILDDIR)/dist/async.js +UMD_BUNDLE_MIN := $(BUILDDIR)/dist/async.min.js +MJS_BUNDLE := $(BUILDDIR)/dist/async.mjs +# UMD_BUNDLE_MAP := $(BUILDDIR)/dist/async.min.map +ALIAS_ES := $(addprefix build-es/, $(addsuffix .js, $(shell cat $(SCRIPTS)/aliases.txt | cut -d ' ' -f1))) +ALIAS_CJS := $(patsubst build-es/%, build/%, $(ALIAS_ES)) +ES_MODULES := $(patsubst lib/%.js, build-es/%.js, $(JS_SRC)) $(ALIAS_ES) +CJS_MODULES := $(patsubst lib/%.js, build/%.js, $(JS_SRC)) $(ALIAS_CJS) + +define ALIAS_SRC = +$(shell cat $(SCRIPTS)/aliases.txt | grep "$(basename $(notdir $(1))) " | cut -d" " -f2 ) +endef + +define COMPILE_ALIAS = +SRC_$(A) := lib/$(call ALIAS_SRC,$(A)).js +$(A): $$(SRC_$(A)) + mkdir -p "$$(@D)" + node $$(SCRIPTS)/build/compile-module.js --file $$< --output $$@ +endef +$(foreach A,$(ALIAS_CJS),$(eval $(COMPILE_ALIAS))) + +define COPY_ES_ALIAS = +SRC_$(A) := lib/$(call ALIAS_SRC,$(A)).js +$(A): $$(SRC_$(A)) + mkdir -p "$$(@D)" + cp $$< $$@ +endef +$(foreach A,$(ALIAS_ES),$(eval $(COPY_ES_ALIAS))) + +all: lint build test test: npm test @@ -34,37 +56,43 @@ clean: rm -rf $(BUILDDIR) rm -rf $(BUILD_ES) rm -rf $(DIST) - rm -rf tmp/ docs/ .nyc_output/ coverage/ + rm -rf $(JS_INDEX) + rm -rf tmp/ .nyc_output/ coverage/ rm -rf perf/versions/ lint: - eslint $(LINT_FILES) + eslint --fix $(LINT_FILES) # Compile the ES6 modules to singular bundles, and individual bundles -build-bundle: build-modules $(UMD_BUNDLE) $(CJS_BUNDLE) +build-bundle: build-modules $(UMD_BUNDLE) $(MJS_BUNDLE) + +build-modules: $(CJS_MODULES) -build-modules: - $(BABEL_NODE) $(SCRIPTS)/build/modules-cjs.js +$(JS_INDEX): $(INDEX_SRC) + node $(SCRIPTS)/generate-index.js > $@ -$(UMD_BUNDLE): $(JS_SRC) package.json +$(BUILDDIR)/%.js: lib/%.js mkdir -p "$(@D)" - $(BABEL_NODE) $(SCRIPTS)/build/aggregate-bundle.js + node $(SCRIPTS)/build/compile-module.js --file $< --output $@ -$(CJS_BUNDLE): $(JS_SRC) package.json - $(BABEL_NODE) $(SCRIPTS)/build/aggregate-cjs.js + +$(UMD_BUNDLE): $(ES_MODULES) package.json + mkdir -p "$(@D)" + node $(SCRIPTS)/build/aggregate-bundle.js + +$(MJS_BUNDLE): $(ES_MODULES) package.json + mkdir -p "$(@D)" + node $(SCRIPTS)/build/aggregate-module.js # Create the minified UMD versions and copy them to dist/ for bower -build-dist: $(DIST) $(UMD_BUNDLE) $(UMD_BUNDLE_MIN) $(DIST)/async.js $(DIST)/async.min.js +build-dist: $(DIST) $(DIST)/async.js $(DIST)/async.min.js # $(DIST)/async.min.map $(DIST): mkdir -p $@ $(UMD_BUNDLE_MIN): $(UMD_BUNDLE) mkdir -p "$(@D)" - $(UGLIFY) $< --mangle --compress \ - --source-map $(DIST)/async.min.map \ - --source-map-url async.min.map \ - -o $@ + babel-minify $< --mangle -o $@ $(DIST)/async.js: $(UMD_BUNDLE) cp $< $@ @@ -72,13 +100,16 @@ $(DIST)/async.js: $(UMD_BUNDLE) $(DIST)/async.min.js: $(UMD_BUNDLE_MIN) cp $< $@ +# $(DIST)/async.min.map: $(UMD_BUNDLE_MIN) +# cp $(UMD_BUNDLE_MAP) $@ + build-es: $(ES_MODULES) $(BUILD_ES)/%.js: lib/%.js mkdir -p "$(@D)" - sed -E "s/(import.+)lodash/\1lodash-es/g" $< > $@ + cat $< > $@ -test-build: +test-build: $(UMD_BUNDLE) $(UMD_BUNDLE_MIN) $(ES_MODULES) $(CJS_MODULES) mocha support/build.test.js build-config: $(BUILDDIR)/package.json $(BUILDDIR)/bower.json $(BUILDDIR)/README.md $(BUILDDIR)/LICENSE $(BUILDDIR)/CHANGELOG.md @@ -97,19 +128,25 @@ $(BUILD_ES)/package.json: package.json mkdir -p "$(@D)" support/sync-es-package.js > $@ +$(BUILD_ES)/README.md: README.es.md + mkdir -p "$(@D)" + cp $< $@ + $(BUILD_ES)/%: % mkdir -p "$(@D)" cp $< $@ .PHONY: build-modules build-bundle build-dist build-es build-config build-es-config test-build -build: clean build-bundle build-dist build-es build-config build-es-config test-build +build: build-bundle build-dist build-es build-config build-es-config test-build .PHONY: test lint build all clean .PHONY: release-major release-minor release-patch release-prerelease -release-major release-minor release-patch release-prerelease: all - npm i # ensure dependencies are up to date (#1158) +release-major release-minor release-patch release-prerelease: + $(MAKE) clean + $(MAKE) all + npm ci # ensure dependencies are up to date (#1158) git add --force $(DIST) git commit -am "Update built files"; true $(XYZ) --increment $(@:release-%=%) @@ -126,7 +163,7 @@ doc: node support/jsdoc/jsdoc-fix-html.js publish-doc: doc - git diff-files --quiet # fail if unstanged changes - git diff-index --quiet HEAD # fail if uncommited changes - npm run-script jsdoc - gh-pages-deploy + +.PHONY: list +list: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' diff --git a/README.es.md b/README.es.md new file mode 100644 index 000000000..2d1f83c03 --- /dev/null +++ b/README.es.md @@ -0,0 +1,58 @@ +![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg) + +![Github Actions CI status](https://github.com/caolan/async/actions/workflows/ci.yml/badge.svg) +[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async) +[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master) +[![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) +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async) + + +Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser. + +This version of the package is optimized for building with webpack. If you use Async in Node.js, install [`async`](https://www.npmjs.com/package/async) instead. + +For Documentation, visit + +*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)* + + +```javascript +// for use with callbacks... +import { forEachOf } from "async-es"; + +const images = {cat: "/cat.png", dog: "/dog.png", duck: "/duck.png"}; +const sizes = {}; + +forEachOf(images, (value, key, callback) => { + const imageElem = new Image(); + imageElem.src = value; + imageElem.addEventListener("load", () => { + sizes[key] = { + width: imageElem.naturalWidth, + height: imageElem.naturalHeight, + }; + callback(); + }); + imageElem.addEventListener("error", (e) => { + callback(e); + }); +}, err => { + if (err) console.error(err.message); + // `sizes` is now a map of image sizes + doSomethingWith(sizes); +}); +``` + +```javascript +import { mapLimit } from "async-es"; + +// ...or ES2017 async functions +mapLimit(urls, 5, async function(url) { + const response = await fetch(url) + return response.body +}, (err, results) => { + if (err) throw err + // results is now an array of the response bodies + console.log(results) +}) +``` diff --git a/README.md b/README.md index aece50987..55a0626de 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,59 @@ ![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg) -[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async) +![Github Actions CI status](https://github.com/caolan/async/actions/workflows/ci.yml/badge.svg) [![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async) [![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master) [![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) +[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async) -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. + -For Documentation, visit +Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/v3/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm i async`, it can also be used directly in the browser. An ESM/MJS version is included in the main `async` package that should automatically be used with compatible bundlers such as Webpack and Rollup. + +A pure ESM version of Async is available as [`async-es`](https://www.npmjs.com/package/async-es). + +For Documentation, visit *For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)* + + +```javascript +// for use with Node-style callbacks... +var async = require("async"); + +var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; +var configs = {}; + +async.forEachOf(obj, (value, key, callback) => { + fs.readFile(__dirname + value, "utf8", (err, data) => { + if (err) return callback(err); + try { + configs[key] = JSON.parse(data); + } catch (e) { + return callback(e); + } + callback(); + }); +}, err => { + if (err) console.error(err.message); + // configs is now a map of JSON data + doSomethingWith(configs); +}); +``` + +```javascript +var async = require("async"); + +// ...or ES2017 async functions +async.mapLimit(urls, 5, async function(url) { + const response = await fetch(url) + return response.body +}, (err, results) => { + if (err) throw err + // results is now an array of the response bodies + console.log(results) +}) +``` diff --git a/bower.json b/bower.json index 7dbeb1497..390c6502f 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,7 @@ "ignore": [ "bower_components", "lib", - "mocha_test", + "test", "node_modules", "perf", "support", diff --git a/dist/async.js b/dist/async.js index 6058c54c4..d7b791898 100644 --- a/dist/async.js +++ b/dist/async.js @@ -1,4998 +1,6061 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.async = global.async || {}))); -}(this, function (exports) { 'use strict'; - - /** - * A faster alternative to `Function#apply`, this function invokes `func` - * with the `this` binding of `thisArg` and the arguments of `args`. - * - * @private - * @param {Function} func The function to invoke. - * @param {*} thisArg The `this` binding of `func`. - * @param {Array} args The arguments to invoke `func` with. - * @returns {*} Returns the result of `func`. - */ - function apply(func, thisArg, args) { - switch (args.length) { - case 0: return func.call(thisArg); - case 1: return func.call(thisArg, args[0]); - case 2: return func.call(thisArg, args[0], args[1]); - case 3: return func.call(thisArg, args[0], args[1], args[2]); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.async = {})); +})(this, (function (exports) { 'use strict'; + + /** + * Creates a continuation function with some arguments already applied. + * + * Useful as a shorthand when combined with other control flow functions. Any + * arguments passed to the returned function are added to the arguments + * originally passed to apply. + * + * @name apply + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {Function} fn - The function you want to eventually apply all + * arguments to. Invokes with (arguments...). + * @param {...*} arguments... - Any number of arguments to automatically apply + * when the continuation is called. + * @returns {Function} the partially-applied function + * @example + * + * // using apply + * async.parallel([ + * async.apply(fs.writeFile, 'testfile1', 'test1'), + * async.apply(fs.writeFile, 'testfile2', 'test2') + * ]); + * + * + * // the same process without using apply + * async.parallel([ + * function(callback) { + * fs.writeFile('testfile1', 'test1', callback); + * }, + * function(callback) { + * fs.writeFile('testfile2', 'test2', callback); + * } + * ]); + * + * // It's possible to pass any number of additional arguments when calling the + * // continuation: + * + * node> var fn = async.apply(sys.puts, 'one'); + * node> fn('two', 'three'); + * one + * two + * three + */ + function apply(fn, ...args) { + return (...callArgs) => fn(...args,...callArgs); } - return func.apply(thisArg, args); - } - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeMax = Math.max; - - /** - * The base implementation of `_.rest` which doesn't validate or coerce arguments. - * - * @private - * @param {Function} func The function to apply a rest parameter to. - * @param {number} [start=func.length-1] The start position of the rest parameter. - * @returns {Function} Returns the new function. - */ - function baseRest(func, start) { - start = nativeMax(start === undefined ? (func.length - 1) : start, 0); - return function() { - var args = arguments, - index = -1, - length = nativeMax(args.length - start, 0), - array = Array(length); - - while (++index < length) { - array[index] = args[start + index]; - } - index = -1; - var otherArgs = Array(start + 1); - while (++index < start) { - otherArgs[index] = args[index]; - } - otherArgs[start] = array; - return apply(func, this, otherArgs); - }; - } - - function initialParams (fn) { - return baseRest(function (args /*..., callback*/) { - var callback = args.pop(); - fn.call(this, args, callback); - }); - } - - function applyEach$1(eachfn) { - return baseRest(function (fns, args) { - var go = initialParams(function (args, callback) { - var that = this; - return eachfn(fns, function (fn, cb) { - fn.apply(that, args.concat([cb])); - }, callback); - }); - if (args.length) { - return go.apply(this, args); - } else { - return go; - } - }); - } - - /** - * The base implementation of `_.property` without support for deep paths. - * - * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. - */ - function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; - } - - /** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a - * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects - * Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ - var getLength = baseProperty('length'); - - /** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ - function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); - } - - var funcTag = '[object Function]'; - var genTag = '[object GeneratorFunction]'; - /** Used for built-in method references. */ - var objectProto = Object.prototype; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ - var objectToString = objectProto.toString; - - /** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ - function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8 which returns 'object' for typed array and weak map constructors, - // and PhantomJS 1.9 which returns 'function' for `NodeList` instances. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; - } - - /** Used as references for various `Number` constants. */ - var MAX_SAFE_INTEGER = 9007199254740991; - - /** - * Checks if `value` is a valid array-like length. - * - * **Note:** This function is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, - * else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ - function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; - } - - /** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ - function isArrayLike(value) { - return value != null && isLength(getLength(value)) && !isFunction(value); - } - - /** - * This method returns `undefined`. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Util - * @example - * - * _.times(2, _.noop); - * // => [undefined, undefined] - */ - function noop() { - // No operation performed. - } - - function once(fn) { - return function () { - if (fn === null) return; - var callFn = fn; - fn = null; - callFn.apply(this, arguments); - }; - } - - var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; - - function getIterator (coll) { - return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); - } - - /** - * Creates a function that invokes `func` with its first argument transformed. - * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. - */ - function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; - } - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeGetPrototype = Object.getPrototypeOf; - - /** - * Gets the `[[Prototype]]` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {null|Object} Returns the `[[Prototype]]`. - */ - var getPrototype = overArg(nativeGetPrototype, Object); - - /** Used for built-in method references. */ - var objectProto$1 = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto$1.hasOwnProperty; - - /** - * The base implementation of `_.has` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ - function baseHas(object, key) { - // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, - // that are composed entirely of index properties, return `false` for - // `hasOwnProperty` checks of them. - return object != null && - (hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototype(object) === null)); - } - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeKeys = Object.keys; - - /** - * The base implementation of `_.keys` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ - var baseKeys = overArg(nativeKeys, Object); - - /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. - * - * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. - */ - function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); - - while (++index < n) { - result[index] = iteratee(index); + + function initialParams (fn) { + return function (...args/*, callback*/) { + var callback = args.pop(); + return fn.call(this, args, callback); + }; } - return result; - } - - /** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ - function isObjectLike(value) { - return !!value && typeof value == 'object'; - } - - /** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ - function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); - } - - /** `Object#toString` result references. */ - var argsTag = '[object Arguments]'; - - /** Used for built-in method references. */ - var objectProto$2 = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty$1 = objectProto$2.hasOwnProperty; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ - var objectToString$1 = objectProto$2.toString; - - /** Built-in value references. */ - var propertyIsEnumerable = objectProto$2.propertyIsEnumerable; - - /** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ - function isArguments(value) { - // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty$1.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString$1.call(value) == argsTag); - } - - /** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ - var isArray = Array.isArray; - - /** `Object#toString` result references. */ - var stringTag = '[object String]'; - - /** Used for built-in method references. */ - var objectProto$3 = Object.prototype; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ - var objectToString$2 = objectProto$3.toString; - - /** - * Checks if `value` is classified as a `String` primitive or object. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a string, else `false`. - * @example - * - * _.isString('abc'); - * // => true - * - * _.isString(1); - * // => false - */ - function isString(value) { - return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objectToString$2.call(value) == stringTag); - } - - /** - * Creates an array of index keys for `object` values of arrays, - * `arguments` objects, and strings, otherwise `null` is returned. - * - * @private - * @param {Object} object The object to query. - * @returns {Array|null} Returns index keys, else `null`. - */ - function indexKeys(object) { - var length = object ? object.length : undefined; - if (isLength(length) && - (isArray(object) || isString(object) || isArguments(object))) { - return baseTimes(length, String); + + /* istanbul ignore file */ + + var hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask; + var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; + var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; + + function fallback(fn) { + setTimeout(fn, 0); } - return null; - } - - /** Used as references for various `Number` constants. */ - var MAX_SAFE_INTEGER$1 = 9007199254740991; - - /** Used to detect unsigned integer values. */ - var reIsUint = /^(?:0|[1-9]\d*)$/; - - /** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ - function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER$1 : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); - } - - /** Used for built-in method references. */ - var objectProto$4 = Object.prototype; - - /** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ - function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$4; - - return value === proto; - } - - /** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ - function keys(object) { - var isProto = isPrototype(object); - if (!(isProto || isArrayLike(object))) { - return baseKeys(object); + + function wrap(defer) { + return (fn, ...args) => defer(() => fn(...args)); } - var indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - for (var key in object) { - if (baseHas(object, key) && - !(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(isProto && key == 'constructor')) { - result.push(key); - } + + var _defer$1; + + if (hasQueueMicrotask) { + _defer$1 = queueMicrotask; + } else if (hasSetImmediate) { + _defer$1 = setImmediate; + } else if (hasNextTick) { + _defer$1 = process.nextTick; + } else { + _defer$1 = fallback; } - return result; - } - - function createArrayIterator(coll) { - var i = -1; - var len = coll.length; - return function next() { - return ++i < len ? { value: coll[i], key: i } : null; - }; - } - - function createES2015Iterator(iterator) { - var i = -1; - return function next() { - var item = iterator.next(); - if (item.done) return null; - i++; - return { value: item.value, key: i }; - }; - } - - function createObjectIterator(obj) { - var okeys = keys(obj); - var i = -1; - var len = okeys.length; - return function next() { - var key = okeys[++i]; - return i < len ? { value: obj[key], key: key } : null; - }; - } - - function iterator(coll) { - if (isArrayLike(coll)) { - return createArrayIterator(coll); - } - - var iterator = getIterator(coll); - return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); - } - - function onlyOnce(fn) { - return function () { - if (fn === null) throw new Error("Callback was already called."); - var callFn = fn; - fn = null; - callFn.apply(this, arguments); - }; - } - - function _eachOfLimit(limit) { - return function (obj, iteratee, callback) { - callback = once(callback || noop); - if (limit <= 0 || !obj) { - return callback(null); - } - var nextElem = iterator(obj); - var done = false; - var running = 0; - - function iterateeCallback(err) { - running -= 1; - if (err) { - done = true; - callback(err); - } else if (done && running <= 0) { - return callback(null); - } else { - replenish(); - } - } - - function replenish() { - while (running < limit && !done) { - var elem = nextElem(); - if (elem === null) { - done = true; - if (running <= 0) { - callback(null); - } - return; - } - running += 1; - iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); - } - } - - replenish(); - }; - } - - /** - * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a - * time. - * - * @name eachOfLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.eachOf]{@link module:Collections.eachOf} - * @alias forEachOfLimit - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each - * item in `coll`. The `key` is the item's key, or index in the case of an - * array. The iteratee is passed a `callback(err)` which must be called once it - * has completed. If no error has occurred, the callback should be run without - * arguments or with an explicit `null` argument. Invoked with - * (item, key, callback). - * @param {Function} [callback] - A callback which is called when all - * `iteratee` functions have finished, or an error occurs. Invoked with (err). - */ - function eachOfLimit(coll, limit, iteratee, callback) { - _eachOfLimit(limit)(coll, iteratee, callback); - } - - function doLimit(fn, limit) { - return function (iterable, iteratee, callback) { - return fn(iterable, limit, iteratee, callback); - }; - } - - // eachOf implementation optimized for array-likes - function eachOfArrayLike(coll, iteratee, callback) { - callback = once(callback || noop); - var index = 0, - completed = 0, - length = coll.length; - if (length === 0) { - callback(null); - } - - function iteratorCallback(err) { - if (err) { - callback(err); - } else if (++completed === length) { - callback(null); - } - } - - for (; index < length; index++) { - iteratee(coll[index], index, onlyOnce(iteratorCallback)); - } - } - - // a generic version of eachOf which can handle array, object, and iterator cases. - var eachOfGeneric = doLimit(eachOfLimit, Infinity); - - /** - * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument - * to the iteratee. - * - * @name eachOf - * @static - * @memberOf module:Collections - * @method - * @alias forEachOf - * @category Collection - * @see [async.each]{@link module:Collections.each} - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each - * item in `coll`. The `key` is the item's key, or index in the case of an - * array. The iteratee is passed a `callback(err)` which must be called once it - * has completed. If no error has occurred, the callback should be run without - * arguments or with an explicit `null` argument. Invoked with - * (item, key, callback). - * @param {Function} [callback] - A callback which is called when all - * `iteratee` functions have finished, or an error occurs. Invoked with (err). - * @example - * - * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; - * var configs = {}; - * - * async.forEachOf(obj, function (value, key, callback) { - * fs.readFile(__dirname + value, "utf8", function (err, data) { - * if (err) return callback(err); - * try { - * configs[key] = JSON.parse(data); - * } catch (e) { - * return callback(e); - * } - * callback(); - * }); - * }, function (err) { - * if (err) console.error(err.message); - * // configs is now a map of JSON data - * doSomethingWith(configs); - * }); - */ - function eachOf (coll, iteratee, callback) { - var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; - eachOfImplementation(coll, iteratee, callback); - } - - function doParallel(fn) { - return function (obj, iteratee, callback) { - return fn(eachOf, obj, iteratee, callback); - }; - } - - function _asyncMap(eachfn, arr, iteratee, callback) { - callback = once(callback || noop); - arr = arr || []; - var results = []; - var counter = 0; - - eachfn(arr, function (value, _, callback) { - var index = counter++; - iteratee(value, function (err, v) { - results[index] = v; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - - /** - * Produces a new collection of values by mapping each value in `coll` through - * the `iteratee` function. The `iteratee` is called with an item from `coll` - * and a callback for when it has finished processing. Each of these callback - * takes 2 arguments: an `error`, and the transformed item from `coll`. If - * `iteratee` passes an error to its callback, the main `callback` (for the - * `map` function) is immediately called with the error. - * - * Note, that since this function applies the `iteratee` to each item in - * parallel, there is no guarantee that the `iteratee` functions will complete - * in order. However, the results array will be in the same order as the - * original `coll`. - * - * If `map` is passed an Object, the results will be an Array. The results - * will roughly be in the order of the original Objects' keys (but this can - * vary across JavaScript engines) - * - * @name map - * @static - * @memberOf module:Collections - * @method - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed item. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Results is an Array of the - * transformed items from the `coll`. Invoked with (err, results). - * @example - * - * async.map(['file1','file2','file3'], fs.stat, function(err, results) { - * // results is now an array of stats for each file - * }); - */ - var map = doParallel(_asyncMap); - - /** - * Applies the provided arguments to each function in the array, calling - * `callback` after all functions have completed. If you only provide the first - * argument, then it will return a function which lets you pass in the - * arguments as if it were a single function call. - * - * @name applyEach - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all - * call with the same arguments - * @param {...*} [args] - any number of separate arguments to pass to the - * function. - * @param {Function} [callback] - the final argument should be the callback, - * called when all functions have completed processing. - * @returns {Function} - If only the first argument is provided, it will return - * a function which lets you pass in the arguments as if it were a single - * function call. - * @example - * - * async.applyEach([enableSearch, updateSchema], 'bucket', callback); - * - * // partial application example: - * async.each( - * buckets, - * async.applyEach([enableSearch, updateSchema]), - * callback - * ); - */ - var applyEach = applyEach$1(map); - - function doParallelLimit(fn) { - return function (obj, limit, iteratee, callback) { - return fn(_eachOfLimit(limit), obj, iteratee, callback); - }; - } - - /** - * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. - * - * @name mapLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.map]{@link module:Collections.map} - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a transformed - * item. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Results is an array of the - * transformed items from the `coll`. Invoked with (err, results). - */ - var mapLimit = doParallelLimit(_asyncMap); - - /** - * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. - * - * @name mapSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.map]{@link module:Collections.map} - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed item. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Results is an array of the - * transformed items from the `coll`. Invoked with (err, results). - */ - var mapSeries = doLimit(mapLimit, 1); - - /** - * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. - * - * @name applyEachSeries - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.applyEach]{@link module:ControlFlow.applyEach} - * @category Control Flow - * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all - * call with the same arguments - * @param {...*} [args] - any number of separate arguments to pass to the - * function. - * @param {Function} [callback] - the final argument should be the callback, - * called when all functions have completed processing. - * @returns {Function} - If only the first argument is provided, it will return - * a function which lets you pass in the arguments as if it were a single - * function call. - */ - var applyEachSeries = applyEach$1(mapSeries); - - /** - * Creates a continuation function with some arguments already applied. - * - * Useful as a shorthand when combined with other control flow functions. Any - * arguments passed to the returned function are added to the arguments - * originally passed to apply. - * - * @name apply - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} function - The function you want to eventually apply all - * arguments to. Invokes with (arguments...). - * @param {...*} arguments... - Any number of arguments to automatically apply - * when the continuation is called. - * @example - * - * // using apply - * async.parallel([ - * async.apply(fs.writeFile, 'testfile1', 'test1'), - * async.apply(fs.writeFile, 'testfile2', 'test2') - * ]); - * - * - * // the same process without using apply - * async.parallel([ - * function(callback) { - * fs.writeFile('testfile1', 'test1', callback); - * }, - * function(callback) { - * fs.writeFile('testfile2', 'test2', callback); - * } - * ]); - * - * // It's possible to pass any number of additional arguments when calling the - * // continuation: - * - * node> var fn = async.apply(sys.puts, 'one'); - * node> fn('two', 'three'); - * one - * two - * three - */ - var apply$1 = baseRest(function (fn, args) { - return baseRest(function (callArgs) { - return fn.apply(null, args.concat(callArgs)); - }); - }); - - /** - * Take a sync function and make it async, passing its return value to a - * callback. This is useful for plugging sync functions into a waterfall, - * series, or other async functions. Any arguments passed to the generated - * function will be passed to the wrapped function (except for the final - * callback argument). Errors thrown will be passed to the callback. - * - * If the function passed to `asyncify` returns a Promise, that promises's - * resolved/rejected state will be used to call the callback, rather than simply - * the synchronous return value. - * - * This also means you can asyncify ES2016 `async` functions. - * - * @name asyncify - * @static - * @memberOf module:Utils - * @method - * @alias wrapSync - * @category Util - * @param {Function} func - The synchronous function to convert to an - * asynchronous function. - * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with - * (callback). - * @example - * - * // passing a regular synchronous function - * async.waterfall([ - * async.apply(fs.readFile, filename, "utf8"), - * async.asyncify(JSON.parse), - * function (data, next) { - * // data is the result of parsing the text. - * // If there was a parsing error, it would have been caught. - * } - * ], callback); - * - * // passing a function returning a promise - * async.waterfall([ - * async.apply(fs.readFile, filename, "utf8"), - * async.asyncify(function (contents) { - * return db.model.create(contents); - * }), - * function (model, next) { - * // `model` is the instantiated model object. - * // If there was an error, this function would be skipped. - * } - * ], callback); - * - * // es6 example - * var q = async.queue(async.asyncify(async function(file) { - * var intermediateStep = await processFile(file); - * return await somePromise(intermediateStep) - * })); - * - * q.push(files); - */ - function asyncify(func) { - return initialParams(function (args, callback) { - var result; - try { - result = func.apply(this, args); - } catch (e) { - return callback(e); - } - // if result is Promise object - if (isObject(result) && typeof result.then === 'function') { - result.then(function (value) { - callback(null, value); - }, function (err) { - callback(err.message ? err : new Error(err)); - }); - } else { - callback(null, result); - } - }); - } - - /** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. - */ - function arrayEach(array, iteratee) { - var index = -1, - length = array ? array.length : 0; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } + + var setImmediate$1 = wrap(_defer$1); + + /** + * Take a sync function and make it async, passing its return value to a + * callback. This is useful for plugging sync functions into a waterfall, + * series, or other async functions. Any arguments passed to the generated + * function will be passed to the wrapped function (except for the final + * callback argument). Errors thrown will be passed to the callback. + * + * If the function passed to `asyncify` returns a Promise, that promises's + * resolved/rejected state will be used to call the callback, rather than simply + * the synchronous return value. + * + * This also means you can asyncify ES2017 `async` functions. + * + * @name asyncify + * @static + * @memberOf module:Utils + * @method + * @alias wrapSync + * @category Util + * @param {Function} func - The synchronous function, or Promise-returning + * function to convert to an {@link AsyncFunction}. + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be + * invoked with `(args..., callback)`. + * @example + * + * // passing a regular synchronous function + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(JSON.parse), + * function (data, next) { + * // data is the result of parsing the text. + * // If there was a parsing error, it would have been caught. + * } + * ], callback); + * + * // passing a function returning a promise + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(function (contents) { + * return db.model.create(contents); + * }), + * function (model, next) { + * // `model` is the instantiated model object. + * // If there was an error, this function would be skipped. + * } + * ], callback); + * + * // es2017 example, though `asyncify` is not needed if your JS environment + * // supports async functions out of the box + * var q = async.queue(async.asyncify(async function(file) { + * var intermediateStep = await processFile(file); + * return await somePromise(intermediateStep) + * })); + * + * q.push(files); + */ + function asyncify(func) { + if (isAsync(func)) { + return function (...args/*, callback*/) { + const callback = args.pop(); + const promise = func.apply(this, args); + return handlePromise(promise, callback) + } + } + + return initialParams(function (args, callback) { + var result; + try { + result = func.apply(this, args); + } catch (e) { + return callback(e); + } + // if result is Promise object + if (result && typeof result.then === 'function') { + return handlePromise(result, callback) + } else { + callback(null, result); + } + }); + } + + function handlePromise(promise, callback) { + return promise.then(value => { + invokeCallback(callback, null, value); + }, err => { + invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err)); + }); } - return array; - } - - /** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ - function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; - - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; + + function invokeCallback(callback, error, value) { + try { + callback(error, value); + } catch (err) { + setImmediate$1(e => { throw e }, err); } - } - return object; - }; - } - - /** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ - var baseFor = createBaseFor(); - - /** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ - function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); - } - - /** - * The base implementation of `_.findIndex` and `_.findLastIndex` without - * support for iteratee shorthands. - * - * @private - * @param {Array} array The array to search. - * @param {Function} predicate The function invoked per iteration. - * @param {number} fromIndex The index to search from. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseFindIndex(array, predicate, fromIndex, fromRight) { - var length = array.length, - index = fromIndex + (fromRight ? 1 : -1); - - while ((fromRight ? index-- : ++index < length)) { - if (predicate(array[index], index, array)) { - return index; - } } - return -1; - } - - /** - * The base implementation of `_.isNaN` without support for number objects. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. - */ - function baseIsNaN(value) { - return value !== value; - } - - /** - * The base implementation of `_.indexOf` without `fromIndex` bounds checks. - * - * @private - * @param {Array} array The array to search. - * @param {*} value The value to search for. - * @param {number} fromIndex The index to search from. - * @returns {number} Returns the index of the matched value, else `-1`. - */ - function baseIndexOf(array, value, fromIndex) { - if (value !== value) { - return baseFindIndex(array, baseIsNaN, fromIndex); + + function isAsync(fn) { + return fn[Symbol.toStringTag] === 'AsyncFunction'; } - var index = fromIndex - 1, - length = array.length; - while (++index < length) { - if (array[index] === value) { - return index; - } + function isAsyncGenerator(fn) { + return fn[Symbol.toStringTag] === 'AsyncGenerator'; } - return -1; - } - - /** - * Determines the best order for running the functions in `tasks`, based on - * their requirements. Each function can optionally depend on other functions - * being completed first, and each function is run as soon as its requirements - * are satisfied. - * - * If any of the functions pass an error to their callback, the `auto` sequence - * will stop. Further tasks will not execute (so any other functions depending - * on it will not run), and the main `callback` is immediately called with the - * error. - * - * Functions also receive an object containing the results of functions which - * have completed so far as the first argument, if they have dependencies. If a - * task function has no dependencies, it will only be passed a callback. - * - * @name auto - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Object} tasks - An object. Each of its properties is either a - * function or an array of requirements, with the function itself the last item - * in the array. The object's key of a property serves as the name of the task - * defined by that property, i.e. can be used when specifying requirements for - * other tasks. The function receives one or two arguments: - * * a `results` object, containing the results of the previously executed - * functions, only passed if the task has any dependencies, - * * a `callback(err, result)` function, which must be called when finished, - * passing an `error` (which can be `null`) and the result of the function's - * execution. - * @param {number} [concurrency=Infinity] - An optional `integer` for - * determining the maximum number of tasks that can be run in parallel. By - * default, as many as possible. - * @param {Function} [callback] - An optional callback which is called when all - * the tasks have been completed. It receives the `err` argument if any `tasks` - * pass an error to their callback. Results are always returned; however, if an - * error occurs, no further `tasks` will be performed, and the results object - * will only contain partial results. Invoked with (err, results). - * @returns undefined - * @example - * - * async.auto({ - * // this function will just be passed a callback - * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'), - * showData: ['readData', function(results, cb) { - * // results.readData is the file's contents - * // ... - * }] - * }, callback); - * - * async.auto({ - * get_data: function(callback) { - * console.log('in get_data'); - * // async code to get some data - * callback(null, 'data', 'converted to array'); - * }, - * make_folder: function(callback) { - * console.log('in make_folder'); - * // async code to create a directory to store a file in - * // this is run at the same time as getting the data - * callback(null, 'folder'); - * }, - * write_file: ['get_data', 'make_folder', function(results, callback) { - * console.log('in write_file', JSON.stringify(results)); - * // once there is some data and the directory exists, - * // write the data to a file in the directory - * callback(null, 'filename'); - * }], - * email_link: ['write_file', function(results, callback) { - * console.log('in email_link', JSON.stringify(results)); - * // once the file is written let's email a link to it... - * // results.write_file contains the filename returned by write_file. - * callback(null, {'file':results.write_file, 'email':'user@example.com'}); - * }] - * }, function(err, results) { - * console.log('err = ', err); - * console.log('results = ', results); - * }); - */ - function auto (tasks, concurrency, callback) { - if (typeof concurrency === 'function') { - // concurrency is optional, shift the args. - callback = concurrency; - concurrency = null; - } - callback = once(callback || noop); - var keys$$ = keys(tasks); - var numTasks = keys$$.length; - if (!numTasks) { - return callback(null); - } - if (!concurrency) { - concurrency = numTasks; - } - - var results = {}; - var runningTasks = 0; - var hasError = false; - - var listeners = {}; - - var readyTasks = []; - - // for cycle detection: - var readyToCheck = []; // tasks that have been identified as reachable - // without the possibility of returning to an ancestor task - var uncheckedDependencies = {}; - - baseForOwn(tasks, function (task, key) { - if (!isArray(task)) { - // no dependencies - enqueueTask(key, [task]); - readyToCheck.push(key); - return; - } - - var dependencies = task.slice(0, task.length - 1); - var remainingDependencies = dependencies.length; - if (remainingDependencies === 0) { - enqueueTask(key, task); - readyToCheck.push(key); - return; - } - uncheckedDependencies[key] = remainingDependencies; - - arrayEach(dependencies, function (dependencyName) { - if (!tasks[dependencyName]) { - throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', ')); - } - addListener(dependencyName, function () { - remainingDependencies--; - if (remainingDependencies === 0) { - enqueueTask(key, task); - } - }); - }); - }); - - checkForDeadlocks(); - processQueue(); - - function enqueueTask(key, task) { - readyTasks.push(function () { - runTask(key, task); - }); - } - - function processQueue() { - if (readyTasks.length === 0 && runningTasks === 0) { - return callback(null, results); - } - while (readyTasks.length && runningTasks < concurrency) { - var run = readyTasks.shift(); - run(); - } - } - - function addListener(taskName, fn) { - var taskListeners = listeners[taskName]; - if (!taskListeners) { - taskListeners = listeners[taskName] = []; - } - - taskListeners.push(fn); - } - - function taskComplete(taskName) { - var taskListeners = listeners[taskName] || []; - arrayEach(taskListeners, function (fn) { - fn(); - }); - processQueue(); - } - - function runTask(key, task) { - if (hasError) return; - - var taskCallback = onlyOnce(baseRest(function (err, args) { - runningTasks--; - if (args.length <= 1) { - args = args[0]; - } - if (err) { - var safeResults = {}; - baseForOwn(results, function (val, rkey) { - safeResults[rkey] = val; - }); - safeResults[key] = args; - hasError = true; - listeners = []; - - callback(err, safeResults); - } else { - results[key] = args; - taskComplete(key); - } - })); - - runningTasks++; - var taskFn = task[task.length - 1]; - if (task.length > 1) { - taskFn(results, taskCallback); - } else { - taskFn(taskCallback); - } - } - - function checkForDeadlocks() { - // Kahn's algorithm - // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm - // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html - var currentTask; - var counter = 0; - while (readyToCheck.length) { - currentTask = readyToCheck.pop(); - counter++; - arrayEach(getDependents(currentTask), function (dependent) { - if (--uncheckedDependencies[dependent] === 0) { - readyToCheck.push(dependent); - } - }); - } - - if (counter !== numTasks) { - throw new Error('async.auto cannot execute tasks due to a recursive dependency'); - } - } - - function getDependents(taskName) { - var result = []; - baseForOwn(tasks, function (task, key) { - if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) { - result.push(key); - } - }); - return result; - } - } - - /** - * A specialized version of `_.map` for arrays without support for iteratee - * shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the new mapped array. - */ - function arrayMap(array, iteratee) { - var index = -1, - length = array ? array.length : 0, - result = Array(length); - - while (++index < length) { - result[index] = iteratee(array[index], index, array); + + function isAsyncIterable(obj) { + return typeof obj[Symbol.asyncIterator] === 'function'; } - return result; - } - - /** - * Copies the values of `source` to `array`. - * - * @private - * @param {Array} source The array to copy values from. - * @param {Array} [array=[]] The array to copy values to. - * @returns {Array} Returns `array`. - */ - function copyArray(source, array) { - var index = -1, - length = source.length; - - array || (array = Array(length)); - while (++index < length) { - array[index] = source[index]; + + function wrapAsync(asyncFn) { + if (typeof asyncFn !== 'function') throw new Error('expected a function') + return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; } - return array; - } - - /** Detect free variable `global` from Node.js. */ - var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - - /** Detect free variable `self`. */ - var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - - /** Used as a reference to the global object. */ - var root = freeGlobal || freeSelf || Function('return this')(); - - /** Built-in value references. */ - var Symbol$1 = root.Symbol; - - /** `Object#toString` result references. */ - var symbolTag = '[object Symbol]'; - - /** Used for built-in method references. */ - var objectProto$5 = Object.prototype; - - /** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) - * of values. - */ - var objectToString$3 = objectProto$5.toString; - - /** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ - function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString$3.call(value) == symbolTag); - } - - /** Used as references for various `Number` constants. */ - var INFINITY = 1 / 0; - - /** Used to convert symbols to primitives and strings. */ - var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined; - var symbolToString = symbolProto ? symbolProto.toString : undefined; - /** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ - function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; + + // conditionally promisify a function. + // only return a promise if a callback is omitted + function awaitify (asyncFn, arity) { + if (!arity) arity = asyncFn.length; + if (!arity) throw new Error('arity is undefined') + function awaitable (...args) { + if (typeof args[arity - 1] === 'function') { + return asyncFn.apply(this, args) + } + + return new Promise((resolve, reject) => { + args[arity - 1] = (err, ...cbArgs) => { + if (err) return reject(err) + resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]); + }; + asyncFn.apply(this, args); + }) + } + + return awaitable } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; + + function applyEach$1 (eachfn) { + return function applyEach(fns, ...callArgs) { + const go = awaitify(function (callback) { + var that = this; + return eachfn(fns, (fn, cb) => { + wrapAsync(fn).apply(that, callArgs.concat(cb)); + }, callback); + }); + return go; + }; + } + + function _asyncMap(eachfn, arr, iteratee, callback) { + arr = arr || []; + var results = []; + var counter = 0; + var _iteratee = wrapAsync(iteratee); + + return eachfn(arr, (value, _, iterCb) => { + var index = counter++; + _iteratee(value, (err, v) => { + results[index] = v; + iterCb(err); + }); + }, err => { + callback(err, results); + }); + } + + function isArrayLike(value) { + return value && + typeof value.length === 'number' && + value.length >= 0 && + value.length % 1 === 0; + } + + // A temporary value used to identify if the loop should be broken. + // See #1064, #1293 + const breakLoop = {}; + + function once(fn) { + function wrapper (...args) { + if (fn === null) return; + var callFn = fn; + fn = null; + callFn.apply(this, args); + } + Object.assign(wrapper, fn); + return wrapper + } + + function getIterator (coll) { + return coll[Symbol.iterator] && coll[Symbol.iterator](); } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; - } - - /** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ - function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - if (start < 0) { - start = -start > length ? 0 : (length + start); + + function createArrayIterator(coll) { + var i = -1; + var len = coll.length; + return function next() { + return ++i < len ? {value: coll[i], key: i} : null; + } } - end = end > length ? length : end; - if (end < 0) { - end += length; + + function createES2015Iterator(iterator) { + var i = -1; + return function next() { + var item = iterator.next(); + if (item.done) + return null; + i++; + return {value: item.value, key: i}; + } } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; + function createObjectIterator(obj) { + var okeys = obj ? Object.keys(obj) : []; + var i = -1; + var len = okeys.length; + return function next() { + var key = okeys[++i]; + if (key === '__proto__') { + return next(); + } + return i < len ? {value: obj[key], key} : null; + }; } - return result; - } - - /** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ - function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : baseSlice(array, start, end); - } - - /** - * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the last unmatched string symbol. - */ - function charsEndIndex(strSymbols, chrSymbols) { - var index = strSymbols.length; - - while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** - * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol - * that is not found in the character symbols. - * - * @private - * @param {Array} strSymbols The string symbols to inspect. - * @param {Array} chrSymbols The character symbols to find. - * @returns {number} Returns the index of the first unmatched string symbol. - */ - function charsStartIndex(strSymbols, chrSymbols) { - var index = -1, - length = strSymbols.length; - - while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} - return index; - } - - /** Used to compose unicode character classes. */ - var rsAstralRange = '\\ud800-\\udfff'; - var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23'; - var rsComboSymbolsRange = '\\u20d0-\\u20f0'; - var rsVarRange = '\\ufe0e\\ufe0f'; - var rsAstral = '[' + rsAstralRange + ']'; - var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']'; - var rsFitz = '\\ud83c[\\udffb-\\udfff]'; - var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')'; - var rsNonAstral = '[^' + rsAstralRange + ']'; - var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; - var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; - var rsZWJ = '\\u200d'; - var reOptMod = rsModifier + '?'; - var rsOptVar = '[' + rsVarRange + ']?'; - var rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; - var rsSeq = rsOptVar + reOptMod + rsOptJoin; - var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - - /** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ - function stringToArray(string) { - return string.match(reComplexSymbol); - } - - /** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ - function toString(value) { - return value == null ? '' : baseToString(value); - } - - /** Used to match leading and trailing whitespace. */ - var reTrim = /^\s+|\s+$/g; - - /** - * Removes leading and trailing whitespace or specified characters from `string`. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to trim. - * @param {string} [chars=whitespace] The characters to trim. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {string} Returns the trimmed string. - * @example - * - * _.trim(' abc '); - * // => 'abc' - * - * _.trim('-_-abc-_-', '_-'); - * // => 'abc' - * - * _.map([' foo ', ' bar '], _.trim); - * // => ['foo', 'bar'] - */ - function trim(string, chars, guard) { - string = toString(string); - if (string && (guard || chars === undefined)) { - return string.replace(reTrim, ''); + + function createIterator(coll) { + if (isArrayLike(coll)) { + return createArrayIterator(coll); + } + + var iterator = getIterator(coll); + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); + } + + function onlyOnce(fn) { + return function (...args) { + if (fn === null) throw new Error("Callback was already called."); + var callFn = fn; + fn = null; + callFn.apply(this, args); + }; } - if (!string || !(chars = baseToString(chars))) { - return string; + + // for async generators + function asyncEachOfLimit(generator, limit, iteratee, callback) { + let done = false; + let canceled = false; + let awaiting = false; + let running = 0; + let idx = 0; + + function replenish() { + //console.log('replenish') + if (running >= limit || awaiting || done) return + //console.log('replenish awaiting') + awaiting = true; + generator.next().then(({value, done: iterDone}) => { + //console.log('got value', value) + if (canceled || done) return + awaiting = false; + if (iterDone) { + done = true; + if (running <= 0) { + //console.log('done nextCb') + callback(null); + } + return; + } + running++; + iteratee(value, idx, iterateeCallback); + idx++; + replenish(); + }).catch(handleError); + } + + function iterateeCallback(err, result) { + //console.log('iterateeCallback') + running -= 1; + if (canceled) return + if (err) return handleError(err) + + if (err === false) { + done = true; + canceled = true; + return + } + + if (result === breakLoop || (done && running <= 0)) { + done = true; + //console.log('done iterCb') + return callback(null); + } + replenish(); + } + + function handleError(err) { + if (canceled) return + awaiting = false; + done = true; + callback(err); + } + + replenish(); } - var strSymbols = stringToArray(string), - chrSymbols = stringToArray(chars), - start = charsStartIndex(strSymbols, chrSymbols), - end = charsEndIndex(strSymbols, chrSymbols) + 1; - - return castSlice(strSymbols, start, end).join(''); - } - - var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m; - var FN_ARG_SPLIT = /,/; - var FN_ARG = /(=.+)?(\s*)$/; - var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; - - function parseParams(func) { - func = func.toString().replace(STRIP_COMMENTS, ''); - func = func.match(FN_ARGS)[2].replace(' ', ''); - func = func ? func.split(FN_ARG_SPLIT) : []; - func = func.map(function (arg) { - return trim(arg.replace(FN_ARG, '')); - }); - return func; - } - - /** - * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent - * tasks are specified as parameters to the function, after the usual callback - * parameter, with the parameter names matching the names of the tasks it - * depends on. This can provide even more readable task graphs which can be - * easier to maintain. - * - * If a final callback is specified, the task results are similarly injected, - * specified as named parameters after the initial error parameter. - * - * The autoInject function is purely syntactic sugar and its semantics are - * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}. - * - * @name autoInject - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.auto]{@link module:ControlFlow.auto} - * @category Control Flow - * @param {Object} tasks - An object, each of whose properties is a function of - * the form 'func([dependencies...], callback). The object's key of a property - * serves as the name of the task defined by that property, i.e. can be used - * when specifying requirements for other tasks. - * * The `callback` parameter is a `callback(err, result)` which must be called - * when finished, passing an `error` (which can be `null`) and the result of - * the function's execution. The remaining parameters name other tasks on - * which the task is dependent, and the results from those tasks are the - * arguments of those parameters. - * @param {Function} [callback] - An optional callback which is called when all - * the tasks have been completed. It receives the `err` argument if any `tasks` - * pass an error to their callback, and a `results` object with any completed - * task results, similar to `auto`. - * @example - * - * // The example from `auto` can be rewritten as follows: - * async.autoInject({ - * get_data: function(callback) { - * // async code to get some data - * callback(null, 'data', 'converted to array'); - * }, - * make_folder: function(callback) { - * // async code to create a directory to store a file in - * // this is run at the same time as getting the data - * callback(null, 'folder'); - * }, - * write_file: function(get_data, make_folder, callback) { - * // once there is some data and the directory exists, - * // write the data to a file in the directory - * callback(null, 'filename'); - * }, - * email_link: function(write_file, callback) { - * // once the file is written let's email a link to it... - * // write_file contains the filename returned by write_file. - * callback(null, {'file':write_file, 'email':'user@example.com'}); - * } - * }, function(err, results) { - * console.log('err = ', err); - * console.log('email_link = ', results.email_link); - * }); - * - * // If you are using a JS minifier that mangles parameter names, `autoInject` - * // will not work with plain functions, since the parameter names will be - * // collapsed to a single letter identifier. To work around this, you can - * // explicitly specify the names of the parameters your task function needs - * // in an array, similar to Angular.js dependency injection. - * - * // This still has an advantage over plain `auto`, since the results a task - * // depends on are still spread into arguments. - * async.autoInject({ - * //... - * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { - * callback(null, 'filename'); - * }], - * email_link: ['write_file', function(write_file, callback) { - * callback(null, {'file':write_file, 'email':'user@example.com'}); - * }] - * //... - * }, function(err, results) { - * console.log('err = ', err); - * console.log('email_link = ', results.email_link); - * }); - */ - function autoInject(tasks, callback) { - var newTasks = {}; - - baseForOwn(tasks, function (taskFn, key) { - var params; - - if (isArray(taskFn)) { - params = copyArray(taskFn); - taskFn = params.pop(); - - newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); - } else if (taskFn.length === 1) { - // no dependencies, use the function as-is - newTasks[key] = taskFn; - } else { - params = parseParams(taskFn); - if (taskFn.length === 0 && params.length === 0) { - throw new Error("autoInject task functions require explicit parameters."); - } - - params.pop(); - - newTasks[key] = params.concat(newTask); - } - - function newTask(results, taskCb) { - var newArgs = arrayMap(params, function (name) { - return results[name]; - }); - newArgs.push(taskCb); - taskFn.apply(null, newArgs); - } - }); - - auto(newTasks, callback); - } - - var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; - var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; - - function fallback(fn) { - setTimeout(fn, 0); - } - - function wrap(defer) { - return baseRest(function (fn, args) { - defer(function () { - fn.apply(null, args); - }); - }); - } - - var _defer; - - if (hasSetImmediate) { - _defer = setImmediate; - } else if (hasNextTick) { - _defer = process.nextTick; - } else { - _defer = fallback; - } - - var setImmediate$1 = wrap(_defer); - - // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation - // used for queues. This implementation assumes that the node provided by the user can be modified - // to adjust the next and last properties. We implement only the minimal functionality - // for queue support. - function DLL() { - this.head = this.tail = null; - this.length = 0; - } - - function setInitial(dll, node) { - dll.length = 1; - dll.head = dll.tail = node; - } - - DLL.prototype.removeLink = function (node) { - if (node.prev) node.prev.next = node.next;else this.head = node.next; - if (node.next) node.next.prev = node.prev;else this.tail = node.prev; - - node.prev = node.next = null; - this.length -= 1; - return node; - }; - - DLL.prototype.empty = DLL; - - DLL.prototype.insertAfter = function (node, newNode) { - newNode.prev = node; - newNode.next = node.next; - if (node.next) node.next.prev = newNode;else this.tail = newNode; - node.next = newNode; - this.length += 1; - }; - - DLL.prototype.insertBefore = function (node, newNode) { - newNode.prev = node.prev; - newNode.next = node; - if (node.prev) node.prev.next = newNode;else this.head = newNode; - node.prev = newNode; - this.length += 1; - }; - - DLL.prototype.unshift = function (node) { - if (this.head) this.insertBefore(this.head, node);else setInitial(this, node); - }; - - DLL.prototype.push = function (node) { - if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node); - }; - - DLL.prototype.shift = function () { - return this.head && this.removeLink(this.head); - }; - - DLL.prototype.pop = function () { - return this.tail && this.removeLink(this.tail); - }; - - function queue(worker, concurrency, payload) { - if (concurrency == null) { - concurrency = 1; - } else if (concurrency === 0) { - throw new Error('Concurrency must not be zero'); - } - - function _insert(data, insertAtFront, callback) { - if (callback != null && typeof callback !== 'function') { - throw new Error('task callback must be a function'); - } - q.started = true; - if (!isArray(data)) { - data = [data]; - } - if (data.length === 0 && q.idle()) { - // call drain immediately if there are no tasks - return setImmediate$1(function () { - q.drain(); - }); - } - arrayEach(data, function (task) { - var item = { - data: task, - callback: callback || noop - }; - - if (insertAtFront) { - q._tasks.unshift(item); - } else { - q._tasks.push(item); - } - }); - setImmediate$1(q.process); - } - - function _next(tasks) { - return baseRest(function (args) { - workers -= 1; - - arrayEach(tasks, function (task) { - arrayEach(workersList, function (worker, index) { - if (worker === task) { - workersList.splice(index, 1); - return false; - } - }); - - task.callback.apply(task, args); - - if (args[0] != null) { - q.error(args[0], task.data); - } - }); - - if (workers <= q.concurrency - q.buffer) { - q.unsaturated(); - } - - if (q.idle()) { - q.drain(); - } - q.process(); - }); - } - - var workers = 0; - var workersList = []; - var q = { - _tasks: new DLL(), - concurrency: concurrency, - payload: payload, - saturated: noop, - unsaturated: noop, - buffer: concurrency / 4, - empty: noop, - drain: noop, - error: noop, - started: false, - paused: false, - push: function (data, callback) { - _insert(data, false, callback); - }, - kill: function () { - q.drain = noop; - q._tasks.empty(); - }, - unshift: function (data, callback) { - _insert(data, true, callback); - }, - process: function () { - while (!q.paused && workers < q.concurrency && q._tasks.length) { - var tasks = [], - data = []; - var l = q._tasks.length; - if (q.payload) l = Math.min(l, q.payload); - for (var i = 0; i < l; i++) { - var node = q._tasks.shift(); - tasks.push(node); - data.push(node.data); - } - - if (q._tasks.length === 0) { - q.empty(); - } - workers += 1; - workersList.push(tasks[0]); - - if (workers === q.concurrency) { - q.saturated(); - } - - var cb = onlyOnce(_next(tasks)); - worker(data, cb); - } - }, - length: function () { - return q._tasks.length; - }, - running: function () { - return workers; - }, - workersList: function () { - return workersList; - }, - idle: function () { - return q._tasks.length + workers === 0; - }, - pause: function () { - q.paused = true; - }, - resume: function () { - if (q.paused === false) { - return; - } - q.paused = false; - var resumeCount = Math.min(q.concurrency, q._tasks.length); - // Need to call q.process once per concurrent - // worker to preserve full concurrency after pause - for (var w = 1; w <= resumeCount; w++) { - setImmediate$1(q.process); - } - } - }; - return q; - } - - /** - * A cargo of tasks for the worker function to complete. Cargo inherits all of - * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. - * @typedef {Object} CargoObject - * @memberOf module:ControlFlow - * @property {Function} length - A function returning the number of items - * waiting to be processed. Invoke like `cargo.length()`. - * @property {number} payload - An `integer` for determining how many tasks - * should be process per round. This property can be changed after a `cargo` is - * created to alter the payload on-the-fly. - * @property {Function} push - Adds `task` to the `queue`. The callback is - * called once the `worker` has finished processing the task. Instead of a - * single task, an array of `tasks` can be submitted. The respective callback is - * used for every task in the list. Invoke like `cargo.push(task, [callback])`. - * @property {Function} saturated - A callback that is called when the - * `queue.length()` hits the concurrency and further tasks will be queued. - * @property {Function} empty - A callback that is called when the last item - * from the `queue` is given to a `worker`. - * @property {Function} drain - A callback that is called when the last item - * from the `queue` has returned from the `worker`. - * @property {Function} idle - a function returning false if there are items - * waiting or being processed, or true if not. Invoke like `cargo.idle()`. - * @property {Function} pause - a function that pauses the processing of tasks - * until `resume()` is called. Invoke like `cargo.pause()`. - * @property {Function} resume - a function that resumes the processing of - * queued tasks when the queue is paused. Invoke like `cargo.resume()`. - * @property {Function} kill - a function that removes the `drain` callback and - * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. - */ - - /** - * Creates a `cargo` object with the specified payload. Tasks added to the - * cargo will be processed altogether (up to the `payload` limit). If the - * `worker` is in progress, the task is queued until it becomes available. Once - * the `worker` has completed some tasks, each callback of those tasks is - * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) - * for how `cargo` and `queue` work. - * - * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers - * at a time, cargo passes an array of tasks to a single worker, repeating - * when the worker is finished. - * - * @name cargo - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.queue]{@link module:ControlFlow.queue} - * @category Control Flow - * @param {Function} worker - An asynchronous function for processing an array - * of queued tasks, which must call its `callback(err)` argument when finished, - * with an optional `err` argument. Invoked with `(tasks, callback)`. - * @param {number} [payload=Infinity] - An optional `integer` for determining - * how many tasks should be processed per round; if omitted, the default is - * unlimited. - * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can - * attached as certain properties to listen for specific events during the - * lifecycle of the cargo and inner queue. - * @example - * - * // create a cargo object with payload 2 - * var cargo = async.cargo(function(tasks, callback) { - * for (var i=0; i true - */ - function identity(value) { - return value; - } - - function _createTester(eachfn, check, getResult) { - return function (arr, limit, iteratee, cb) { - function done(err) { - if (cb) { - if (err) { - cb(err); - } else { - cb(null, getResult(false)); - } - } - } - function wrappedIteratee(x, _, callback) { - if (!cb) return callback(); - iteratee(x, function (err, v) { - if (cb) { - if (err) { - cb(err); - cb = iteratee = false; - } else if (check(v)) { - cb(null, getResult(true, x)); - cb = iteratee = false; - } - } - callback(); - }); - } - if (arguments.length > 3) { - cb = cb || noop; - eachfn(arr, limit, wrappedIteratee, done); - } else { - cb = iteratee; - cb = cb || noop; - iteratee = limit; - eachfn(arr, wrappedIteratee, done); - } - }; - } - - function _findGetResult(v, x) { - return x; - } - - /** - * Returns the first value in `coll` that passes an async truth test. The - * `iteratee` is applied in parallel, meaning the first iteratee to return - * `true` will fire the detect `callback` with that result. That means the - * result might not be the first item in the original `coll` (in terms of order) - * that passes the test. - - * If order within the original `coll` is important, then look at - * [`detectSeries`]{@link module:Collections.detectSeries}. - * - * @name detect - * @static - * @memberOf module:Collections - * @method - * @alias find - * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the `iteratee` functions have finished. - * Result will be the first item in the array that passes the truth test - * (iteratee) or the value `undefined` if none passed. Invoked with - * (err, result). - * @example - * - * async.detect(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { - * // result now equals the first file in the list that exists - * }); - */ - var detect = _createTester(eachOf, identity, _findGetResult); - - /** - * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a - * time. - * - * @name detectLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.detect]{@link module:Collections.detect} - * @alias findLimit - * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the `iteratee` functions have finished. - * Result will be the first item in the array that passes the truth test - * (iteratee) or the value `undefined` if none passed. Invoked with - * (err, result). - */ - var detectLimit = _createTester(eachOfLimit, identity, _findGetResult); - - /** - * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. - * - * @name detectSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.detect]{@link module:Collections.detect} - * @alias findSeries - * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the `iteratee` functions have finished. - * Result will be the first item in the array that passes the truth test - * (iteratee) or the value `undefined` if none passed. Invoked with - * (err, result). - */ - var detectSeries = _createTester(eachOfSeries, identity, _findGetResult); - - function consoleFunc(name) { - return baseRest(function (fn, args) { - fn.apply(null, args.concat([baseRest(function (err, args) { - if (typeof console === 'object') { - if (err) { - if (console.error) { - console.error(err); - } - } else if (console[name]) { - arrayEach(args, function (x) { - console[name](x); - }); - } - } - })])); - }); - } - - /** - * Logs the result of an `async` function to the `console` using `console.dir` - * to display the properties of the resulting object. Only works in Node.js or - * in browsers that support `console.dir` and `console.error` (such as FF and - * Chrome). If multiple arguments are returned from the async function, - * `console.dir` is called on each argument in order. - * - * @name dir - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} function - The function you want to eventually apply all - * arguments to. - * @param {...*} arguments... - Any number of arguments to apply to the function. - * @example - * - * // in a module - * var hello = function(name, callback) { - * setTimeout(function() { - * callback(null, {hello: name}); - * }, 1000); - * }; - * - * // in the node repl - * node> async.dir(hello, 'world'); - * {hello: 'world'} - */ - var dir = consoleFunc('dir'); - - /** - * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in - * the order of operations, the arguments `test` and `fn` are switched. - * - * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function. - * @name doDuring - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.during]{@link module:ControlFlow.during} - * @category Control Flow - * @param {Function} fn - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - asynchronous truth test to perform before each - * execution of `fn`. Invoked with (...args, callback), where `...args` are the - * non-error args from the previous callback of `fn`. - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error if one occured, otherwise `null`. - */ - function doDuring(fn, test, callback) { - callback = onlyOnce(callback || noop); - - var next = baseRest(function (err, args) { - if (err) return callback(err); - args.push(check); - test.apply(this, args); - }); - - function check(err, truth) { - if (err) return callback(err); - if (!truth) return callback(null); - fn(next); - } - - check(null, true); - } - - /** - * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in - * the order of operations, the arguments `test` and `iteratee` are switched. - * - * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. - * - * @name doWhilst - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.whilst]{@link module:ControlFlow.whilst} - * @category Control Flow - * @param {Function} iteratee - A function which is called each time `test` - * passes. The function is passed a `callback(err)`, which must be called once - * it has completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - synchronous truth test to perform after each - * execution of `iteratee`. Invoked with Invoked with the non-error callback - * results of `iteratee`. - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `iteratee` has stopped. - * `callback` will be passed an error and any arguments passed to the final - * `iteratee`'s callback. Invoked with (err, [results]); - */ - function doWhilst(iteratee, test, callback) { - callback = onlyOnce(callback || noop); - var next = baseRest(function (err, args) { - if (err) return callback(err); - if (test.apply(this, args)) return iteratee(next); - callback.apply(null, [null].concat(args)); - }); - iteratee(next); - } - - /** - * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the - * argument ordering differs from `until`. - * - * @name doUntil - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} - * @category Control Flow - * @param {Function} fn - A function which is called each time `test` fails. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - synchronous truth test to perform after each - * execution of `fn`. Invoked with the non-error callback results of `fn`. - * @param {Function} [callback] - A callback which is called after the test - * function has passed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s - * callback. Invoked with (err, [results]); - */ - function doUntil(fn, test, callback) { - doWhilst(fn, function () { - return !test.apply(this, arguments); - }, callback); - } - - /** - * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that - * is passed a callback in the form of `function (err, truth)`. If error is - * passed to `test` or `fn`, the main callback is immediately called with the - * value of the error. - * - * @name during - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.whilst]{@link module:ControlFlow.whilst} - * @category Control Flow - * @param {Function} test - asynchronous truth test to perform before each - * execution of `fn`. Invoked with (callback). - * @param {Function} fn - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error, if one occured, otherwise `null`. - * @example - * - * var count = 0; - * - * async.during( - * function (callback) { - * return callback(null, count < 5); - * }, - * function (callback) { - * count++; - * setTimeout(callback, 1000); - * }, - * function (err) { - * // 5 seconds have passed - * } - * ); - */ - function during(test, fn, callback) { - callback = onlyOnce(callback || noop); - - function next(err) { - if (err) return callback(err); - test(check); - } - - function check(err, truth) { - if (err) return callback(err); - if (!truth) return callback(null); - fn(next); - } - - test(check); - } - - function _withoutIndex(iteratee) { - return function (value, index, callback) { - return iteratee(value, callback); - }; - } - - /** - * Applies the function `iteratee` to each item in `coll`, in parallel. - * The `iteratee` is called with an item from the list, and a callback for when - * it has finished. If the `iteratee` passes an error to its `callback`, the - * main `callback` (for the `each` function) is immediately called with the - * error. - * - * Note, that since this function applies `iteratee` to each item in parallel, - * there is no guarantee that the iteratee functions will complete in order. - * - * @name each - * @static - * @memberOf module:Collections - * @method - * @alias forEach - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item - * in `coll`. The iteratee is passed a `callback(err)` which must be called once - * it has completed. If no error has occurred, the `callback` should be run - * without arguments or with an explicit `null` argument. The array index is not - * passed to the iteratee. Invoked with (item, callback). If you need the index, - * use `eachOf`. - * @param {Function} [callback] - A callback which is called when all - * `iteratee` functions have finished, or an error occurs. Invoked with (err). - * @example - * - * // assuming openFiles is an array of file names and saveFile is a function - * // to save the modified contents of that file: - * - * async.each(openFiles, saveFile, function(err){ - * // if any of the saves produced an error, err would equal that error - * }); - * - * // assuming openFiles is an array of file names - * async.each(openFiles, function(file, callback) { - * - * // Perform operation on file here. - * console.log('Processing file ' + file); - * - * if( file.length > 32 ) { - * console.log('This file name is too long'); - * callback('File name too long'); - * } else { - * // Do work to process file here - * console.log('File processed'); - * callback(); - * } - * }, function(err) { - * // if any of the file processing produced an error, err would equal that error - * if( err ) { - * // One of the iterations produced an error. - * // All processing will now stop. - * console.log('A file failed to process'); - * } else { - * console.log('All files have been processed successfully'); - * } - * }); - */ - function eachLimit(coll, iteratee, callback) { - eachOf(coll, _withoutIndex(iteratee), callback); - } - - /** - * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. - * - * @name eachLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.each]{@link module:Collections.each} - * @alias forEachLimit - * @category Collection - * @param {Array|Iterable|Object} coll - A colleciton to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each item in `coll`. The - * iteratee is passed a `callback(err)` which must be called once it has - * completed. If no error has occurred, the `callback` should be run without - * arguments or with an explicit `null` argument. The array index is not passed - * to the iteratee. Invoked with (item, callback). If you need the index, use - * `eachOfLimit`. - * @param {Function} [callback] - A callback which is called when all - * `iteratee` functions have finished, or an error occurs. Invoked with (err). - */ - function eachLimit$1(coll, limit, iteratee, callback) { - _eachOfLimit(limit)(coll, _withoutIndex(iteratee), callback); - } - - /** - * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. - * - * @name eachSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.each]{@link module:Collections.each} - * @alias forEachSeries - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each - * item in `coll`. The iteratee is passed a `callback(err)` which must be called - * once it has completed. If no error has occurred, the `callback` should be run - * without arguments or with an explicit `null` argument. The array index is - * not passed to the iteratee. Invoked with (item, callback). If you need the - * index, use `eachOfSeries`. - * @param {Function} [callback] - A callback which is called when all - * `iteratee` functions have finished, or an error occurs. Invoked with (err). - */ - var eachSeries = doLimit(eachLimit$1, 1); - - /** - * Wrap an async function and ensure it calls its callback on a later tick of - * the event loop. If the function already calls its callback on a next tick, - * no extra deferral is added. This is useful for preventing stack overflows - * (`RangeError: Maximum call stack size exceeded`) and generally keeping - * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) - * contained. - * - * @name ensureAsync - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} fn - an async function, one that expects a node-style - * callback as its last argument. - * @returns {Function} Returns a wrapped function with the exact same call - * signature as the function passed in. - * @example - * - * function sometimesAsync(arg, callback) { - * if (cache[arg]) { - * return callback(null, cache[arg]); // this would be synchronous!! - * } else { - * doSomeIO(arg, callback); // this IO would be asynchronous - * } - * } - * - * // this has a risk of stack overflows if many results are cached in a row - * async.mapSeries(args, sometimesAsync, done); - * - * // this will defer sometimesAsync's callback if necessary, - * // preventing stack overflows - * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); - */ - function ensureAsync(fn) { - return initialParams(function (args, callback) { - var sync = true; - args.push(function () { - var innerArgs = arguments; - if (sync) { - setImmediate$1(function () { - callback.apply(null, innerArgs); - }); - } else { - callback.apply(null, innerArgs); - } - }); - fn.apply(this, args); - sync = false; - }); - } - - function notId(v) { - return !v; - } - - /** - * Returns `true` if every element in `coll` satisfies an async test. If any - * iteratee call returns `false`, the main `callback` is immediately called. - * - * @name every - * @static - * @memberOf module:Collections - * @method - * @alias all - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Result will be either `true` or `false` - * depending on the values of the async tests. Invoked with (err, result). - * @example - * - * async.every(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { - * // if result is true then every file exists - * }); - */ - var every = _createTester(eachOf, notId, notId); - - /** - * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. - * - * @name everyLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.every]{@link module:Collections.every} - * @alias allLimit - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Result will be either `true` or `false` - * depending on the values of the async tests. Invoked with (err, result). - */ - var everyLimit = _createTester(eachOfLimit, notId, notId); - - /** - * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. - * - * @name everySeries - * @static - * @memberOf module:Collections - * @method - * @see [async.every]{@link module:Collections.every} - * @alias allSeries - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Result will be either `true` or `false` - * depending on the values of the async tests. Invoked with (err, result). - */ - var everySeries = doLimit(everyLimit, 1); - - function _filter(eachfn, arr, iteratee, callback) { - callback = once(callback || noop); - var results = []; - eachfn(arr, function (x, index, callback) { - iteratee(x, function (err, v) { - if (err) { - callback(err); - } else { - if (v) { - results.push({ index: index, value: x }); - } - callback(); - } - }); - }, function (err) { - if (err) { - callback(err); - } else { - callback(null, arrayMap(results.sort(function (a, b) { - return a.index - b.index; - }), baseProperty('value'))); - } - }); - } - - /** - * Returns a new array of all the values in `coll` which pass an async truth - * test. This operation is performed in parallel, but the results array will be - * in the same order as the original. - * - * @name filter - * @static - * @memberOf module:Collections - * @method - * @alias select - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results). - * @example - * - * async.filter(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, results) { - * // results now equals an array of the existing files - * }); - */ - var filter = doParallel(_filter); - - /** - * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a - * time. - * - * @name filterLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.filter]{@link module:Collections.filter} - * @alias selectLimit - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results). - */ - var filterLimit = doParallelLimit(_filter); - - /** - * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. - * - * @name filterSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.filter]{@link module:Collections.filter} - * @alias selectSeries - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results) - */ - var filterSeries = doLimit(filterLimit, 1); - - /** - * Calls the asynchronous function `fn` with a callback parameter that allows it - * to call itself again, in series, indefinitely. - - * If an error is passed to the - * callback then `errback` is called with the error, and execution stops, - * otherwise it will never be called. - * - * @name forever - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Function} fn - a function to call repeatedly. Invoked with (next). - * @param {Function} [errback] - when `fn` passes an error to it's callback, - * this function will be called, and execution stops. Invoked with (err). - * @example - * - * async.forever( - * function(next) { - * // next is suitable for passing to things that need a callback(err [, whatever]); - * // it will result in this function being called again. - * }, - * function(err) { - * // if next is called with a value in its first parameter, it will appear - * // in here as 'err', and execution will stop. - * } - * ); - */ - function forever(fn, errback) { - var done = onlyOnce(errback || noop); - var task = ensureAsync(fn); - - function next(err) { - if (err) return done(err); - task(next); - } - next(); - } - - /** - * Logs the result of an `async` function to the `console`. Only works in - * Node.js or in browsers that support `console.log` and `console.error` (such - * as FF and Chrome). If multiple arguments are returned from the async - * function, `console.log` is called on each argument in order. - * - * @name log - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} function - The function you want to eventually apply all - * arguments to. - * @param {...*} arguments... - Any number of arguments to apply to the function. - * @example - * - * // in a module - * var hello = function(name, callback) { - * setTimeout(function() { - * callback(null, 'hello ' + name); - * }, 1000); - * }; - * - * // in the node repl - * node> async.log(hello, 'world'); - * 'hello world' - */ - var log = consoleFunc('log'); - - /** - * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a - * time. - * - * @name mapValuesLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.mapValues]{@link module:Collections.mapValues} - * @category Collection - * @param {Object} obj - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each value in `obj`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Result is an object of the - * transformed values from the `obj`. Invoked with (err, result). - */ - function mapValuesLimit(obj, limit, iteratee, callback) { - callback = once(callback || noop); - var newObj = {}; - eachOfLimit(obj, limit, function (val, key, next) { - iteratee(val, key, function (err, result) { - if (err) return next(err); - newObj[key] = result; - next(); - }); - }, function (err) { - callback(err, newObj); - }); - } - - /** - * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. - * - * Produces a new Object by mapping each value of `obj` through the `iteratee` - * function. The `iteratee` is called each `value` and `key` from `obj` and a - * callback for when it has finished processing. Each of these callbacks takes - * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` - * passes an error to its callback, the main `callback` (for the `mapValues` - * function) is immediately called with the error. - * - * Note, the order of the keys in the result is not guaranteed. The keys will - * be roughly in the order they complete, (but this is very engine-specific) - * - * @name mapValues - * @static - * @memberOf module:Collections - * @method - * @category Collection - * @param {Object} obj - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each value and key in - * `coll`. The iteratee is passed a `callback(err, transformed)` which must be - * called once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Results is an array of the - * transformed items from the `obj`. Invoked with (err, result). - * @example - * - * async.mapValues({ - * f1: 'file1', - * f2: 'file2', - * f3: 'file3' - * }, function (file, key, callback) { - * fs.stat(file, callback); - * }, function(err, result) { - * // results is now a map of stats for each file, e.g. - * // { - * // f1: [stats for file1], - * // f2: [stats for file2], - * // f3: [stats for file3] - * // } - * }); - */ - - var mapValues = doLimit(mapValuesLimit, Infinity); - - /** - * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. - * - * @name mapValuesSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.mapValues]{@link module:Collections.mapValues} - * @category Collection - * @param {Object} obj - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each value in `obj`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). - * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Result is an object of the - * transformed values from the `obj`. Invoked with (err, result). - */ - var mapValuesSeries = doLimit(mapValuesLimit, 1); - - function has(obj, key) { - return key in obj; - } - - /** - * Caches the results of an `async` function. When creating a hash to store - * function results against, the callback is omitted from the hash and an - * optional hash function can be used. - * - * If no hash function is specified, the first argument is used as a hash key, - * which may work reasonably if it is a string or a data type that converts to a - * distinct string. Note that objects and arrays will not behave reasonably. - * Neither will cases where the other arguments are significant. In such cases, - * specify your own hash function. - * - * The cache of results is exposed as the `memo` property of the function - * returned by `memoize`. - * - * @name memoize - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} fn - The function to proxy and cache results from. - * @param {Function} hasher - An optional function for generating a custom hash - * for storing results. It has all the arguments applied to it apart from the - * callback, and must be synchronous. - * @returns {Function} a memoized version of `fn` - * @example - * - * var slow_fn = function(name, callback) { - * // do something - * callback(null, result); - * }; - * var fn = async.memoize(slow_fn); - * - * // fn can now be used as if it were slow_fn - * fn('some name', function() { - * // callback - * }); - */ - function memoize(fn, hasher) { - var memo = Object.create(null); - var queues = Object.create(null); - hasher = hasher || identity; - var memoized = initialParams(function memoized(args, callback) { - var key = hasher.apply(null, args); - if (has(memo, key)) { - setImmediate$1(function () { - callback.apply(null, memo[key]); - }); - } else if (has(queues, key)) { - queues[key].push(callback); - } else { - queues[key] = [callback]; - fn.apply(null, args.concat([baseRest(function (args) { - memo[key] = args; - var q = queues[key]; - delete queues[key]; - for (var i = 0, l = q.length; i < l; i++) { - q[i].apply(null, args); - } - })])); - } - }); - memoized.memo = memo; - memoized.unmemoized = fn; - return memoized; - } - - /** - * Calls `callback` on a later loop around the event loop. In Node.js this just - * calls `setImmediate`. In the browser it will use `setImmediate` if - * available, otherwise `setTimeout(callback, 0)`, which means other higher - * priority events may precede the execution of `callback`. - * - * This is used internally for browser-compatibility purposes. - * - * @name nextTick - * @static - * @memberOf module:Utils - * @method - * @alias setImmediate - * @category Util - * @param {Function} callback - The function to call on a later loop around - * the event loop. Invoked with (args...). - * @param {...*} args... - any number of additional arguments to pass to the - * callback on the next tick. - * @example - * - * var call_order = []; - * async.nextTick(function() { - * call_order.push('two'); - * // call_order now equals ['one','two'] - * }); - * call_order.push('one'); - * - * async.setImmediate(function (a, b, c) { - * // a, b, and c equal 1, 2, and 3 - * }, 1, 2, 3); - */ - var _defer$1; - - if (hasNextTick) { - _defer$1 = process.nextTick; - } else if (hasSetImmediate) { - _defer$1 = setImmediate; - } else { - _defer$1 = fallback; - } - - var nextTick = wrap(_defer$1); - - function _parallel(eachfn, tasks, callback) { - callback = callback || noop; - var results = isArrayLike(tasks) ? [] : {}; - - eachfn(tasks, function (task, key, callback) { - task(baseRest(function (err, args) { - if (args.length <= 1) { - args = args[0]; - } - results[key] = args; - callback(err); - })); - }, function (err) { - callback(err, results); - }); - } - - /** - * Run the `tasks` collection of functions in parallel, without waiting until - * the previous function has completed. If any of the functions pass an error to - * its callback, the main `callback` is immediately called with the value of the - * error. Once the `tasks` have completed, the results are passed to the final - * `callback` as an array. - * - * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about - * parallel execution of code. If your tasks do not use any timers or perform - * any I/O, they will actually be executed in series. Any synchronous setup - * sections for each task will happen one after the other. JavaScript remains - * single-threaded. - * - * It is also possible to use an object instead of an array. Each property will - * be run as a function and the results will be passed to the final `callback` - * as an object instead of an array. This can be a more readable way of handling - * results from {@link async.parallel}. - * - * @name parallel - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Array|Iterable|Object} tasks - A collection containing functions to run. - * Each function is passed a `callback(err, result)` which it must call on - * completion with an error `err` (which can be `null`) and an optional `result` - * value. - * @param {Function} [callback] - An optional callback to run once all the - * functions have completed successfully. This function gets a results array - * (or object) containing all the result arguments passed to the task callbacks. - * Invoked with (err, results). - * @example - * async.parallel([ - * function(callback) { - * setTimeout(function() { - * callback(null, 'one'); - * }, 200); - * }, - * function(callback) { - * setTimeout(function() { - * callback(null, 'two'); - * }, 100); - * } - * ], - * // optional callback - * function(err, results) { - * // the results array will equal ['one','two'] even though - * // the second function had a shorter timeout. - * }); - * - * // an example using an object instead of an array - * async.parallel({ - * one: function(callback) { - * setTimeout(function() { - * callback(null, 1); - * }, 200); - * }, - * two: function(callback) { - * setTimeout(function() { - * callback(null, 2); - * }, 100); - * } - * }, function(err, results) { - * // results is now equals to: {one: 1, two: 2} - * }); - */ - function parallelLimit(tasks, callback) { - _parallel(eachOf, tasks, callback); - } - - /** - * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a - * time. - * - * @name parallelLimit - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.parallel]{@link module:ControlFlow.parallel} - * @category Control Flow - * @param {Array|Collection} tasks - A collection containing functions to run. - * Each function is passed a `callback(err, result)` which it must call on - * completion with an error `err` (which can be `null`) and an optional `result` - * value. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} [callback] - An optional callback to run once all the - * functions have completed successfully. This function gets a results array - * (or object) containing all the result arguments passed to the task callbacks. - * Invoked with (err, results). - */ - function parallelLimit$1(tasks, limit, callback) { - _parallel(_eachOfLimit(limit), tasks, callback); - } - - /** - * A queue of tasks for the worker function to complete. - * @typedef {Object} QueueObject - * @memberOf module:ControlFlow - * @property {Function} length - a function returning the number of items - * waiting to be processed. Invoke with `queue.length()`. - * @property {boolean} started - a boolean indicating whether or not any - * items have been pushed and processed by the queue. - * @property {Function} running - a function returning the number of items - * currently being processed. Invoke with `queue.running()`. - * @property {Function} workersList - a function returning the array of items - * currently being processed. Invoke with `queue.workersList()`. - * @property {Function} idle - a function returning false if there are items - * waiting or being processed, or true if not. Invoke with `queue.idle()`. - * @property {number} concurrency - an integer for determining how many `worker` - * functions should be run in parallel. This property can be changed after a - * `queue` is created to alter the concurrency on-the-fly. - * @property {Function} push - add a new task to the `queue`. Calls `callback` - * once the `worker` has finished processing the task. Instead of a single task, - * a `tasks` array can be submitted. The respective callback is used for every - * task in the list. Invoke with `queue.push(task, [callback])`, - * @property {Function} unshift - add a new task to the front of the `queue`. - * Invoke with `queue.unshift(task, [callback])`. - * @property {Function} saturated - a callback that is called when the number of - * running workers hits the `concurrency` limit, and further tasks will be - * queued. - * @property {Function} unsaturated - a callback that is called when the number - * of running workers is less than the `concurrency` & `buffer` limits, and - * further tasks will not be queued. - * @property {number} buffer - A minimum threshold buffer in order to say that - * the `queue` is `unsaturated`. - * @property {Function} empty - a callback that is called when the last item - * from the `queue` is given to a `worker`. - * @property {Function} drain - a callback that is called when the last item - * from the `queue` has returned from the `worker`. - * @property {Function} error - a callback that is called when a task errors. - * Has the signature `function(error, task)`. - * @property {boolean} paused - a boolean for determining whether the queue is - * in a paused state. - * @property {Function} pause - a function that pauses the processing of tasks - * until `resume()` is called. Invoke with `queue.pause()`. - * @property {Function} resume - a function that resumes the processing of - * queued tasks when the queue is paused. Invoke with `queue.resume()`. - * @property {Function} kill - a function that removes the `drain` callback and - * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`. - */ - - /** - * Creates a `queue` object with the specified `concurrency`. Tasks added to the - * `queue` are processed in parallel (up to the `concurrency` limit). If all - * `worker`s are in progress, the task is queued until one becomes available. - * Once a `worker` completes a `task`, that `task`'s callback is called. - * - * @name queue - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Function} worker - An asynchronous function for processing a queued - * task, which must call its `callback(err)` argument when finished, with an - * optional `error` as an argument. If you want to handle errors from an - * individual task, pass a callback to `q.push()`. Invoked with - * (task, callback). - * @param {number} [concurrency=1] - An `integer` for determining how many - * `worker` functions should be run in parallel. If omitted, the concurrency - * defaults to `1`. If the concurrency is `0`, an error is thrown. - * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can - * attached as certain properties to listen for specific events during the - * lifecycle of the queue. - * @example - * - * // create a queue object with concurrency 2 - * var q = async.queue(function(task, callback) { - * console.log('hello ' + task.name); - * callback(); - * }, 2); - * - * // assign a callback - * q.drain = function() { - * console.log('all items have been processed'); - * }; - * - * // add some items to the queue - * q.push({name: 'foo'}, function(err) { - * console.log('finished processing foo'); - * }); - * q.push({name: 'bar'}, function (err) { - * console.log('finished processing bar'); - * }); - * - * // add some items to the queue (batch-wise) - * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { - * console.log('finished processing item'); - * }); - * - * // add some items to the front of the queue - * q.unshift({name: 'bar'}, function (err) { - * console.log('finished processing bar'); - * }); - */ - function queue$1 (worker, concurrency) { - return queue(function (items, cb) { - worker(items[0], cb); - }, concurrency, 1); - } - - /** - * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and - * completed in ascending priority order. - * - * @name priorityQueue - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.queue]{@link module:ControlFlow.queue} - * @category Control Flow - * @param {Function} worker - An asynchronous function for processing a queued - * task, which must call its `callback(err)` argument when finished, with an - * optional `error` as an argument. If you want to handle errors from an - * individual task, pass a callback to `q.push()`. Invoked with - * (task, callback). - * @param {number} concurrency - An `integer` for determining how many `worker` - * functions should be run in parallel. If omitted, the concurrency defaults to - * `1`. If the concurrency is `0`, an error is thrown. - * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two - * differences between `queue` and `priorityQueue` objects: - * * `push(task, priority, [callback])` - `priority` should be a number. If an - * array of `tasks` is given, all tasks will be assigned the same priority. - * * The `unshift` method was removed. - */ - function priorityQueue (worker, concurrency) { - // Start with a normal queue - var q = queue$1(worker, concurrency); - - // Override push to accept second parameter representing priority - q.push = function (data, priority, callback) { - if (callback == null) callback = noop; - if (typeof callback !== 'function') { - throw new Error('task callback must be a function'); - } - q.started = true; - if (!isArray(data)) { - data = [data]; - } - if (data.length === 0) { - // call drain immediately if there are no tasks - return setImmediate$1(function () { - q.drain(); - }); - } - - priority = priority || 0; - var nextNode = q._tasks.head; - while (nextNode && priority >= nextNode.priority) { - nextNode = nextNode.next; - } - - arrayEach(data, function (task) { - var item = { - data: task, - priority: priority, - callback: callback - }; - - if (nextNode) { - q._tasks.insertBefore(nextNode, item); - } else { - q._tasks.push(item); - } - }); - setImmediate$1(q.process); - }; - - // Remove unshift function - delete q.unshift; - - return q; - } - - /** - * Runs the `tasks` array of functions in parallel, without waiting until the - * previous function has completed. Once any the `tasks` completed or pass an - * error to its callback, the main `callback` is immediately called. It's - * equivalent to `Promise.race()`. - * - * @name race - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Array} tasks - An array containing functions to run. Each function - * is passed a `callback(err, result)` which it must call on completion with an - * error `err` (which can be `null`) and an optional `result` value. - * @param {Function} callback - A callback to run once any of the functions have - * completed. This function gets an error or result from the first function that - * completed. Invoked with (err, result). - * @returns undefined - * @example - * - * async.race([ - * function(callback) { - * setTimeout(function() { - * callback(null, 'one'); - * }, 200); - * }, - * function(callback) { - * setTimeout(function() { - * callback(null, 'two'); - * }, 100); - * } - * ], - * // main callback - * function(err, result) { - * // the result will be equal to 'two' as it finishes earlier - * }); - */ - function race(tasks, callback) { - callback = once(callback || noop); - if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); - if (!tasks.length) return callback(); - arrayEach(tasks, function (task) { - task(callback); - }); - } - - var slice = Array.prototype.slice; - - /** - * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. - * - * @name reduceRight - * @static - * @memberOf module:Collections - * @method - * @see [async.reduce]{@link module:Collections.reduce} - * @alias foldr - * @category Collection - * @param {Array} array - A collection to iterate over. - * @param {*} memo - The initial state of the reduction. - * @param {Function} iteratee - A function applied to each item in the - * array to produce the next step in the reduction. The `iteratee` is passed a - * `callback(err, reduction)` which accepts an optional error as its first - * argument, and the state of the reduction as the second. If an error is - * passed to the callback, the reduction is stopped and the main `callback` is - * immediately called with the error. Invoked with (memo, item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Result is the reduced value. Invoked with - * (err, result). - */ - function reduceRight(array, memo, iteratee, callback) { - var reversed = slice.call(array).reverse(); - reduce(reversed, memo, iteratee, callback); - } - - /** - * Wraps the function in another function that always returns data even when it - * errors. - * - * The object returned has either the property `error` or `value`. - * - * @name reflect - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} fn - The function you want to wrap - * @returns {Function} - A function that always passes null to it's callback as - * the error. The second argument to the callback will be an `object` with - * either an `error` or a `value` property. - * @example - * - * async.parallel([ - * async.reflect(function(callback) { - * // do some stuff ... - * callback(null, 'one'); - * }), - * async.reflect(function(callback) { - * // do some more stuff but error ... - * callback('bad stuff happened'); - * }), - * async.reflect(function(callback) { - * // do some more stuff ... - * callback(null, 'two'); - * }) - * ], - * // optional callback - * function(err, results) { - * // values - * // results[0].value = 'one' - * // results[1].error = 'bad stuff happened' - * // results[2].value = 'two' - * }); - */ - function reflect(fn) { - return initialParams(function reflectOn(args, reflectCallback) { - args.push(baseRest(function callback(err, cbArgs) { - if (err) { - reflectCallback(null, { - error: err - }); - } else { - var value = null; - if (cbArgs.length === 1) { - value = cbArgs[0]; - } else if (cbArgs.length > 1) { - value = cbArgs; - } - reflectCallback(null, { - value: value - }); - } - })); - - return fn.apply(this, args); - }); - } - - function reject$1(eachfn, arr, iteratee, callback) { - _filter(eachfn, arr, function (value, cb) { - iteratee(value, function (err, v) { - if (err) { - cb(err); - } else { - cb(null, !v); - } - }); - }, callback); - } - - /** - * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. - * - * @name reject - * @static - * @memberOf module:Collections - * @method - * @see [async.filter]{@link module:Collections.filter} - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results). - * @example - * - * async.reject(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, results) { - * // results now equals an array of missing files - * createFiles(results); - * }); - */ - var reject = doParallel(reject$1); - - /** - * A helper function that wraps an array or an object of functions with reflect. - * - * @name reflectAll - * @static - * @memberOf module:Utils - * @method - * @see [async.reflect]{@link module:Utils.reflect} - * @category Util - * @param {Array} tasks - The array of functions to wrap in `async.reflect`. - * @returns {Array} Returns an array of functions, each function wrapped in - * `async.reflect` - * @example - * - * let tasks = [ - * function(callback) { - * setTimeout(function() { - * callback(null, 'one'); - * }, 200); - * }, - * function(callback) { - * // do some more stuff but error ... - * callback(new Error('bad stuff happened')); - * }, - * function(callback) { - * setTimeout(function() { - * callback(null, 'two'); - * }, 100); - * } - * ]; - * - * async.parallel(async.reflectAll(tasks), - * // optional callback - * function(err, results) { - * // values - * // results[0].value = 'one' - * // results[1].error = Error('bad stuff happened') - * // results[2].value = 'two' - * }); - * - * // an example using an object instead of an array - * let tasks = { - * one: function(callback) { - * setTimeout(function() { - * callback(null, 'one'); - * }, 200); - * }, - * two: function(callback) { - * callback('two'); - * }, - * three: function(callback) { - * setTimeout(function() { - * callback(null, 'three'); - * }, 100); - * } - * }; - * - * async.parallel(async.reflectAll(tasks), - * // optional callback - * function(err, results) { - * // values - * // results.one.value = 'one' - * // results.two.error = 'two' - * // results.three.value = 'three' - * }); - */ - function reflectAll(tasks) { - var results; - if (isArray(tasks)) { - results = arrayMap(tasks, reflect); - } else { - results = {}; - baseForOwn(tasks, function (task, key) { - results[key] = reflect.call(this, task); - }); - } - return results; - } - - /** - * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a - * time. - * - * @name rejectLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.reject]{@link module:Collections.reject} - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results). - */ - var rejectLimit = doParallelLimit(reject$1); - - /** - * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. - * - * @name rejectSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.reject]{@link module:Collections.reject} - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Invoked with (err, results). - */ - var rejectSeries = doLimit(rejectLimit, 1); - - /** - * Creates a function that returns `value`. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {*} value The value to return from the new function. - * @returns {Function} Returns the new constant function. - * @example - * - * var objects = _.times(2, _.constant({ 'a': 1 })); - * - * console.log(objects); - * // => [{ 'a': 1 }, { 'a': 1 }] - * - * console.log(objects[0] === objects[1]); - * // => true - */ - function constant$1(value) { - return function() { - return value; + + var eachOfLimit$2 = (limit) => { + return (obj, iteratee, callback) => { + callback = once(callback); + if (limit <= 0) { + throw new RangeError('concurrency limit cannot be less than 1') + } + if (!obj) { + return callback(null); + } + if (isAsyncGenerator(obj)) { + return asyncEachOfLimit(obj, limit, iteratee, callback) + } + if (isAsyncIterable(obj)) { + return asyncEachOfLimit(obj[Symbol.asyncIterator](), limit, iteratee, callback) + } + var nextElem = createIterator(obj); + var done = false; + var canceled = false; + var running = 0; + var looping = false; + + function iterateeCallback(err, value) { + if (canceled) return + running -= 1; + if (err) { + done = true; + callback(err); + } + else if (err === false) { + done = true; + canceled = true; + } + else if (value === breakLoop || (done && running <= 0)) { + done = true; + return callback(null); + } + else if (!looping) { + replenish(); + } + } + + function replenish () { + looping = true; + while (running < limit && !done) { + var elem = nextElem(); + if (elem === null) { + done = true; + if (running <= 0) { + callback(null); + } + return; + } + running += 1; + iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); + } + looping = false; + } + + replenish(); + }; }; - } - - /** - * Attempts to get a successful response from `task` no more than `times` times - * before returning an error. If the task is successful, the `callback` will be - * passed the result of the successful task. If all attempts fail, the callback - * will be passed the error and result (if any) of the final attempt. - * - * @name retry - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an - * object with `times` and `interval` or a number. - * * `times` - The number of attempts to make before giving up. The default - * is `5`. - * * `interval` - The time to wait between retries, in milliseconds. The - * default is `0`. The interval may also be specified as a function of the - * retry count (see example). - * * If `opts` is a number, the number specifies the number of times to retry, - * with the default interval of `0`. - * @param {Function} task - A function which receives two arguments: (1) a - * `callback(err, result)` which must be called when finished, passing `err` - * (which can be `null`) and the `result` of the function's execution, and (2) - * a `results` object, containing the results of the previously executed - * functions (if nested inside another control flow). Invoked with - * (callback, results). - * @param {Function} [callback] - An optional callback which is called when the - * task has succeeded, or after the final failed attempt. It receives the `err` - * and `result` arguments of the last attempt at completing the `task`. Invoked - * with (err, results). - * @example - * - * // The `retry` function can be used as a stand-alone control flow by passing - * // a callback, as shown below: - * - * // try calling apiMethod 3 times - * async.retry(3, apiMethod, function(err, result) { - * // do something with the result - * }); - * - * // try calling apiMethod 3 times, waiting 200 ms between each retry - * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { - * // do something with the result - * }); - * - * // try calling apiMethod 10 times with exponential backoff - * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) - * async.retry({ - * times: 10, - * interval: function(retryCount) { - * return 50 * Math.pow(2, retryCount); - * } - * }, apiMethod, function(err, result) { - * // do something with the result - * }); - * - * // try calling apiMethod the default 5 times no delay between each retry - * async.retry(apiMethod, function(err, result) { - * // do something with the result - * }); - * - * // It can also be embedded within other control flow functions to retry - * // individual methods that are not as reliable, like this: - * async.auto({ - * users: api.getUsers.bind(api), - * payments: async.retry(3, api.getPayments.bind(api)) - * }, function(err, results) { - * // do something with the results - * }); - */ - function retry(opts, task, callback) { - var DEFAULT_TIMES = 5; - var DEFAULT_INTERVAL = 0; - - var options = { - times: DEFAULT_TIMES, - intervalFunc: constant$1(DEFAULT_INTERVAL) - }; - - function parseTimes(acc, t) { - if (typeof t === 'object') { - acc.times = +t.times || DEFAULT_TIMES; - - acc.intervalFunc = typeof t.interval === 'function' ? t.interval : constant$1(+t.interval || DEFAULT_INTERVAL); - } else if (typeof t === 'number' || typeof t === 'string') { - acc.times = +t || DEFAULT_TIMES; - } else { - throw new Error("Invalid arguments for async.retry"); - } - } - - if (arguments.length < 3 && typeof opts === 'function') { - callback = task || noop; - task = opts; - } else { - parseTimes(options, opts); - callback = callback || noop; - } - - if (typeof task !== 'function') { - throw new Error("Invalid arguments for async.retry"); - } - - var attempt = 1; - function retryAttempt() { - task(function (err) { - if (err && attempt++ < options.times) { - setTimeout(retryAttempt, options.intervalFunc(attempt)); - } else { - callback.apply(null, arguments); - } - }); - } - - retryAttempt(); - } - - /** - * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it - * retryable, rather than immediately calling it with retries. - * - * @name retryable - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.retry]{@link module:ControlFlow.retry} - * @category Control Flow - * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional - * options, exactly the same as from `retry` - * @param {Function} task - the asynchronous function to wrap - * @returns {Functions} The wrapped function, which when invoked, will retry on - * an error, based on the parameters specified in `opts`. - * @example - * - * async.auto({ - * dep1: async.retryable(3, getFromFlakyService), - * process: ["dep1", async.retryable(3, function (results, cb) { - * maybeProcessData(results.dep1, cb); - * })] - * }, callback); - */ - function retryable (opts, task) { - if (!task) { - task = opts; - opts = null; - } - return initialParams(function (args, callback) { - function taskFn(cb) { - task.apply(null, args.concat([cb])); - } - - if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback); - }); - } - - /** - * Run the functions in the `tasks` collection in series, each one running once - * the previous function has completed. If any functions in the series pass an - * error to its callback, no more functions are run, and `callback` is - * immediately called with the value of the error. Otherwise, `callback` - * receives an array of results when `tasks` have completed. - * - * It is also possible to use an object instead of an array. Each property will - * be run as a function, and the results will be passed to the final `callback` - * as an object instead of an array. This can be a more readable way of handling - * results from {@link async.series}. - * - * **Note** that while many implementations preserve the order of object - * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) - * explicitly states that - * - * > The mechanics and order of enumerating the properties is not specified. - * - * So if you rely on the order in which your series of functions are executed, - * and want this to work on all platforms, consider using an array. - * - * @name series - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each - * function is passed a `callback(err, result)` it must call on completion with - * an error `err` (which can be `null`) and an optional `result` value. - * @param {Function} [callback] - An optional callback to run once all the - * functions have completed. This function gets a results array (or object) - * containing all the result arguments passed to the `task` callbacks. Invoked - * with (err, result). - * @example - * async.series([ - * function(callback) { - * // do some stuff ... - * callback(null, 'one'); - * }, - * function(callback) { - * // do some more stuff ... - * callback(null, 'two'); - * } - * ], - * // optional callback - * function(err, results) { - * // results is now equal to ['one', 'two'] - * }); - * - * async.series({ - * one: function(callback) { - * setTimeout(function() { - * callback(null, 1); - * }, 200); - * }, - * two: function(callback){ - * setTimeout(function() { - * callback(null, 2); - * }, 100); - * } - * }, function(err, results) { - * // results is now equal to: {one: 1, two: 2} - * }); - */ - function series(tasks, callback) { - _parallel(eachOfSeries, tasks, callback); - } - - /** - * Returns `true` if at least one element in the `coll` satisfies an async test. - * If any iteratee call returns `true`, the main `callback` is immediately - * called. - * - * @name some - * @static - * @memberOf module:Collections - * @method - * @alias any - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the iteratee functions have finished. - * Result will be either `true` or `false` depending on the values of the async - * tests. Invoked with (err, result). - * @example - * - * async.some(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { - * // if result is true then at least one of the files exists - * }); - */ - var some = _createTester(eachOf, Boolean, identity); - - /** - * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. - * - * @name someLimit - * @static - * @memberOf module:Collections - * @method - * @see [async.some]{@link module:Collections.some} - * @alias anyLimit - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the iteratee functions have finished. - * Result will be either `true` or `false` depending on the values of the async - * tests. Invoked with (err, result). - */ - var someLimit = _createTester(eachOfLimit, Boolean, identity); - - /** - * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. - * - * @name someSeries - * @static - * @memberOf module:Collections - * @method - * @see [async.some]{@link module:Collections.some} - * @alias anySeries - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). - * @param {Function} [callback] - A callback which is called as soon as any - * iteratee returns `true`, or after all the iteratee functions have finished. - * Result will be either `true` or `false` depending on the values of the async - * tests. Invoked with (err, result). - */ - var someSeries = doLimit(someLimit, 1); - - /** - * Sorts a list by the results of running each `coll` value through an async - * `iteratee`. - * - * @name sortBy - * @static - * @memberOf module:Collections - * @method - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, sortValue)` which must be called once - * it has completed with an error (which can be `null`) and a value to use as - * the sort criteria. Invoked with (item, callback). - * @param {Function} callback - A callback which is called after all the - * `iteratee` functions have finished, or an error occurs. Results is the items - * from the original `coll` sorted by the values returned by the `iteratee` - * calls. Invoked with (err, results). - * @example - * - * async.sortBy(['file1','file2','file3'], function(file, callback) { - * fs.stat(file, function(err, stats) { - * callback(err, stats.mtime); - * }); - * }, function(err, results) { - * // results is now the original array of files sorted by - * // modified date - * }); - * - * // By modifying the callback parameter the - * // sorting order can be influenced: - * - * // ascending order - * async.sortBy([1,9,3,5], function(x, callback) { - * callback(null, x); - * }, function(err,result) { - * // result callback - * }); - * - * // descending order - * async.sortBy([1,9,3,5], function(x, callback) { - * callback(null, x*-1); //<- x*-1 instead of x, turns the order around - * }, function(err,result) { - * // result callback - * }); - */ - function sortBy(coll, iteratee, callback) { - map(coll, function (x, callback) { - iteratee(x, function (err, criteria) { - if (err) return callback(err); - callback(null, { value: x, criteria: criteria }); - }); - }, function (err, results) { - if (err) return callback(err); - callback(null, arrayMap(results.sort(comparator), baseProperty('value'))); - }); - - function comparator(left, right) { - var a = left.criteria, - b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - } - } - - /** - * Sets a time limit on an asynchronous function. If the function does not call - * its callback within the specified milliseconds, it will be called with a - * timeout error. The code property for the error object will be `'ETIMEDOUT'`. - * - * @name timeout - * @static - * @memberOf module:Utils - * @method - * @category Util - * @param {Function} asyncFn - The asynchronous function you want to set the - * time limit. - * @param {number} milliseconds - The specified time limit. - * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) - * to timeout Error for more information.. - * @returns {Function} Returns a wrapped function that can be used with any of - * the control flow functions. - * @example - * - * async.timeout(function(callback) { - * doAsyncTask(callback); - * }, 1000); - */ - function timeout(asyncFn, milliseconds, info) { - var originalCallback, timer; - var timedOut = false; - - function injectedCallback() { - if (!timedOut) { - originalCallback.apply(null, arguments); - clearTimeout(timer); - } - } - - function timeoutCallback() { - var name = asyncFn.name || 'anonymous'; - var error = new Error('Callback function "' + name + '" timed out.'); - error.code = 'ETIMEDOUT'; - if (info) { - error.info = info; - } - timedOut = true; - originalCallback(error); - } - - return initialParams(function (args, origCallback) { - originalCallback = origCallback; - // setup timer and call original function - timer = setTimeout(timeoutCallback, milliseconds); - asyncFn.apply(null, args.concat(injectedCallback)); - }); - } - - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeCeil = Math.ceil; - var nativeMax$1 = Math.max; - /** - * The base implementation of `_.range` and `_.rangeRight` which doesn't - * coerce arguments. - * - * @private - * @param {number} start The start of the range. - * @param {number} end The end of the range. - * @param {number} step The value to increment or decrement by. - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Array} Returns the range of numbers. - */ - function baseRange(start, end, step, fromRight) { - var index = -1, - length = nativeMax$1(nativeCeil((end - start) / (step || 1)), 0), - result = Array(length); - - while (length--) { - result[fromRight ? length : ++index] = start; - start += step; + + /** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a + * time. + * + * @name eachOfLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. The `key` is the item's key, or index in the case of an + * array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachOfLimit(coll, limit, iteratee, callback) { + return eachOfLimit$2(limit)(coll, wrapAsync(iteratee), callback); } - return result; - } - - /** - * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a - * time. - * - * @name timesLimit - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.times]{@link module:ControlFlow.times} - * @category Control Flow - * @param {number} count - The number of times to run the function. - * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). - * @param {Function} callback - see [async.map]{@link module:Collections.map}. - */ - function timeLimit(count, limit, iteratee, callback) { - mapLimit(baseRange(0, count, 1), limit, iteratee, callback); - } - - /** - * Calls the `iteratee` function `n` times, and accumulates results in the same - * manner you would use with [map]{@link module:Collections.map}. - * - * @name times - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.map]{@link module:Collections.map} - * @category Control Flow - * @param {number} n - The number of times to run the function. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). - * @param {Function} callback - see {@link module:Collections.map}. - * @example - * - * // Pretend this is some complicated async factory - * var createUser = function(id, callback) { - * callback(null, { - * id: 'user' + id - * }); - * }; - * - * // generate 5 users - * async.times(5, function(n, next) { - * createUser(n, function(err, user) { - * next(err, user); - * }); - * }, function(err, users) { - * // we should now have 5 users - * }); - */ - var times = doLimit(timeLimit, Infinity); - - /** - * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. - * - * @name timesSeries - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.times]{@link module:ControlFlow.times} - * @category Control Flow - * @param {number} n - The number of times to run the function. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). - * @param {Function} callback - see {@link module:Collections.map}. - */ - var timesSeries = doLimit(timeLimit, 1); - - /** - * A relative of `reduce`. Takes an Object or Array, and iterates over each - * element in series, each step potentially mutating an `accumulator` value. - * The type of the accumulator defaults to the type of collection passed in. - * - * @name transform - * @static - * @memberOf module:Collections - * @method - * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {*} [accumulator] - The initial state of the transform. If omitted, - * it will default to an empty Object or Array, depending on the type of `coll` - * @param {Function} iteratee - A function applied to each item in the - * collection that potentially modifies the accumulator. The `iteratee` is - * passed a `callback(err)` which accepts an optional error as its first - * argument. If an error is passed to the callback, the transform is stopped - * and the main `callback` is immediately called with the error. - * Invoked with (accumulator, item, key, callback). - * @param {Function} [callback] - A callback which is called after all the - * `iteratee` functions have finished. Result is the transformed accumulator. - * Invoked with (err, result). - * @example - * - * async.transform([1,2,3], function(acc, item, index, callback) { - * // pointless async: - * process.nextTick(function() { - * acc.push(item * 2) - * callback(null) - * }); - * }, function(err, result) { - * // result is now equal to [2, 4, 6] - * }); - * - * @example - * - * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { - * setImmediate(function () { - * obj[key] = val * 2; - * callback(); - * }) - * }, function (err, result) { - * // result is equal to {a: 2, b: 4, c: 6} - * }) - */ - function transform(coll, accumulator, iteratee, callback) { - if (arguments.length === 3) { - callback = iteratee; - iteratee = accumulator; - accumulator = isArray(coll) ? [] : {}; - } - callback = once(callback || noop); - - eachOf(coll, function (v, k, cb) { - iteratee(accumulator, v, k, cb); - }, function (err) { - callback(err, accumulator); - }); - } - - /** - * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, - * unmemoized form. Handy for testing. - * - * @name unmemoize - * @static - * @memberOf module:Utils - * @method - * @see [async.memoize]{@link module:Utils.memoize} - * @category Util - * @param {Function} fn - the memoized function - * @returns {Function} a function that calls the original unmemoized function - */ - function unmemoize(fn) { - return function () { - return (fn.unmemoized || fn).apply(null, arguments); - }; - } - - /** - * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when - * stopped, or an error occurs. - * - * @name whilst - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Function} test - synchronous truth test to perform before each - * execution of `fn`. Invoked with (). - * @param {Function} iteratee - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s - * callback. Invoked with (err, [results]); - * @returns undefined - * @example - * - * var count = 0; - * async.whilst( - * function() { return count < 5; }, - * function(callback) { - * count++; - * setTimeout(function() { - * callback(null, count); - * }, 1000); - * }, - * function (err, n) { - * // 5 seconds have passed, n = 5 - * } - * ); - */ - function whilst(test, iteratee, callback) { - callback = onlyOnce(callback || noop); - if (!test()) return callback(null); - var next = baseRest(function (err, args) { - if (err) return callback(err); - if (test()) return iteratee(next); - callback.apply(null, [null].concat(args)); - }); - iteratee(next); - } - - /** - * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when - * stopped, or an error occurs. `callback` will be passed an error and any - * arguments passed to the final `fn`'s callback. - * - * The inverse of [whilst]{@link module:ControlFlow.whilst}. - * - * @name until - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.whilst]{@link module:ControlFlow.whilst} - * @category Control Flow - * @param {Function} test - synchronous truth test to perform before each - * execution of `fn`. Invoked with (). - * @param {Function} fn - A function which is called each time `test` fails. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} [callback] - A callback which is called after the test - * function has passed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s - * callback. Invoked with (err, [results]); - */ - function until(test, fn, callback) { - whilst(function () { - return !test.apply(this, arguments); - }, fn, callback); - } - - /** - * Runs the `tasks` array of functions in series, each passing their results to - * the next in the array. However, if any of the `tasks` pass an error to their - * own callback, the next function is not executed, and the main `callback` is - * immediately called with the error. - * - * @name waterfall - * @static - * @memberOf module:ControlFlow - * @method - * @category Control Flow - * @param {Array} tasks - An array of functions to run, each function is passed - * a `callback(err, result1, result2, ...)` it must call on completion. The - * first argument is an error (which can be `null`) and any further arguments - * will be passed as arguments in order to the next task. - * @param {Function} [callback] - An optional callback to run once all the - * functions have completed. This will be passed the results of the last task's - * callback. Invoked with (err, [results]). - * @returns undefined - * @example - * - * async.waterfall([ - * function(callback) { - * callback(null, 'one', 'two'); - * }, - * function(arg1, arg2, callback) { - * // arg1 now equals 'one' and arg2 now equals 'two' - * callback(null, 'three'); - * }, - * function(arg1, callback) { - * // arg1 now equals 'three' - * callback(null, 'done'); - * } - * ], function (err, result) { - * // result now equals 'done' - * }); - * - * // Or, with named functions: - * async.waterfall([ - * myFirstFunction, - * mySecondFunction, - * myLastFunction, - * ], function (err, result) { - * // result now equals 'done' - * }); - * function myFirstFunction(callback) { - * callback(null, 'one', 'two'); - * } - * function mySecondFunction(arg1, arg2, callback) { - * // arg1 now equals 'one' and arg2 now equals 'two' - * callback(null, 'three'); - * } - * function myLastFunction(arg1, callback) { - * // arg1 now equals 'three' - * callback(null, 'done'); - * } - */ - function waterfall (tasks, callback) { - callback = once(callback || noop); - if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); - if (!tasks.length) return callback(); - var taskIndex = 0; - - function nextTask(args) { - if (taskIndex === tasks.length) { - return callback.apply(null, [null].concat(args)); - } - - var taskCallback = onlyOnce(baseRest(function (err, args) { - if (err) { - return callback.apply(null, [err].concat(args)); - } - nextTask(args); - })); - - args.push(taskCallback); - - var task = tasks[taskIndex++]; - task.apply(null, args); - } - - nextTask([]); - } - - var index = { - applyEach: applyEach, - applyEachSeries: applyEachSeries, - apply: apply$1, - asyncify: asyncify, - auto: auto, - autoInject: autoInject, - cargo: cargo, - compose: compose, - concat: concat, - concatSeries: concatSeries, - constant: constant, - detect: detect, - detectLimit: detectLimit, - detectSeries: detectSeries, - dir: dir, - doDuring: doDuring, - doUntil: doUntil, - doWhilst: doWhilst, - during: during, - each: eachLimit, - eachLimit: eachLimit$1, - eachOf: eachOf, - eachOfLimit: eachOfLimit, - eachOfSeries: eachOfSeries, - eachSeries: eachSeries, - ensureAsync: ensureAsync, - every: every, - everyLimit: everyLimit, - everySeries: everySeries, - filter: filter, - filterLimit: filterLimit, - filterSeries: filterSeries, - forever: forever, - log: log, - map: map, - mapLimit: mapLimit, - mapSeries: mapSeries, - mapValues: mapValues, - mapValuesLimit: mapValuesLimit, - mapValuesSeries: mapValuesSeries, - memoize: memoize, - nextTick: nextTick, - parallel: parallelLimit, - parallelLimit: parallelLimit$1, - priorityQueue: priorityQueue, - queue: queue$1, - race: race, - reduce: reduce, - reduceRight: reduceRight, - reflect: reflect, - reflectAll: reflectAll, - reject: reject, - rejectLimit: rejectLimit, - rejectSeries: rejectSeries, - retry: retry, - retryable: retryable, - seq: seq, - series: series, - setImmediate: setImmediate$1, - some: some, - someLimit: someLimit, - someSeries: someSeries, - sortBy: sortBy, - timeout: timeout, - times: times, - timesLimit: timeLimit, - timesSeries: timesSeries, - transform: transform, - unmemoize: unmemoize, - until: until, - waterfall: waterfall, - whilst: whilst, - - // aliases - all: every, - any: some, - forEach: eachLimit, - forEachSeries: eachSeries, - forEachLimit: eachLimit$1, - forEachOf: eachOf, - forEachOfSeries: eachOfSeries, - forEachOfLimit: eachOfLimit, - inject: reduce, - foldl: reduce, - foldr: reduceRight, - select: filter, - selectLimit: filterLimit, - selectSeries: filterSeries, - wrapSync: asyncify - }; - - exports['default'] = index; - exports.applyEach = applyEach; - exports.applyEachSeries = applyEachSeries; - exports.apply = apply$1; - exports.asyncify = asyncify; - exports.auto = auto; - exports.autoInject = autoInject; - exports.cargo = cargo; - exports.compose = compose; - exports.concat = concat; - exports.concatSeries = concatSeries; - exports.constant = constant; - exports.detect = detect; - exports.detectLimit = detectLimit; - exports.detectSeries = detectSeries; - exports.dir = dir; - exports.doDuring = doDuring; - exports.doUntil = doUntil; - exports.doWhilst = doWhilst; - exports.during = during; - exports.each = eachLimit; - exports.eachLimit = eachLimit$1; - exports.eachOf = eachOf; - exports.eachOfLimit = eachOfLimit; - exports.eachOfSeries = eachOfSeries; - exports.eachSeries = eachSeries; - exports.ensureAsync = ensureAsync; - exports.every = every; - exports.everyLimit = everyLimit; - exports.everySeries = everySeries; - exports.filter = filter; - exports.filterLimit = filterLimit; - exports.filterSeries = filterSeries; - exports.forever = forever; - exports.log = log; - exports.map = map; - exports.mapLimit = mapLimit; - exports.mapSeries = mapSeries; - exports.mapValues = mapValues; - exports.mapValuesLimit = mapValuesLimit; - exports.mapValuesSeries = mapValuesSeries; - exports.memoize = memoize; - exports.nextTick = nextTick; - exports.parallel = parallelLimit; - exports.parallelLimit = parallelLimit$1; - exports.priorityQueue = priorityQueue; - exports.queue = queue$1; - exports.race = race; - exports.reduce = reduce; - exports.reduceRight = reduceRight; - exports.reflect = reflect; - exports.reflectAll = reflectAll; - exports.reject = reject; - exports.rejectLimit = rejectLimit; - exports.rejectSeries = rejectSeries; - exports.retry = retry; - exports.retryable = retryable; - exports.seq = seq; - exports.series = series; - exports.setImmediate = setImmediate$1; - exports.some = some; - exports.someLimit = someLimit; - exports.someSeries = someSeries; - exports.sortBy = sortBy; - exports.timeout = timeout; - exports.times = times; - exports.timesLimit = timeLimit; - exports.timesSeries = timesSeries; - exports.transform = transform; - exports.unmemoize = unmemoize; - exports.until = until; - exports.waterfall = waterfall; - exports.whilst = whilst; - exports.all = every; - exports.allLimit = everyLimit; - exports.allSeries = everySeries; - exports.any = some; - exports.anyLimit = someLimit; - exports.anySeries = someSeries; - exports.find = detect; - exports.findLimit = detectLimit; - exports.findSeries = detectSeries; - exports.forEach = eachLimit; - exports.forEachSeries = eachSeries; - exports.forEachLimit = eachLimit$1; - exports.forEachOf = eachOf; - exports.forEachOfSeries = eachOfSeries; - exports.forEachOfLimit = eachOfLimit; - exports.inject = reduce; - exports.foldl = reduce; - exports.foldr = reduceRight; - exports.select = filter; - exports.selectLimit = filterLimit; - exports.selectSeries = filterSeries; - exports.wrapSync = asyncify; - -})); \ No newline at end of file + + var eachOfLimit$1 = awaitify(eachOfLimit, 4); + + // eachOf implementation optimized for array-likes + function eachOfArrayLike(coll, iteratee, callback) { + callback = once(callback); + var index = 0, + completed = 0, + {length} = coll, + canceled = false; + if (length === 0) { + callback(null); + } + + function iteratorCallback(err, value) { + if (err === false) { + canceled = true; + } + if (canceled === true) return + if (err) { + callback(err); + } else if ((++completed === length) || value === breakLoop) { + callback(null); + } + } + + for (; index < length; index++) { + iteratee(coll[index], index, onlyOnce(iteratorCallback)); + } + } + + // a generic version of eachOf which can handle array, object, and iterator cases. + function eachOfGeneric (coll, iteratee, callback) { + return eachOfLimit$1(coll, Infinity, iteratee, callback); + } + + /** + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument + * to the iteratee. + * + * @name eachOf + * @static + * @memberOf module:Collections + * @method + * @alias forEachOf + * @category Collection + * @see [async.each]{@link module:Collections.each} + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each + * item in `coll`. + * The `key` is the item's key, or index in the case of an array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dev.json is a file containing a valid json object config for dev environment + * // dev.json is a file containing a valid json object config for test environment + * // prod.json is a file containing a valid json object config for prod environment + * // invalid.json is a file with a malformed json object + * + * let configs = {}; //global variable + * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'}; + * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'}; + * + * // asynchronous function that reads a json file and parses the contents as json object + * function parseFile(file, key, callback) { + * fs.readFile(file, "utf8", function(err, data) { + * if (err) return calback(err); + * try { + * configs[key] = JSON.parse(data); + * } catch (e) { + * return callback(e); + * } + * callback(); + * }); + * } + * + * // Using callbacks + * async.forEachOf(validConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * } else { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * // JSON parse error exception + * } else { + * console.log(configs); + * } + * }); + * + * // Using Promises + * async.forEachOf(validConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * }).catch( err => { + * console.error(err); + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * }).catch( err => { + * console.error(err); + * // JSON parse error exception + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.forEachOf(validConfigFileMap, parseFile); + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * catch (err) { + * console.log(err); + * } + * } + * + * //Error handing + * async () => { + * try { + * let result = await async.forEachOf(invalidConfigFileMap, parseFile); + * console.log(configs); + * } + * catch (err) { + * console.log(err); + * // JSON parse error exception + * } + * } + * + */ + function eachOf(coll, iteratee, callback) { + var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; + return eachOfImplementation(coll, wrapAsync(iteratee), callback); + } + + var eachOf$1 = awaitify(eachOf, 3); + + /** + * Produces a new collection of values by mapping each value in `coll` through + * the `iteratee` function. The `iteratee` is called with an item from `coll` + * and a callback for when it has finished processing. Each of these callbacks + * takes 2 arguments: an `error`, and the transformed item from `coll`. If + * `iteratee` passes an error to its callback, the main `callback` (for the + * `map` function) is immediately called with the error. + * + * Note, that since this function applies the `iteratee` to each item in + * parallel, there is no guarantee that the `iteratee` functions will complete + * in order. However, the results array will be in the same order as the + * original `coll`. + * + * If `map` is passed an Object, the results will be an Array. The results + * will roughly be in the order of the original Objects' keys (but this can + * vary across JavaScript engines). + * + * @name map + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an Array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.map(fileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * }); + * + * // Using Promises + * async.map(fileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.map(fileList, getFileSizeInBytes); + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.map(withMissingFileList, getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function map (coll, iteratee, callback) { + return _asyncMap(eachOf$1, coll, iteratee, callback) + } + var map$1 = awaitify(map, 3); + + /** + * Applies the provided arguments to each function in the array, calling + * `callback` after all functions have completed. If you only provide the first + * argument, `fns`, then it will return a function which lets you pass in the + * arguments as if it were a single function call. If more arguments are + * provided, `callback` is required while `args` is still optional. The results + * for each of the applied async functions are passed to the final callback + * as an array. + * + * @name applyEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s + * to all call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {AsyncFunction} - Returns a function that takes no args other than + * an optional callback, that is the result of applying the `args` to each + * of the functions. + * @example + * + * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket') + * + * appliedFn((err, results) => { + * // results[0] is the results for `enableSearch` + * // results[1] is the results for `updateSchema` + * }); + * + * // partial application example: + * async.each( + * buckets, + * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(), + * callback + * ); + */ + var applyEach = applyEach$1(map$1); + + /** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time. + * + * @name eachOfSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachOfSeries(coll, iteratee, callback) { + return eachOfLimit$1(coll, 1, iteratee, callback) + } + var eachOfSeries$1 = awaitify(eachOfSeries, 3); + + /** + * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. + * + * @name mapSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function mapSeries (coll, iteratee, callback) { + return _asyncMap(eachOfSeries$1, coll, iteratee, callback) + } + var mapSeries$1 = awaitify(mapSeries, 3); + + /** + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. + * + * @name applyEachSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.applyEach]{@link module:ControlFlow.applyEach} + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all + * call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {AsyncFunction} - A function, that when called, is the result of + * appling the `args` to the list of functions. It takes no args, other than + * a callback. + */ + var applyEachSeries = applyEach$1(mapSeries$1); + + const PROMISE_SYMBOL = Symbol('promiseCallback'); + + function promiseCallback () { + let resolve, reject; + function callback (err, ...args) { + if (err) return reject(err) + resolve(args.length > 1 ? args : args[0]); + } + + callback[PROMISE_SYMBOL] = new Promise((res, rej) => { + resolve = res, + reject = rej; + }); + + return callback + } + + /** + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on + * their requirements. Each function can optionally depend on other functions + * being completed first, and each function is run as soon as its requirements + * are satisfied. + * + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence + * will stop. Further tasks will not execute (so any other functions depending + * on it will not run), and the main `callback` is immediately called with the + * error. + * + * {@link AsyncFunction}s also receive an object containing the results of functions which + * have completed so far as the first argument, if they have dependencies. If a + * task function has no dependencies, it will only be passed a callback. + * + * @name auto + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Object} tasks - An object. Each of its properties is either a + * function or an array of requirements, with the {@link AsyncFunction} itself the last item + * in the array. The object's key of a property serves as the name of the task + * defined by that property, i.e. can be used when specifying requirements for + * other tasks. The function receives one or two arguments: + * * a `results` object, containing the results of the previously executed + * functions, only passed if the task has any dependencies, + * * a `callback(err, result)` function, which must be called when finished, + * passing an `error` (which can be `null`) and the result of the function's + * execution. + * @param {number} [concurrency=Infinity] - An optional `integer` for + * determining the maximum number of tasks that can be run in parallel. By + * default, as many as possible. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback. Results are always returned; however, if an + * error occurs, no further `tasks` will be performed, and the results object + * will only contain partial results. Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + * @example + * + * //Using Callbacks + * async.auto({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }, function(err, results) { + * if (err) { + * console.log('err = ', err); + * } + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }); + * + * //Using Promises + * async.auto({ + * get_data: function(callback) { + * console.log('in get_data'); + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * console.log('in make_folder'); + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }).then(results => { + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }).catch(err => { + * console.log('err = ', err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.auto({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }); + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function auto(tasks, concurrency, callback) { + if (typeof concurrency !== 'number') { + // concurrency is optional, shift the args. + callback = concurrency; + concurrency = null; + } + callback = once(callback || promiseCallback()); + var numTasks = Object.keys(tasks).length; + if (!numTasks) { + return callback(null); + } + if (!concurrency) { + concurrency = numTasks; + } + + var results = {}; + var runningTasks = 0; + var canceled = false; + var hasError = false; + + var listeners = Object.create(null); + + var readyTasks = []; + + // for cycle detection: + var readyToCheck = []; // tasks that have been identified as reachable + // without the possibility of returning to an ancestor task + var uncheckedDependencies = {}; + + Object.keys(tasks).forEach(key => { + var task = tasks[key]; + if (!Array.isArray(task)) { + // no dependencies + enqueueTask(key, [task]); + readyToCheck.push(key); + return; + } + + var dependencies = task.slice(0, task.length - 1); + var remainingDependencies = dependencies.length; + if (remainingDependencies === 0) { + enqueueTask(key, task); + readyToCheck.push(key); + return; + } + uncheckedDependencies[key] = remainingDependencies; + + dependencies.forEach(dependencyName => { + if (!tasks[dependencyName]) { + throw new Error('async.auto task `' + key + + '` has a non-existent dependency `' + + dependencyName + '` in ' + + dependencies.join(', ')); + } + addListener(dependencyName, () => { + remainingDependencies--; + if (remainingDependencies === 0) { + enqueueTask(key, task); + } + }); + }); + }); + + checkForDeadlocks(); + processQueue(); + + function enqueueTask(key, task) { + readyTasks.push(() => runTask(key, task)); + } + + function processQueue() { + if (canceled) return + if (readyTasks.length === 0 && runningTasks === 0) { + return callback(null, results); + } + while(readyTasks.length && runningTasks < concurrency) { + var run = readyTasks.shift(); + run(); + } + + } + + function addListener(taskName, fn) { + var taskListeners = listeners[taskName]; + if (!taskListeners) { + taskListeners = listeners[taskName] = []; + } + + taskListeners.push(fn); + } + + function taskComplete(taskName) { + var taskListeners = listeners[taskName] || []; + taskListeners.forEach(fn => fn()); + processQueue(); + } + + + function runTask(key, task) { + if (hasError) return; + + var taskCallback = onlyOnce((err, ...result) => { + runningTasks--; + if (err === false) { + canceled = true; + return + } + if (result.length < 2) { + [result] = result; + } + if (err) { + var safeResults = {}; + Object.keys(results).forEach(rkey => { + safeResults[rkey] = results[rkey]; + }); + safeResults[key] = result; + hasError = true; + listeners = Object.create(null); + if (canceled) return + callback(err, safeResults); + } else { + results[key] = result; + taskComplete(key); + } + }); + + runningTasks++; + var taskFn = wrapAsync(task[task.length - 1]); + if (task.length > 1) { + taskFn(results, taskCallback); + } else { + taskFn(taskCallback); + } + } + + function checkForDeadlocks() { + // Kahn's algorithm + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html + var currentTask; + var counter = 0; + while (readyToCheck.length) { + currentTask = readyToCheck.pop(); + counter++; + getDependents(currentTask).forEach(dependent => { + if (--uncheckedDependencies[dependent] === 0) { + readyToCheck.push(dependent); + } + }); + } + + if (counter !== numTasks) { + throw new Error( + 'async.auto cannot execute tasks due to a recursive dependency' + ); + } + } + + function getDependents(taskName) { + var result = []; + Object.keys(tasks).forEach(key => { + const task = tasks[key]; + if (Array.isArray(task) && task.indexOf(taskName) >= 0) { + result.push(key); + } + }); + return result; + } + + return callback[PROMISE_SYMBOL] + } + + var FN_ARGS = /^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/; + var ARROW_FN_ARGS = /^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/; + var FN_ARG_SPLIT = /,/; + var FN_ARG = /(=.+)?(\s*)$/; + + function stripComments(string) { + let stripped = ''; + let index = 0; + let endBlockComment = string.indexOf('*/'); + while (index < string.length) { + if (string[index] === '/' && string[index+1] === '/') { + // inline comment + let endIndex = string.indexOf('\n', index); + index = (endIndex === -1) ? string.length : endIndex; + } else if ((endBlockComment !== -1) && (string[index] === '/') && (string[index+1] === '*')) { + // block comment + let endIndex = string.indexOf('*/', index); + if (endIndex !== -1) { + index = endIndex + 2; + endBlockComment = string.indexOf('*/', index); + } else { + stripped += string[index]; + index++; + } + } else { + stripped += string[index]; + index++; + } + } + return stripped; + } + + function parseParams(func) { + const src = stripComments(func.toString()); + let match = src.match(FN_ARGS); + if (!match) { + match = src.match(ARROW_FN_ARGS); + } + if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src) + let [, args] = match; + return args + .replace(/\s/g, '') + .split(FN_ARG_SPLIT) + .map((arg) => arg.replace(FN_ARG, '').trim()); + } + + /** + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent + * tasks are specified as parameters to the function, after the usual callback + * parameter, with the parameter names matching the names of the tasks it + * depends on. This can provide even more readable task graphs which can be + * easier to maintain. + * + * If a final callback is specified, the task results are similarly injected, + * specified as named parameters after the initial error parameter. + * + * The autoInject function is purely syntactic sugar and its semantics are + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}. + * + * @name autoInject + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.auto]{@link module:ControlFlow.auto} + * @category Control Flow + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of + * the form 'func([dependencies...], callback). The object's key of a property + * serves as the name of the task defined by that property, i.e. can be used + * when specifying requirements for other tasks. + * * The `callback` parameter is a `callback(err, result)` which must be called + * when finished, passing an `error` (which can be `null`) and the result of + * the function's execution. The remaining parameters name other tasks on + * which the task is dependent, and the results from those tasks are the + * arguments of those parameters. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback, and a `results` object with any completed + * task results, similar to `auto`. + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // The example from `auto` can be rewritten as follows: + * async.autoInject({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: function(get_data, make_folder, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }, + * email_link: function(write_file, callback) { + * // once the file is written let's email a link to it... + * // write_file contains the filename returned by write_file. + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * } + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + * + * // If you are using a JS minifier that mangles parameter names, `autoInject` + * // will not work with plain functions, since the parameter names will be + * // collapsed to a single letter identifier. To work around this, you can + * // explicitly specify the names of the parameters your task function needs + * // in an array, similar to Angular.js dependency injection. + * + * // This still has an advantage over plain `auto`, since the results a task + * // depends on are still spread into arguments. + * async.autoInject({ + * //... + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(write_file, callback) { + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * }] + * //... + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + */ + function autoInject(tasks, callback) { + var newTasks = {}; + + Object.keys(tasks).forEach(key => { + var taskFn = tasks[key]; + var params; + var fnIsAsync = isAsync(taskFn); + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); + + if (Array.isArray(taskFn)) { + params = [...taskFn]; + taskFn = params.pop(); + + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); + } else if (hasNoDeps) { + // no dependencies, use the function as-is + newTasks[key] = taskFn; + } else { + params = parseParams(taskFn); + if ((taskFn.length === 0 && !fnIsAsync) && params.length === 0) { + throw new Error("autoInject task functions require explicit parameters."); + } + + // remove callback param + if (!fnIsAsync) params.pop(); + + newTasks[key] = params.concat(newTask); + } + + function newTask(results, taskCb) { + var newArgs = params.map(name => results[name]); + newArgs.push(taskCb); + wrapAsync(taskFn)(...newArgs); + } + }); + + return auto(newTasks, callback); + } + + // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation + // used for queues. This implementation assumes that the node provided by the user can be modified + // to adjust the next and last properties. We implement only the minimal functionality + // for queue support. + class DLL { + constructor() { + this.head = this.tail = null; + this.length = 0; + } + + removeLink(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next; + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; + + node.prev = node.next = null; + this.length -= 1; + return node; + } + + empty () { + while(this.head) this.shift(); + return this; + } + + insertAfter(node, newNode) { + newNode.prev = node; + newNode.next = node.next; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; + node.next = newNode; + this.length += 1; + } + + insertBefore(node, newNode) { + newNode.prev = node.prev; + newNode.next = node; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; + node.prev = newNode; + this.length += 1; + } + + unshift(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); + } + + push(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); + } + + shift() { + return this.head && this.removeLink(this.head); + } + + pop() { + return this.tail && this.removeLink(this.tail); + } + + toArray() { + return [...this] + } + + *[Symbol.iterator] () { + var cur = this.head; + while (cur) { + yield cur.data; + cur = cur.next; + } + } + + remove (testFn) { + var curr = this.head; + while(curr) { + var {next} = curr; + if (testFn(curr)) { + this.removeLink(curr); + } + curr = next; + } + return this; + } + } + + function setInitial(dll, node) { + dll.length = 1; + dll.head = dll.tail = node; + } + + function queue$1(worker, concurrency, payload) { + if (concurrency == null) { + concurrency = 1; + } + else if(concurrency === 0) { + throw new RangeError('Concurrency must not be zero'); + } + + var _worker = wrapAsync(worker); + var numRunning = 0; + var workersList = []; + const events = { + error: [], + drain: [], + saturated: [], + unsaturated: [], + empty: [] + }; + + function on (event, handler) { + events[event].push(handler); + } + + function once (event, handler) { + const handleAndRemove = (...args) => { + off(event, handleAndRemove); + handler(...args); + }; + events[event].push(handleAndRemove); + } + + function off (event, handler) { + if (!event) return Object.keys(events).forEach(ev => events[ev] = []) + if (!handler) return events[event] = [] + events[event] = events[event].filter(ev => ev !== handler); + } + + function trigger (event, ...args) { + events[event].forEach(handler => handler(...args)); + } + + var processingScheduled = false; + function _insert(data, insertAtFront, rejectOnError, callback) { + if (callback != null && typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + + var res, rej; + function promiseCallback (err, ...args) { + // we don't care about the error, let the global error handler + // deal with it + if (err) return rejectOnError ? rej(err) : res() + if (args.length <= 1) return res(args[0]) + res(args); + } + + var item = q._createTaskItem( + data, + rejectOnError ? promiseCallback : + (callback || promiseCallback) + ); + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); + } + + if (!processingScheduled) { + processingScheduled = true; + setImmediate$1(() => { + processingScheduled = false; + q.process(); + }); + } + + if (rejectOnError || !callback) { + return new Promise((resolve, reject) => { + res = resolve; + rej = reject; + }) + } + } + + function _createCB(tasks) { + return function (err, ...args) { + numRunning -= 1; + + for (var i = 0, l = tasks.length; i < l; i++) { + var task = tasks[i]; + + var index = workersList.indexOf(task); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); + } + + task.callback(err, ...args); + + if (err != null) { + trigger('error', err, task.data); + } + } + + if (numRunning <= (q.concurrency - q.buffer) ) { + trigger('unsaturated'); + } + + if (q.idle()) { + trigger('drain'); + } + q.process(); + }; + } + + function _maybeDrain(data) { + if (data.length === 0 && q.idle()) { + // call drain immediately if there are no tasks + setImmediate$1(() => trigger('drain')); + return true + } + return false + } + + const eventMethod = (name) => (handler) => { + if (!handler) { + return new Promise((resolve, reject) => { + once(name, (err, data) => { + if (err) return reject(err) + resolve(data); + }); + }) + } + off(name); + on(name, handler); + + }; + + var isProcessing = false; + var q = { + _tasks: new DLL(), + _createTaskItem (data, callback) { + return { + data, + callback + }; + }, + *[Symbol.iterator] () { + yield* q._tasks[Symbol.iterator](); + }, + concurrency, + payload, + buffer: concurrency / 4, + started: false, + paused: false, + push (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, false, callback)) + } + return _insert(data, false, false, callback); + }, + pushAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, true, callback)) + } + return _insert(data, false, true, callback); + }, + kill () { + off(); + q._tasks.empty(); + }, + unshift (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, false, callback)) + } + return _insert(data, true, false, callback); + }, + unshiftAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, true, callback)) + } + return _insert(data, true, true, callback); + }, + remove (testFn) { + q._tasks.remove(testFn); + }, + process () { + // Avoid trying to start too many processing operations. This can occur + // when callbacks resolve synchronously (#1267). + if (isProcessing) { + return; + } + isProcessing = true; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ + var tasks = [], data = []; + var l = q._tasks.length; + if (q.payload) l = Math.min(l, q.payload); + for (var i = 0; i < l; i++) { + var node = q._tasks.shift(); + tasks.push(node); + workersList.push(node); + data.push(node.data); + } + + numRunning += 1; + + if (q._tasks.length === 0) { + trigger('empty'); + } + + if (numRunning === q.concurrency) { + trigger('saturated'); + } + + var cb = onlyOnce(_createCB(tasks)); + _worker(data, cb); + } + isProcessing = false; + }, + length () { + return q._tasks.length; + }, + running () { + return numRunning; + }, + workersList () { + return workersList; + }, + idle() { + return q._tasks.length + numRunning === 0; + }, + pause () { + q.paused = true; + }, + resume () { + if (q.paused === false) { return; } + q.paused = false; + setImmediate$1(q.process); + } + }; + // define these as fixed properties, so people get useful errors when updating + Object.defineProperties(q, { + saturated: { + writable: false, + value: eventMethod('saturated') + }, + unsaturated: { + writable: false, + value: eventMethod('unsaturated') + }, + empty: { + writable: false, + value: eventMethod('empty') + }, + drain: { + writable: false, + value: eventMethod('drain') + }, + error: { + writable: false, + value: eventMethod('error') + }, + }); + return q; + } + + /** + * Creates a `cargo` object with the specified payload. Tasks added to the + * cargo will be processed altogether (up to the `payload` limit). If the + * `worker` is in progress, the task is queued until it becomes available. Once + * the `worker` has completed some tasks, each callback of those tasks is + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) + * for how `cargo` and `queue` work. + * + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers + * at a time, cargo passes an array of tasks to a single worker, repeating + * when the worker is finished. + * + * @name cargo + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. + * @param {number} [payload=Infinity] - An optional `integer` for determining + * how many tasks should be processed per round; if omitted, the default is + * unlimited. + * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the cargo and inner queue. + * @example + * + * // create a cargo object with payload 2 + * var cargo = async.cargo(function(tasks, callback) { + * for (var i=0; i { + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.reduce(withMissingFileList, 0, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.reduce(fileList, 0, getFileSizeInBytes); + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function reduce(coll, memo, iteratee, callback) { + callback = once(callback); + var _iteratee = wrapAsync(iteratee); + return eachOfSeries$1(coll, (x, i, iterCb) => { + _iteratee(memo, x, (err, v) => { + memo = v; + iterCb(err); + }); + }, err => callback(err, memo)); + } + var reduce$1 = awaitify(reduce, 4); + + /** + * Version of the compose function that is more natural to read. Each function + * consumes the return value of the previous function. It is the equivalent of + * [compose]{@link module:ControlFlow.compose} with the arguments reversed. + * + * Each function is executed with the `this` binding of the composed function. + * + * @name seq + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.compose]{@link module:ControlFlow.compose} + * @category Control Flow + * @param {...AsyncFunction} functions - the asynchronous functions to compose + * @returns {Function} a function that composes the `functions` in order + * @example + * + * // Requires lodash (or underscore), express3 and dresende's orm2. + * // Part of an app, that fetches cats of the logged user. + * // This example uses `seq` function to avoid overnesting and error + * // handling clutter. + * app.get('/cats', function(request, response) { + * var User = request.models.User; + * async.seq( + * User.get.bind(User), // 'User.get' has signature (id, callback(err, data)) + * function(user, fn) { + * user.getCats(fn); // 'getCats' has signature (callback(err, data)) + * } + * )(req.session.user_id, function (err, cats) { + * if (err) { + * console.error(err); + * response.json({ status: 'error', message: err.message }); + * } else { + * response.json({ status: 'ok', message: 'Cats found', data: cats }); + * } + * }); + * }); + */ + function seq(...functions) { + var _functions = functions.map(wrapAsync); + return function (...args) { + var that = this; + + var cb = args[args.length - 1]; + if (typeof cb == 'function') { + args.pop(); + } else { + cb = promiseCallback(); + } + + reduce$1(_functions, args, (newargs, fn, iterCb) => { + fn.apply(that, newargs.concat((err, ...nextargs) => { + iterCb(err, nextargs); + })); + }, + (err, results) => cb(err, ...results)); + + return cb[PROMISE_SYMBOL] + }; + } + + /** + * Creates a function which is a composition of the passed asynchronous + * functions. Each function consumes the return value of the function that + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result + * of `f(g(h()))`, only this version uses callbacks to obtain the return values. + * + * If the last argument to the composed function is not a function, a promise + * is returned when you call it. + * + * Each function is executed with the `this` binding of the composed function. + * + * @name compose + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {...AsyncFunction} functions - the asynchronous functions to compose + * @returns {Function} an asynchronous function that is the composed + * asynchronous `functions` + * @example + * + * function add1(n, callback) { + * setTimeout(function () { + * callback(null, n + 1); + * }, 10); + * } + * + * function mul3(n, callback) { + * setTimeout(function () { + * callback(null, n * 3); + * }, 10); + * } + * + * var add1mul3 = async.compose(mul3, add1); + * add1mul3(4, function (err, result) { + * // result now equals 15 + * }); + */ + function compose(...args) { + return seq(...args.reverse()); + } + + /** + * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. + * + * @name mapLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function mapLimit (coll, limit, iteratee, callback) { + return _asyncMap(eachOfLimit$2(limit), coll, iteratee, callback) + } + var mapLimit$1 = awaitify(mapLimit, 4); + + /** + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time. + * + * @name concatLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.concat]{@link module:Collections.concat} + * @category Collection + * @alias flatMapLimit + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`, + * which should use an array as its result. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + */ + function concatLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(coll, limit, (val, iterCb) => { + _iteratee(val, (err, ...args) => { + if (err) return iterCb(err); + return iterCb(err, args); + }); + }, (err, mapResults) => { + var result = []; + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + result = result.concat(...mapResults[i]); + } + } + + return callback(err, result); + }); + } + var concatLimit$1 = awaitify(concatLimit, 4); + + /** + * Applies `iteratee` to each item in `coll`, concatenating the results. Returns + * the concatenated list. The `iteratee`s are called in parallel, and the + * results are concatenated as they return. The results array will be returned in + * the original order of `coll` passed to the `iteratee` function. + * + * @name concat + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @alias flatMap + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`, + * which should use an array as its result. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * let directoryList = ['dir1','dir2','dir3']; + * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4']; + * + * // Using callbacks + * async.concat(directoryList, fs.readdir, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * } + * }); + * + * // Error Handling + * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * } else { + * console.log(results); + * } + * }); + * + * // Using Promises + * async.concat(directoryList, fs.readdir) + * .then(results => { + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * }).catch(err => { + * console.log(err); + * }); + * + * // Error Handling + * async.concat(withMissingDirectoryList, fs.readdir) + * .then(results => { + * console.log(results); + * }).catch(err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.concat(directoryList, fs.readdir); + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * } catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.concat(withMissingDirectoryList, fs.readdir); + * console.log(results); + * } catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * } + * } + * + */ + function concat(coll, iteratee, callback) { + return concatLimit$1(coll, Infinity, iteratee, callback) + } + var concat$1 = awaitify(concat, 3); + + /** + * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time. + * + * @name concatSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.concat]{@link module:Collections.concat} + * @category Collection + * @alias flatMapSeries + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`. + * The iteratee should complete with an array an array of results. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + */ + function concatSeries(coll, iteratee, callback) { + return concatLimit$1(coll, 1, iteratee, callback) + } + var concatSeries$1 = awaitify(concatSeries, 3); + + /** + * Returns a function that when called, calls-back with the values provided. + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to + * [`auto`]{@link module:ControlFlow.auto}. + * + * @name constant + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {...*} arguments... - Any number of arguments to automatically invoke + * callback with. + * @returns {AsyncFunction} Returns a function that when invoked, automatically + * invokes the callback with the previous given arguments. + * @example + * + * async.waterfall([ + * async.constant(42), + * function (value, next) { + * // value === 42 + * }, + * //... + * ], callback); + * + * async.waterfall([ + * async.constant(filename, "utf8"), + * fs.readFile, + * function (fileData, next) { + * //... + * } + * //... + * ], callback); + * + * async.auto({ + * hostname: async.constant("https://server.net/"), + * port: findFreePort, + * launchServer: ["hostname", "port", function (options, cb) { + * startServer(options, cb); + * }], + * //... + * }, callback); + */ + function constant$1(...args) { + return function (...ignoredArgs/*, callback*/) { + var callback = ignoredArgs.pop(); + return callback(null, ...args); + }; + } + + function _createTester(check, getResult) { + return (eachfn, arr, _iteratee, cb) => { + var testPassed = false; + var testResult; + const iteratee = wrapAsync(_iteratee); + eachfn(arr, (value, _, callback) => { + iteratee(value, (err, result) => { + if (err || err === false) return callback(err); + + if (check(result) && !testResult) { + testPassed = true; + testResult = getResult(true, value); + return callback(null, breakLoop); + } + callback(); + }); + }, err => { + if (err) return cb(err); + cb(null, testPassed ? testResult : getResult(false)); + }); + }; + } + + /** + * Returns the first value in `coll` that passes an async truth test. The + * `iteratee` is applied in parallel, meaning the first iteratee to return + * `true` will fire the detect `callback` with that result. That means the + * result might not be the first item in the original `coll` (in terms of order) + * that passes the test. + + * If order within the original `coll` is important, then look at + * [`detectSeries`]{@link module:Collections.detectSeries}. + * + * @name detect + * @static + * @memberOf module:Collections + * @method + * @alias find + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // dir1/file1.txt + * // result now equals the first file in the list that exists + * } + *); + * + * // Using Promises + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists) + * .then(result => { + * console.log(result); + * // dir1/file1.txt + * // result now equals the first file in the list that exists + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists); + * console.log(result); + * // dir1/file1.txt + * // result now equals the file in the list that exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function detect(coll, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOf$1, coll, iteratee, callback) + } + var detect$1 = awaitify(detect, 3); + + /** + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a + * time. + * + * @name detectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findLimit + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + */ + function detectLimit(coll, limit, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var detectLimit$1 = awaitify(detectLimit, 4); + + /** + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. + * + * @name detectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findSeries + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + */ + function detectSeries(coll, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOfLimit$2(1), coll, iteratee, callback) + } + + var detectSeries$1 = awaitify(detectSeries, 3); + + function consoleFunc(name) { + return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => { + /* istanbul ignore else */ + if (typeof console === 'object') { + /* istanbul ignore else */ + if (err) { + /* istanbul ignore else */ + if (console.error) { + console.error(err); + } + } else if (console[name]) { /* istanbul ignore else */ + resultArgs.forEach(x => console[name](x)); + } + } + }) + } + + /** + * Logs the result of an [`async` function]{@link AsyncFunction} to the + * `console` using `console.dir` to display the properties of the resulting object. + * Only works in Node.js or in browsers that support `console.dir` and + * `console.error` (such as FF and Chrome). + * If multiple arguments are returned from the async function, + * `console.dir` is called on each argument in order. + * + * @name dir + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, {hello: name}); + * }, 1000); + * }; + * + * // in the node repl + * node> async.dir(hello, 'world'); + * {hello: 'world'} + */ + var dir = consoleFunc('dir'); + + /** + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in + * the order of operations, the arguments `test` and `iteratee` are switched. + * + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + * + * @name doWhilst + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - A function which is called each time `test` + * passes. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. + * `callback` will be passed an error and any arguments passed to the final + * `iteratee`'s callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + */ + function doWhilst(iteratee, test, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results; + + function next(err, ...args) { + if (err) return callback(err); + if (err === false) return; + results = args; + _test(...args, check); + } + + function check(err, truth) { + if (err) return callback(err); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return check(null, true); + } + + var doWhilst$1 = awaitify(doWhilst, 3); + + /** + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the + * argument ordering differs from `until`. + * + * @name doUntil + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee` + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + */ + function doUntil(iteratee, test, callback) { + const _test = wrapAsync(test); + return doWhilst$1(iteratee, (...args) => { + const cb = args.pop(); + _test(...args, (err, truth) => cb (err, !truth)); + }, callback); + } + + function _withoutIndex(iteratee) { + return (value, index, callback) => iteratee(value, callback); + } + + /** + * Applies the function `iteratee` to each item in `coll`, in parallel. + * The `iteratee` is called with an item from the list, and a callback for when + * it has finished. If the `iteratee` passes an error to its `callback`, the + * main `callback` (for the `each` function) is immediately called with the + * error. + * + * Note, that since this function applies `iteratee` to each item in parallel, + * there is no guarantee that the iteratee functions will complete in order. + * + * @name each + * @static + * @memberOf module:Collections + * @method + * @alias forEach + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to + * each item in `coll`. Invoked with (item, callback). + * The array index is not passed to the iteratee. + * If you need the index, use `eachOf`. + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt']; + * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt']; + * + * // asynchronous function that deletes a file + * const deleteFile = function(file, callback) { + * fs.unlink(file, callback); + * }; + * + * // Using callbacks + * async.each(fileList, deleteFile, function(err) { + * if( err ) { + * console.log(err); + * } else { + * console.log('All files have been deleted successfully'); + * } + * }); + * + * // Error Handling + * async.each(withMissingFileList, deleteFile, function(err){ + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using Promises + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using async/await + * async () => { + * try { + * await async.each(files, deleteFile); + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * await async.each(withMissingFileList, deleteFile); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * } + * } + * + */ + function eachLimit$2(coll, iteratee, callback) { + return eachOf$1(coll, _withoutIndex(wrapAsync(iteratee)), callback); + } + + var each = awaitify(eachLimit$2, 3); + + /** + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. + * + * @name eachLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfLimit`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachLimit(coll, limit, iteratee, callback) { + return eachOfLimit$2(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback); + } + var eachLimit$1 = awaitify(eachLimit, 4); + + /** + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. + * + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item + * in series and therefore the iteratee functions will complete in order. + + * @name eachSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfSeries`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachSeries(coll, iteratee, callback) { + return eachLimit$1(coll, 1, iteratee, callback) + } + var eachSeries$1 = awaitify(eachSeries, 3); + + /** + * Wrap an async function and ensure it calls its callback on a later tick of + * the event loop. If the function already calls its callback on a next tick, + * no extra deferral is added. This is useful for preventing stack overflows + * (`RangeError: Maximum call stack size exceeded`) and generally keeping + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) + * contained. ES2017 `async` functions are returned as-is -- they are immune + * to Zalgo's corrupting influences, as they always resolve on a later tick. + * + * @name ensureAsync + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - an async function, one that expects a node-style + * callback as its last argument. + * @returns {AsyncFunction} Returns a wrapped function with the exact same call + * signature as the function passed in. + * @example + * + * function sometimesAsync(arg, callback) { + * if (cache[arg]) { + * return callback(null, cache[arg]); // this would be synchronous!! + * } else { + * doSomeIO(arg, callback); // this IO would be asynchronous + * } + * } + * + * // this has a risk of stack overflows if many results are cached in a row + * async.mapSeries(args, sometimesAsync, done); + * + * // this will defer sometimesAsync's callback if necessary, + * // preventing stack overflows + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); + */ + function ensureAsync(fn) { + if (isAsync(fn)) return fn; + return function (...args/*, callback*/) { + var callback = args.pop(); + var sync = true; + args.push((...innerArgs) => { + if (sync) { + setImmediate$1(() => callback(...innerArgs)); + } else { + callback(...innerArgs); + } + }); + fn.apply(this, args); + sync = false; + }; + } + + /** + * Returns `true` if every element in `coll` satisfies an async test. If any + * iteratee call returns `false`, the main `callback` is immediately called. + * + * @name every + * @static + * @memberOf module:Collections + * @method + * @alias all + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.every(fileList, fileExists, function(err, result) { + * console.log(result); + * // true + * // result is true since every file exists + * }); + * + * async.every(withMissingFileList, fileExists, function(err, result) { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }); + * + * // Using Promises + * async.every(fileList, fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since every file exists + * }).catch( err => { + * console.log(err); + * }); + * + * async.every(withMissingFileList, fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.every(fileList, fileExists); + * console.log(result); + * // true + * // result is true since every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.every(withMissingFileList, fileExists); + * console.log(result); + * // false + * // result is false since NOT every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function every(coll, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOf$1, coll, iteratee, callback) + } + var every$1 = awaitify(every, 3); + + /** + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. + * + * @name everyLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function everyLimit(coll, limit, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var everyLimit$1 = awaitify(everyLimit, 4); + + /** + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. + * + * @name everySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in series. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function everySeries(coll, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOfSeries$1, coll, iteratee, callback) + } + var everySeries$1 = awaitify(everySeries, 3); + + function filterArray(eachfn, arr, iteratee, callback) { + var truthValues = new Array(arr.length); + eachfn(arr, (x, index, iterCb) => { + iteratee(x, (err, v) => { + truthValues[index] = !!v; + iterCb(err); + }); + }, err => { + if (err) return callback(err); + var results = []; + for (var i = 0; i < arr.length; i++) { + if (truthValues[i]) results.push(arr[i]); + } + callback(null, results); + }); + } + + function filterGeneric(eachfn, coll, iteratee, callback) { + var results = []; + eachfn(coll, (x, index, iterCb) => { + iteratee(x, (err, v) => { + if (err) return iterCb(err); + if (v) { + results.push({index, value: x}); + } + iterCb(err); + }); + }, err => { + if (err) return callback(err); + callback(null, results + .sort((a, b) => a.index - b.index) + .map(v => v.value)); + }); + } + + function _filter(eachfn, coll, iteratee, callback) { + var filter = isArrayLike(coll) ? filterArray : filterGeneric; + return filter(eachfn, coll, wrapAsync(iteratee), callback); + } + + /** + * Returns a new array of all the values in `coll` which pass an async truth + * test. This operation is performed in parallel, but the results array will be + * in the same order as the original. + * + * @name filter + * @static + * @memberOf module:Collections + * @method + * @alias select + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.filter(files, fileExists, function(err, results) { + * if(err) { + * console.log(err); + * } else { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } + * }); + * + * // Using Promises + * async.filter(files, fileExists) + * .then(results => { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.filter(files, fileExists); + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function filter (coll, iteratee, callback) { + return _filter(eachOf$1, coll, iteratee, callback) + } + var filter$1 = awaitify(filter, 3); + + /** + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a + * time. + * + * @name filterLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided + */ + function filterLimit (coll, limit, iteratee, callback) { + return _filter(eachOfLimit$2(limit), coll, iteratee, callback) + } + var filterLimit$1 = awaitify(filterLimit, 4); + + /** + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. + * + * @name filterSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results) + * @returns {Promise} a promise, if no callback provided + */ + function filterSeries (coll, iteratee, callback) { + return _filter(eachOfSeries$1, coll, iteratee, callback) + } + var filterSeries$1 = awaitify(filterSeries, 3); + + /** + * Calls the asynchronous function `fn` with a callback parameter that allows it + * to call itself again, in series, indefinitely. + + * If an error is passed to the callback then `errback` is called with the + * error, and execution stops, otherwise it will never be called. + * + * @name forever + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} fn - an async function to call repeatedly. + * Invoked with (next). + * @param {Function} [errback] - when `fn` passes an error to it's callback, + * this function will be called, and execution stops. Invoked with (err). + * @returns {Promise} a promise that rejects if an error occurs and an errback + * is not passed + * @example + * + * async.forever( + * function(next) { + * // next is suitable for passing to things that need a callback(err [, whatever]); + * // it will result in this function being called again. + * }, + * function(err) { + * // if next is called with a value in its first parameter, it will appear + * // in here as 'err', and execution will stop. + * } + * ); + */ + function forever(fn, errback) { + var done = onlyOnce(errback); + var task = wrapAsync(ensureAsync(fn)); + + function next(err) { + if (err) return done(err); + if (err === false) return; + task(next); + } + return next(); + } + var forever$1 = awaitify(forever, 2); + + /** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. + * + * @name groupByLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ + function groupByLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(coll, limit, (val, iterCb) => { + _iteratee(val, (err, key) => { + if (err) return iterCb(err); + return iterCb(err, {key, val}); + }); + }, (err, mapResults) => { + var result = {}; + // from MDN, handle object having an `hasOwnProperty` prop + var {hasOwnProperty} = Object.prototype; + + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + var {key} = mapResults[i]; + var {val} = mapResults[i]; + + if (hasOwnProperty.call(result, key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } + } + + return callback(err, result); + }); + } + + var groupByLimit$1 = awaitify(groupByLimit, 4); + + /** + * Returns a new object, where each value corresponds to an array of items, from + * `coll`, that returned the corresponding key. That is, the keys of the object + * correspond to the values passed to the `iteratee` callback. + * + * Note: Since this function applies the `iteratee` to each item in parallel, + * there is no guarantee that the `iteratee` functions will complete in order. + * However, the values for each key in the `result` will be in the same order as + * the original `coll`. For Objects, the values will roughly be in the order of + * the original Objects' keys (but this can vary across JavaScript engines). + * + * @name groupBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const files = ['dir1/file1.txt','dir2','dir4'] + * + * // asynchronous function that detects file type as none, file, or directory + * function detectFile(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(null, 'none'); + * } + * callback(null, stat.isDirectory() ? 'directory' : 'file'); + * }); + * } + * + * //Using callbacks + * async.groupBy(files, detectFile, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * }); + * + * // Using Promises + * async.groupBy(files, detectFile) + * .then( result => { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.groupBy(files, detectFile); + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function groupBy (coll, iteratee, callback) { + return groupByLimit$1(coll, Infinity, iteratee, callback) + } + + /** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. + * + * @name groupBySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ + function groupBySeries (coll, iteratee, callback) { + return groupByLimit$1(coll, 1, iteratee, callback) + } + + /** + * Logs the result of an `async` function to the `console`. Only works in + * Node.js or in browsers that support `console.log` and `console.error` (such + * as FF and Chrome). If multiple arguments are returned from the async + * function, `console.log` is called on each argument in order. + * + * @name log + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, 'hello ' + name); + * }, 1000); + * }; + * + * // in the node repl + * node> async.log(hello, 'world'); + * 'hello world' + */ + var log = consoleFunc('log'); + + /** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a + * time. + * + * @name mapValuesLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function mapValuesLimit(obj, limit, iteratee, callback) { + callback = once(callback); + var newObj = {}; + var _iteratee = wrapAsync(iteratee); + return eachOfLimit$2(limit)(obj, (val, key, next) => { + _iteratee(val, key, (err, result) => { + if (err) return next(err); + newObj[key] = result; + next(err); + }); + }, err => callback(err, newObj)); + } + + var mapValuesLimit$1 = awaitify(mapValuesLimit, 4); + + /** + * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. + * + * Produces a new Object by mapping each value of `obj` through the `iteratee` + * function. The `iteratee` is called each `value` and `key` from `obj` and a + * callback for when it has finished processing. Each of these callbacks takes + * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` + * passes an error to its callback, the main `callback` (for the `mapValues` + * function) is immediately called with the error. + * + * Note, the order of the keys in the result is not guaranteed. The keys will + * be roughly in the order they complete, (but this is very engine-specific) + * + * @name mapValues + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file3.txt' + * }; + * + * const withMissingFileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file4.txt' + * }; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, key, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * } else { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * }); + * + * // Error handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(result); + * } + * }); + * + * // Using Promises + * async.mapValues(fileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * }).catch (err => { + * console.log(err); + * }); + * + * // Error Handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch (err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.mapValues(fileMap, getFileSizeInBytes); + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function mapValues(obj, iteratee, callback) { + return mapValuesLimit$1(obj, Infinity, iteratee, callback) + } + + /** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. + * + * @name mapValuesSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function mapValuesSeries(obj, iteratee, callback) { + return mapValuesLimit$1(obj, 1, iteratee, callback) + } + + /** + * Caches the results of an async function. When creating a hash to store + * function results against, the callback is omitted from the hash and an + * optional hash function can be used. + * + * **Note: if the async function errs, the result will not be cached and + * subsequent calls will call the wrapped function.** + * + * If no hash function is specified, the first argument is used as a hash key, + * which may work reasonably if it is a string or a data type that converts to a + * distinct string. Note that objects and arrays will not behave reasonably. + * Neither will cases where the other arguments are significant. In such cases, + * specify your own hash function. + * + * The cache of results is exposed as the `memo` property of the function + * returned by `memoize`. + * + * @name memoize + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function to proxy and cache results from. + * @param {Function} hasher - An optional function for generating a custom hash + * for storing results. It has all the arguments applied to it apart from the + * callback, and must be synchronous. + * @returns {AsyncFunction} a memoized version of `fn` + * @example + * + * var slow_fn = function(name, callback) { + * // do something + * callback(null, result); + * }; + * var fn = async.memoize(slow_fn); + * + * // fn can now be used as if it were slow_fn + * fn('some name', function() { + * // callback + * }); + */ + function memoize(fn, hasher = v => v) { + var memo = Object.create(null); + var queues = Object.create(null); + var _fn = wrapAsync(fn); + var memoized = initialParams((args, callback) => { + var key = hasher(...args); + if (key in memo) { + setImmediate$1(() => callback(null, ...memo[key])); + } else if (key in queues) { + queues[key].push(callback); + } else { + queues[key] = [callback]; + _fn(...args, (err, ...resultArgs) => { + // #1465 don't memoize if an error occurred + if (!err) { + memo[key] = resultArgs; + } + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i](err, ...resultArgs); + } + }); + } + }); + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + } + + /* istanbul ignore file */ + + /** + * Calls `callback` on a later loop around the event loop. In Node.js this just + * calls `process.nextTick`. In the browser it will use `setImmediate` if + * available, otherwise `setTimeout(callback, 0)`, which means other higher + * priority events may precede the execution of `callback`. + * + * This is used internally for browser-compatibility purposes. + * + * @name nextTick + * @static + * @memberOf module:Utils + * @method + * @see [async.setImmediate]{@link module:Utils.setImmediate} + * @category Util + * @param {Function} callback - The function to call on a later loop around + * the event loop. Invoked with (args...). + * @param {...*} args... - any number of additional arguments to pass to the + * callback on the next tick. + * @example + * + * var call_order = []; + * async.nextTick(function() { + * call_order.push('two'); + * // call_order now equals ['one','two'] + * }); + * call_order.push('one'); + * + * async.setImmediate(function (a, b, c) { + * // a, b, and c equal 1, 2, and 3 + * }, 1, 2, 3); + */ + var _defer; + + if (hasNextTick) { + _defer = process.nextTick; + } else if (hasSetImmediate) { + _defer = setImmediate; + } else { + _defer = fallback; + } + + var nextTick = wrap(_defer); + + var _parallel = awaitify((eachfn, tasks, callback) => { + var results = isArrayLike(tasks) ? [] : {}; + + eachfn(tasks, (task, key, taskCb) => { + wrapAsync(task)((err, ...result) => { + if (result.length < 2) { + [result] = result; + } + results[key] = result; + taskCb(err); + }); + }, err => callback(err, results)); + }, 3); + + /** + * Run the `tasks` collection of functions in parallel, without waiting until + * the previous function has completed. If any of the functions pass an error to + * its callback, the main `callback` is immediately called with the value of the + * error. Once the `tasks` have completed, the results are passed to the final + * `callback` as an array. + * + * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about + * parallel execution of code. If your tasks do not use any timers or perform + * any I/O, they will actually be executed in series. Any synchronous setup + * sections for each task will happen one after the other. JavaScript remains + * single-threaded. + * + * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the + * execution of other tasks when a task fails. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.parallel}. + * + * @name parallel + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + * + * @example + * + * //Using Callbacks + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * }).catch(err => { + * console.log(err); + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function parallel(tasks, callback) { + return _parallel(eachOf$1, tasks, callback); + } + + /** + * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a + * time. + * + * @name parallelLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.parallel]{@link module:ControlFlow.parallel} + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + */ + function parallelLimit(tasks, limit, callback) { + return _parallel(eachOfLimit$2(limit), tasks, callback); + } + + /** + * A queue of tasks for the worker function to complete. + * @typedef {Iterable} QueueObject + * @memberOf module:ControlFlow + * @property {Function} length - a function returning the number of items + * waiting to be processed. Invoke with `queue.length()`. + * @property {boolean} started - a boolean indicating whether or not any + * items have been pushed and processed by the queue. + * @property {Function} running - a function returning the number of items + * currently being processed. Invoke with `queue.running()`. + * @property {Function} workersList - a function returning the array of items + * currently being processed. Invoke with `queue.workersList()`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke with `queue.idle()`. + * @property {number} concurrency - an integer for determining how many `worker` + * functions should be run in parallel. This property can be changed after a + * `queue` is created to alter the concurrency on-the-fly. + * @property {number} payload - an integer that specifies how many items are + * passed to the worker function at a time. only applies if this is a + * [cargo]{@link module:ControlFlow.cargo} object + * @property {AsyncFunction} push - add a new task to the `queue`. Calls `callback` + * once the `worker` has finished processing the task. Instead of a single task, + * a `tasks` array can be submitted. The respective callback is used for every + * task in the list. Invoke with `queue.push(task, [callback])`, + * @property {AsyncFunction} unshift - add a new task to the front of the `queue`. + * Invoke with `queue.unshift(task, [callback])`. + * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns + * a promise that rejects if an error occurs. + * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns + * a promise that rejects if an error occurs. + * @property {Function} remove - remove items from the queue that match a test + * function. The test function will be passed an object with a `data` property, + * and a `priority` property, if this is a + * [priorityQueue]{@link module:ControlFlow.priorityQueue} object. + * Invoked with `queue.remove(testFn)`, where `testFn` is of the form + * `function ({data, priority}) {}` and returns a Boolean. + * @property {Function} saturated - a function that sets a callback that is + * called when the number of running workers hits the `concurrency` limit, and + * further tasks will be queued. If the callback is omitted, `q.saturated()` + * returns a promise for the next occurrence. + * @property {Function} unsaturated - a function that sets a callback that is + * called when the number of running workers is less than the `concurrency` & + * `buffer` limits, and further tasks will not be queued. If the callback is + * omitted, `q.unsaturated()` returns a promise for the next occurrence. + * @property {number} buffer - A minimum threshold buffer in order to say that + * the `queue` is `unsaturated`. + * @property {Function} empty - a function that sets a callback that is called + * when the last item from the `queue` is given to a `worker`. If the callback + * is omitted, `q.empty()` returns a promise for the next occurrence. + * @property {Function} drain - a function that sets a callback that is called + * when the last item from the `queue` has returned from the `worker`. If the + * callback is omitted, `q.drain()` returns a promise for the next occurrence. + * @property {Function} error - a function that sets a callback that is called + * when a task errors. Has the signature `function(error, task)`. If the + * callback is omitted, `error()` returns a promise that rejects on the next + * error. + * @property {boolean} paused - a boolean for determining whether the queue is + * in a paused state. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke with `queue.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke with `queue.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. No more tasks + * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. + * + * @example + * const q = async.queue(worker, 2) + * q.push(item1) + * q.push(item2) + * q.push(item3) + * // queues are iterable, spread into an array to inspect + * const items = [...q] // [item1, item2, item3] + * // or use for of + * for (let item of q) { + * console.log(item) + * } + * + * q.drain(() => { + * console.log('all done') + * }) + * // or + * await q.drain() + */ + + /** + * Creates a `queue` object with the specified `concurrency`. Tasks added to the + * `queue` are processed in parallel (up to the `concurrency` limit). If all + * `worker`s are in progress, the task is queued until one becomes available. + * Once a `worker` completes a `task`, that `task`'s callback is called. + * + * @name queue + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. Invoked with (task, callback). + * @param {number} [concurrency=1] - An `integer` for determining how many + * `worker` functions should be run in parallel. If omitted, the concurrency + * defaults to `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can be + * attached as certain properties to listen for specific events during the + * lifecycle of the queue. + * @example + * + * // create a queue object with concurrency 2 + * var q = async.queue(function(task, callback) { + * console.log('hello ' + task.name); + * callback(); + * }, 2); + * + * // assign a callback + * q.drain(function() { + * console.log('all items have been processed'); + * }); + * // or await the end + * await q.drain() + * + * // assign an error callback + * q.error(function(err, task) { + * console.error('task experienced an error'); + * }); + * + * // add some items to the queue + * q.push({name: 'foo'}, function(err) { + * console.log('finished processing foo'); + * }); + * // callback is optional + * q.push({name: 'bar'}); + * + * // add some items to the queue (batch-wise) + * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { + * console.log('finished processing item'); + * }); + * + * // add some items to the front of the queue + * q.unshift({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + */ + function queue (worker, concurrency) { + var _worker = wrapAsync(worker); + return queue$1((items, cb) => { + _worker(items[0], cb); + }, concurrency, 1); + } + + // Binary min-heap implementation used for priority queue. + // Implementation is stable, i.e. push time is considered for equal priorities + class Heap { + constructor() { + this.heap = []; + this.pushCount = Number.MIN_SAFE_INTEGER; + } + + get length() { + return this.heap.length; + } + + empty () { + this.heap = []; + return this; + } + + percUp(index) { + let p; + + while (index > 0 && smaller(this.heap[index], this.heap[p=parent(index)])) { + let t = this.heap[index]; + this.heap[index] = this.heap[p]; + this.heap[p] = t; + + index = p; + } + } + + percDown(index) { + let l; + + while ((l=leftChi(index)) < this.heap.length) { + if (l+1 < this.heap.length && smaller(this.heap[l+1], this.heap[l])) { + l = l+1; + } + + if (smaller(this.heap[index], this.heap[l])) { + break; + } + + let t = this.heap[index]; + this.heap[index] = this.heap[l]; + this.heap[l] = t; + + index = l; + } + } + + push(node) { + node.pushCount = ++this.pushCount; + this.heap.push(node); + this.percUp(this.heap.length-1); + } + + unshift(node) { + return this.heap.push(node); + } + + shift() { + let [top] = this.heap; + + this.heap[0] = this.heap[this.heap.length-1]; + this.heap.pop(); + this.percDown(0); + + return top; + } + + toArray() { + return [...this]; + } + + *[Symbol.iterator] () { + for (let i = 0; i < this.heap.length; i++) { + yield this.heap[i].data; + } + } + + remove (testFn) { + let j = 0; + for (let i = 0; i < this.heap.length; i++) { + if (!testFn(this.heap[i])) { + this.heap[j] = this.heap[i]; + j++; + } + } + + this.heap.splice(j); + + for (let i = parent(this.heap.length-1); i >= 0; i--) { + this.percDown(i); + } + + return this; + } + } + + function leftChi(i) { + return (i<<1)+1; + } + + function parent(i) { + return ((i+1)>>1)-1; + } + + function smaller(x, y) { + if (x.priority !== y.priority) { + return x.priority < y.priority; + } + else { + return x.pushCount < y.pushCount; + } + } + + /** + * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and + * completed in ascending priority order. + * + * @name priorityQueue + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. + * Invoked with (task, callback). + * @param {number} concurrency - An `integer` for determining how many `worker` + * functions should be run in parallel. If omitted, the concurrency defaults to + * `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are three + * differences between `queue` and `priorityQueue` objects: + * * `push(task, priority, [callback])` - `priority` should be a number. If an + * array of `tasks` is given, all tasks will be assigned the same priority. + * * `pushAsync(task, priority, [callback])` - the same as `priorityQueue.push`, + * except this returns a promise that rejects if an error occurs. + * * The `unshift` and `unshiftAsync` methods were removed. + */ + function priorityQueue(worker, concurrency) { + // Start with a normal queue + var q = queue(worker, concurrency); + + var { + push, + pushAsync + } = q; + + q._tasks = new Heap(); + q._createTaskItem = ({data, priority}, callback) => { + return { + data, + priority, + callback + }; + }; + + function createDataItems(tasks, priority) { + if (!Array.isArray(tasks)) { + return {data: tasks, priority}; + } + return tasks.map(data => { return {data, priority}; }); + } + + // Override push to accept second parameter representing priority + q.push = function(data, priority = 0, callback) { + return push(createDataItems(data, priority), callback); + }; + + q.pushAsync = function(data, priority = 0, callback) { + return pushAsync(createDataItems(data, priority), callback); + }; + + // Remove unshift functions + delete q.unshift; + delete q.unshiftAsync; + + return q; + } + + /** + * Runs the `tasks` array of functions in parallel, without waiting until the + * previous function has completed. Once any of the `tasks` complete or pass an + * error to its callback, the main `callback` is immediately called. It's + * equivalent to `Promise.race()`. + * + * @name race + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction} + * to run. Each function can complete with an optional `result` value. + * @param {Function} callback - A callback to run once any of the functions have + * completed. This function gets an error or result from the first function that + * completed. Invoked with (err, result). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * async.race([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // main callback + * function(err, result) { + * // the result will be equal to 'two' as it finishes earlier + * }); + */ + function race(tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); + if (!tasks.length) return callback(); + for (var i = 0, l = tasks.length; i < l; i++) { + wrapAsync(tasks[i])(callback); + } + } + + var race$1 = awaitify(race, 2); + + /** + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. + * + * @name reduceRight + * @static + * @memberOf module:Collections + * @method + * @see [async.reduce]{@link module:Collections.reduce} + * @alias foldr + * @category Collection + * @param {Array} array - A collection to iterate over. + * @param {*} memo - The initial state of the reduction. + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee completes with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the reduced value. Invoked with + * (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function reduceRight (array, memo, iteratee, callback) { + var reversed = [...array].reverse(); + return reduce$1(reversed, memo, iteratee, callback); + } + + /** + * Wraps the async function in another function that always completes with a + * result object, even when it errors. + * + * The result object has either the property `error` or `value`. + * + * @name reflect + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function you want to wrap + * @returns {Function} - A function that always passes null to it's callback as + * the error. The second argument to the callback will be an `object` with + * either an `error` or a `value` property. + * @example + * + * async.parallel([ + * async.reflect(function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }), + * async.reflect(function(callback) { + * // do some more stuff but error ... + * callback('bad stuff happened'); + * }), + * async.reflect(function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * }) + * ], + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = 'bad stuff happened' + * // results[2].value = 'two' + * }); + */ + function reflect(fn) { + var _fn = wrapAsync(fn); + return initialParams(function reflectOn(args, reflectCallback) { + args.push((error, ...cbArgs) => { + let retVal = {}; + if (error) { + retVal.error = error; + } + if (cbArgs.length > 0){ + var value = cbArgs; + if (cbArgs.length <= 1) { + [value] = cbArgs; + } + retVal.value = value; + } + reflectCallback(null, retVal); + }); + + return _fn.apply(this, args); + }); + } + + /** + * A helper function that wraps an array or an object of functions with `reflect`. + * + * @name reflectAll + * @static + * @memberOf module:Utils + * @method + * @see [async.reflect]{@link module:Utils.reflect} + * @category Util + * @param {Array|Object|Iterable} tasks - The collection of + * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. + * @returns {Array} Returns an array of async functions, each wrapped in + * `async.reflect` + * @example + * + * let tasks = [ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * // do some more stuff but error ... + * callback(new Error('bad stuff happened')); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = Error('bad stuff happened') + * // results[2].value = 'two' + * }); + * + * // an example using an object instead of an array + * let tasks = { + * one: function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * two: function(callback) { + * callback('two'); + * }, + * three: function(callback) { + * setTimeout(function() { + * callback(null, 'three'); + * }, 100); + * } + * }; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results.one.value = 'one' + * // results.two.error = 'two' + * // results.three.value = 'three' + * }); + */ + function reflectAll(tasks) { + var results; + if (Array.isArray(tasks)) { + results = tasks.map(reflect); + } else { + results = {}; + Object.keys(tasks).forEach(key => { + results[key] = reflect.call(this, tasks[key]); + }); + } + return results; + } + + function reject$2(eachfn, arr, _iteratee, callback) { + const iteratee = wrapAsync(_iteratee); + return _filter(eachfn, arr, (value, cb) => { + iteratee(value, (err, v) => { + cb(err, !v); + }); + }, callback); + } + + /** + * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. + * + * @name reject + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.reject(fileList, fileExists, function(err, results) { + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * }); + * + * // Using Promises + * async.reject(fileList, fileExists) + * .then( results => { + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.reject(fileList, fileExists); + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function reject (coll, iteratee, callback) { + return reject$2(eachOf$1, coll, iteratee, callback) + } + var reject$1 = awaitify(reject, 3); + + /** + * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a + * time. + * + * @name rejectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function rejectLimit (coll, limit, iteratee, callback) { + return reject$2(eachOfLimit$2(limit), coll, iteratee, callback) + } + var rejectLimit$1 = awaitify(rejectLimit, 4); + + /** + * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. + * + * @name rejectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function rejectSeries (coll, iteratee, callback) { + return reject$2(eachOfSeries$1, coll, iteratee, callback) + } + var rejectSeries$1 = awaitify(rejectSeries, 3); + + function constant(value) { + return function () { + return value; + } + } + + /** + * Attempts to get a successful response from `task` no more than `times` times + * before returning an error. If the task is successful, the `callback` will be + * passed the result of the successful task. If all attempts fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name retry + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @see [async.retryable]{@link module:ControlFlow.retryable} + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an + * object with `times` and `interval` or a number. + * * `times` - The number of attempts to make before giving up. The default + * is `5`. + * * `interval` - The time to wait between retries, in milliseconds. The + * default is `0`. The interval may also be specified as a function of the + * retry count (see example). + * * `errorFilter` - An optional synchronous function that is invoked on + * erroneous result. If it returns `true` the retry attempts will continue; + * if the function returns `false` the retry flow is aborted with the current + * attempt's error and result being returned to the final callback. + * Invoked with (err). + * * If `opts` is a number, the number specifies the number of times to retry, + * with the default interval of `0`. + * @param {AsyncFunction} task - An async function to retry. + * Invoked with (callback). + * @param {Function} [callback] - An optional callback which is called when the + * task has succeeded, or after the final failed attempt. It receives the `err` + * and `result` arguments of the last attempt at completing the `task`. Invoked + * with (err, results). + * @returns {Promise} a promise if no callback provided + * + * @example + * + * // The `retry` function can be used as a stand-alone control flow by passing + * // a callback, as shown below: + * + * // try calling apiMethod 3 times + * async.retry(3, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 3 times, waiting 200 ms between each retry + * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 10 times with exponential backoff + * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) + * async.retry({ + * times: 10, + * interval: function(retryCount) { + * return 50 * Math.pow(2, retryCount); + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod the default 5 times no delay between each retry + * async.retry(apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod only when error condition satisfies, all other + * // errors will abort the retry control flow and return to final callback + * async.retry({ + * errorFilter: function(err) { + * return err.message === 'Temporary error'; // only retry on a specific error + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // to retry individual methods that are not as reliable within other + * // control flow functions, use the `retryable` wrapper: + * async.auto({ + * users: api.getUsers.bind(api), + * payments: async.retryable(3, api.getPayments.bind(api)) + * }, function(err, results) { + * // do something with the results + * }); + * + */ + const DEFAULT_TIMES = 5; + const DEFAULT_INTERVAL = 0; + + function retry(opts, task, callback) { + var options = { + times: DEFAULT_TIMES, + intervalFunc: constant(DEFAULT_INTERVAL) + }; + + if (arguments.length < 3 && typeof opts === 'function') { + callback = task || promiseCallback(); + task = opts; + } else { + parseTimes(options, opts); + callback = callback || promiseCallback(); + } + + if (typeof task !== 'function') { + throw new Error("Invalid arguments for async.retry"); + } + + var _task = wrapAsync(task); + + var attempt = 1; + function retryAttempt() { + _task((err, ...args) => { + if (err === false) return + if (err && attempt++ < options.times && + (typeof options.errorFilter != 'function' || + options.errorFilter(err))) { + setTimeout(retryAttempt, options.intervalFunc(attempt - 1)); + } else { + callback(err, ...args); + } + }); + } + + retryAttempt(); + return callback[PROMISE_SYMBOL] + } + + function parseTimes(acc, t) { + if (typeof t === 'object') { + acc.times = +t.times || DEFAULT_TIMES; + + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant(+t.interval || DEFAULT_INTERVAL); + + acc.errorFilter = t.errorFilter; + } else if (typeof t === 'number' || typeof t === 'string') { + acc.times = +t || DEFAULT_TIMES; + } else { + throw new Error("Invalid arguments for async.retry"); + } + } + + /** + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method + * wraps a task and makes it retryable, rather than immediately calling it + * with retries. + * + * @name retryable + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.retry]{@link module:ControlFlow.retry} + * @category Control Flow + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional + * options, exactly the same as from `retry`, except for a `opts.arity` that + * is the arity of the `task` function, defaulting to `task.length` + * @param {AsyncFunction} task - the asynchronous function to wrap. + * This function will be passed any arguments passed to the returned wrapper. + * Invoked with (...args, callback). + * @returns {AsyncFunction} The wrapped function, which when invoked, will + * retry on an error, based on the parameters specified in `opts`. + * This function will accept the same parameters as `task`. + * @example + * + * async.auto({ + * dep1: async.retryable(3, getFromFlakyService), + * process: ["dep1", async.retryable(3, function (results, cb) { + * maybeProcessData(results.dep1, cb); + * })] + * }, callback); + */ + function retryable (opts, task) { + if (!task) { + task = opts; + opts = null; + } + let arity = (opts && opts.arity) || task.length; + if (isAsync(task)) { + arity += 1; + } + var _task = wrapAsync(task); + return initialParams((args, callback) => { + if (args.length < arity - 1 || callback == null) { + args.push(callback); + callback = promiseCallback(); + } + function taskFn(cb) { + _task(...args, cb); + } + + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + + return callback[PROMISE_SYMBOL] + }); + } + + /** + * Run the functions in the `tasks` collection in series, each one running once + * the previous function has completed. If any functions in the series pass an + * error to its callback, no more functions are run, and `callback` is + * immediately called with the value of the error. Otherwise, `callback` + * receives an array of results when `tasks` have completed. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function, and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.series}. + * + * **Note** that while many implementations preserve the order of object + * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) + * explicitly states that + * + * > The mechanics and order of enumerating the properties is not specified. + * + * So if you rely on the order in which your series of functions are executed, + * and want this to work on all platforms, consider using an array. + * + * @name series + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing + * [async functions]{@link AsyncFunction} to run in series. + * Each function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This function gets a results array (or object) + * containing all the result arguments passed to the `task` callbacks. Invoked + * with (err, result). + * @return {Promise} a promise, if no callback is passed + * @example + * + * //Using Callbacks + * async.series([ + * function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); + * } + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] + * }); + * + * // an example using objects instead of arrays + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.series([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] + * }).catch(err => { + * console.log(err); + * }); + * + * // an example using an object instead of an array + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.series([ + * function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function series(tasks, callback) { + return _parallel(eachOfSeries$1, tasks, callback); + } + + /** + * Returns `true` if at least one element in the `coll` satisfies an async test. + * If any iteratee call returns `true`, the main `callback` is immediately + * called. + * + * @name some + * @static + * @memberOf module:Collections + * @method + * @alias any + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + *); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // false + * // result is false since none of the files exists + * } + *); + * + * // Using Promises + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since some file in the list exists + * }).catch( err => { + * console.log(err); + * }); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since none of the files exists + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists); + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists); + * console.log(result); + * // false + * // result is false since none of the files exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function some(coll, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOf$1, coll, iteratee, callback) + } + var some$1 = awaitify(some, 3); + + /** + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. + * + * @name someLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anyLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function someLimit(coll, limit, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var someLimit$1 = awaitify(someLimit, 4); + + /** + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. + * + * @name someSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anySeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in series. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function someSeries(coll, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOfSeries$1, coll, iteratee, callback) + } + var someSeries$1 = awaitify(someSeries, 3); + + /** + * Sorts a list by the results of running each `coll` value through an async + * `iteratee`. + * + * @name sortBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a value to use as the sort criteria as + * its `result`. + * Invoked with (item, callback). + * @param {Function} callback - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is the items + * from the original `coll` sorted by the values returned by the `iteratee` + * calls. Invoked with (err, results). + * @returns {Promise} a promise, if no callback passed + * @example + * + * // bigfile.txt is a file that is 251100 bytes in size + * // mediumfile.txt is a file that is 11000 bytes in size + * // smallfile.txt is a file that is 121 bytes in size + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); + * + * // By modifying the callback parameter the + * // sorting order can be influenced: + * + * // ascending order + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) return callback(getFileSizeErr); + * callback(null, fileSize); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); + * + * // descending order + * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) { + * return callback(getFileSizeErr); + * } + * callback(null, fileSize * -1); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt'] + * } + * } + * ); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * } + * ); + * + * // Using Promises + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * }).catch( err => { + * console.log(err); + * }); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * (async () => { + * try { + * let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * + * // Error handling + * async () => { + * try { + * let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function sortBy (coll, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return map$1(coll, (x, iterCb) => { + _iteratee(x, (err, criteria) => { + if (err) return iterCb(err); + iterCb(err, {value: x, criteria}); + }); + }, (err, results) => { + if (err) return callback(err); + callback(null, results.sort(comparator).map(v => v.value)); + }); + + function comparator(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + } + } + var sortBy$1 = awaitify(sortBy, 3); + + /** + * Sets a time limit on an asynchronous function. If the function does not call + * its callback within the specified milliseconds, it will be called with a + * timeout error. The code property for the error object will be `'ETIMEDOUT'`. + * + * @name timeout + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} asyncFn - The async function to limit in time. + * @param {number} milliseconds - The specified time limit. + * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) + * to timeout Error for more information.. + * @returns {AsyncFunction} Returns a wrapped function that can be used with any + * of the control flow functions. + * Invoke this function with the same parameters as you would `asyncFunc`. + * @example + * + * function myFunction(foo, callback) { + * doAsyncTask(foo, function(err, data) { + * // handle errors + * if (err) return callback(err); + * + * // do some stuff ... + * + * // return processed data + * return callback(null, data); + * }); + * } + * + * var wrapped = async.timeout(myFunction, 1000); + * + * // call `wrapped` as you would `myFunction` + * wrapped({ bar: 'bar' }, function(err, data) { + * // if `myFunction` takes < 1000 ms to execute, `err` + * // and `data` will have their expected values + * + * // else `err` will be an Error with the code 'ETIMEDOUT' + * }); + */ + function timeout(asyncFn, milliseconds, info) { + var fn = wrapAsync(asyncFn); + + return initialParams((args, callback) => { + var timedOut = false; + var timer; + + function timeoutCallback() { + var name = asyncFn.name || 'anonymous'; + var error = new Error('Callback function "' + name + '" timed out.'); + error.code = 'ETIMEDOUT'; + if (info) { + error.info = info; + } + timedOut = true; + callback(error); + } + + args.push((...cbArgs) => { + if (!timedOut) { + callback(...cbArgs); + clearTimeout(timer); + } + }); + + // setup timer and call original function + timer = setTimeout(timeoutCallback, milliseconds); + fn(...args); + }); + } + + function range(size) { + var result = Array(size); + while (size--) { + result[size] = size; + } + return result; + } + + /** + * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a + * time. + * + * @name timesLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} count - The number of times to run the function. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see [async.map]{@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + */ + function timesLimit(count, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(range(count), limit, _iteratee, callback); + } + + /** + * Calls the `iteratee` function `n` times, and accumulates results in the same + * manner you would use with [map]{@link module:Collections.map}. + * + * @name times + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.map]{@link module:Collections.map} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + * @example + * + * // Pretend this is some complicated async factory + * var createUser = function(id, callback) { + * callback(null, { + * id: 'user' + id + * }); + * }; + * + * // generate 5 users + * async.times(5, function(n, next) { + * createUser(n, function(err, user) { + * next(err, user); + * }); + * }, function(err, users) { + * // we should now have 5 users + * }); + */ + function times (n, iteratee, callback) { + return timesLimit(n, Infinity, iteratee, callback) + } + + /** + * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. + * + * @name timesSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + */ + function timesSeries (n, iteratee, callback) { + return timesLimit(n, 1, iteratee, callback) + } + + /** + * A relative of `reduce`. Takes an Object or Array, and iterates over each + * element in parallel, each step potentially mutating an `accumulator` value. + * The type of the accumulator defaults to the type of collection passed in. + * + * @name transform + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {*} [accumulator] - The initial state of the transform. If omitted, + * it will default to an empty Object or Array, depending on the type of `coll` + * @param {AsyncFunction} iteratee - A function applied to each item in the + * collection that potentially modifies the accumulator. + * Invoked with (accumulator, item, key, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the transformed accumulator. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); + * }); + * } + * + * // Using callbacks + * async.transform(fileList, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } + * }); + * + * // Using Promises + * async.transform(fileList, transformFileSize) + * .then(result => { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * (async () => { + * try { + * let result = await async.transform(fileList, transformFileSize); + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' }; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); + * }); + * } + * + * // Using callbacks + * async.transform(fileMap, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * }); + * + * // Using Promises + * async.transform(fileMap, transformFileSize) + * .then(result => { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.transform(fileMap, transformFileSize); + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function transform (coll, accumulator, iteratee, callback) { + if (arguments.length <= 3 && typeof accumulator === 'function') { + callback = iteratee; + iteratee = accumulator; + accumulator = Array.isArray(coll) ? [] : {}; + } + callback = once(callback || promiseCallback()); + var _iteratee = wrapAsync(iteratee); + + eachOf$1(coll, (v, k, cb) => { + _iteratee(accumulator, v, k, cb); + }, err => callback(err, accumulator)); + return callback[PROMISE_SYMBOL] + } + + /** + * It runs each task in series but stops whenever any of the functions were + * successful. If one of the tasks were successful, the `callback` will be + * passed the result of the successful task. If all tasks fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name tryEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing functions to + * run, each function is passed a `callback(err, result)` it must call on + * completion with an error `err` (which can be `null`) and an optional `result` + * value. + * @param {Function} [callback] - An optional callback which is called when one + * of the tasks has succeeded, or all have failed. It receives the `err` and + * `result` arguments of the last attempt at completing the `task`. Invoked with + * (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * async.tryEach([ + * function getDataFromFirstWebsite(callback) { + * // Try getting the data from the first website + * callback(err, data); + * }, + * function getDataFromSecondWebsite(callback) { + * // First website failed, + * // Try getting the data from the backup website + * callback(err, data); + * } + * ], + * // optional callback + * function(err, results) { + * Now do something with the data. + * }); + * + */ + function tryEach(tasks, callback) { + var error = null; + var result; + return eachSeries$1(tasks, (task, taskCb) => { + wrapAsync(task)((err, ...args) => { + if (err === false) return taskCb(err); + + if (args.length < 2) { + [result] = args; + } else { + result = args; + } + error = err; + taskCb(err ? null : {}); + }); + }, () => callback(error, result)); + } + + var tryEach$1 = awaitify(tryEach); + + /** + * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, + * unmemoized form. Handy for testing. + * + * @name unmemoize + * @static + * @memberOf module:Utils + * @method + * @see [async.memoize]{@link module:Utils.memoize} + * @category Util + * @param {AsyncFunction} fn - the memoized function + * @returns {AsyncFunction} a function that calls the original unmemoized function + */ + function unmemoize(fn) { + return (...args) => { + return (fn.unmemoized || fn)(...args); + }; + } + + /** + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. + * + * @name whilst + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + * @example + * + * var count = 0; + * async.whilst( + * function test(cb) { cb(null, count < 5); }, + * function iter(callback) { + * count++; + * setTimeout(function() { + * callback(null, count); + * }, 1000); + * }, + * function (err, n) { + * // 5 seconds have passed, n = 5 + * } + * ); + */ + function whilst(test, iteratee, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results = []; + + function next(err, ...rest) { + if (err) return callback(err); + results = rest; + if (err === false) return; + _test(check); + } + + function check(err, truth) { + if (err) return callback(err); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return _test(check); + } + var whilst$1 = awaitify(whilst, 3); + + /** + * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. `callback` will be passed an error and any + * arguments passed to the final `iteratee`'s callback. + * + * The inverse of [whilst]{@link module:ControlFlow.whilst}. + * + * @name until + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if a callback is not passed + * + * @example + * const results = [] + * let finished = false + * async.until(function test(cb) { + * cb(null, finished) + * }, function iter(next) { + * fetchPage(url, (err, body) => { + * if (err) return next(err) + * results = results.concat(body.objects) + * finished = !!body.next + * next(err) + * }) + * }, function done (err) { + * // all pages have been fetched + * }) + */ + function until(test, iteratee, callback) { + const _test = wrapAsync(test); + return whilst$1((cb) => _test((err, truth) => cb (err, !truth)), iteratee, callback); + } + + /** + * Runs the `tasks` array of functions in series, each passing their results to + * the next in the array. However, if any of the `tasks` pass an error to their + * own callback, the next function is not executed, and the main `callback` is + * immediately called with the error. + * + * @name waterfall + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} + * to run. + * Each function should complete with any number of `result` values. + * The `result` values will be passed as arguments, in order, to the next task. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This will be passed the results of the last task's + * callback. Invoked with (err, [results]). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * async.waterfall([ + * function(callback) { + * callback(null, 'one', 'two'); + * }, + * function(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * }, + * function(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + * ], function (err, result) { + * // result now equals 'done' + * }); + * + * // Or, with named functions: + * async.waterfall([ + * myFirstFunction, + * mySecondFunction, + * myLastFunction, + * ], function (err, result) { + * // result now equals 'done' + * }); + * function myFirstFunction(callback) { + * callback(null, 'one', 'two'); + * } + * function mySecondFunction(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * } + * function myLastFunction(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + */ + function waterfall (tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); + if (!tasks.length) return callback(); + var taskIndex = 0; + + function nextTask(args) { + var task = wrapAsync(tasks[taskIndex++]); + task(...args, onlyOnce(next)); + } + + function next(err, ...args) { + if (err === false) return + if (err || taskIndex === tasks.length) { + return callback(err, ...args); + } + nextTask(args); + } + + nextTask([]); + } + + var waterfall$1 = awaitify(waterfall); + + /** + * 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 + */ + + + var index = { + apply, + applyEach, + applyEachSeries, + asyncify, + auto, + autoInject, + cargo: cargo$1, + cargoQueue: cargo, + compose, + concat: concat$1, + concatLimit: concatLimit$1, + concatSeries: concatSeries$1, + constant: constant$1, + detect: detect$1, + detectLimit: detectLimit$1, + detectSeries: detectSeries$1, + dir, + doUntil, + doWhilst: doWhilst$1, + each, + eachLimit: eachLimit$1, + eachOf: eachOf$1, + eachOfLimit: eachOfLimit$1, + eachOfSeries: eachOfSeries$1, + eachSeries: eachSeries$1, + ensureAsync, + every: every$1, + everyLimit: everyLimit$1, + everySeries: everySeries$1, + filter: filter$1, + filterLimit: filterLimit$1, + filterSeries: filterSeries$1, + forever: forever$1, + groupBy, + groupByLimit: groupByLimit$1, + groupBySeries, + log, + map: map$1, + mapLimit: mapLimit$1, + mapSeries: mapSeries$1, + mapValues, + mapValuesLimit: mapValuesLimit$1, + mapValuesSeries, + memoize, + nextTick, + parallel, + parallelLimit, + priorityQueue, + queue, + race: race$1, + reduce: reduce$1, + reduceRight, + reflect, + reflectAll, + reject: reject$1, + rejectLimit: rejectLimit$1, + rejectSeries: rejectSeries$1, + retry, + retryable, + seq, + series, + setImmediate: setImmediate$1, + some: some$1, + someLimit: someLimit$1, + someSeries: someSeries$1, + sortBy: sortBy$1, + timeout, + times, + timesLimit, + timesSeries, + transform, + tryEach: tryEach$1, + unmemoize, + until, + waterfall: waterfall$1, + whilst: whilst$1, + + // aliases + all: every$1, + allLimit: everyLimit$1, + allSeries: everySeries$1, + any: some$1, + anyLimit: someLimit$1, + anySeries: someSeries$1, + find: detect$1, + findLimit: detectLimit$1, + findSeries: detectSeries$1, + flatMap: concat$1, + flatMapLimit: concatLimit$1, + flatMapSeries: concatSeries$1, + forEach: each, + forEachSeries: eachSeries$1, + forEachLimit: eachLimit$1, + forEachOf: eachOf$1, + forEachOfSeries: eachOfSeries$1, + forEachOfLimit: eachOfLimit$1, + inject: reduce$1, + foldl: reduce$1, + foldr: reduceRight, + select: filter$1, + selectLimit: filterLimit$1, + selectSeries: filterSeries$1, + wrapSync: asyncify, + during: whilst$1, + doDuring: doWhilst$1 + }; + + exports.all = every$1; + exports.allLimit = everyLimit$1; + exports.allSeries = everySeries$1; + exports.any = some$1; + exports.anyLimit = someLimit$1; + exports.anySeries = someSeries$1; + exports.apply = apply; + exports.applyEach = applyEach; + exports.applyEachSeries = applyEachSeries; + exports.asyncify = asyncify; + exports.auto = auto; + exports.autoInject = autoInject; + exports.cargo = cargo$1; + exports.cargoQueue = cargo; + exports.compose = compose; + exports.concat = concat$1; + exports.concatLimit = concatLimit$1; + exports.concatSeries = concatSeries$1; + exports.constant = constant$1; + exports.default = index; + exports.detect = detect$1; + exports.detectLimit = detectLimit$1; + exports.detectSeries = detectSeries$1; + exports.dir = dir; + exports.doDuring = doWhilst$1; + exports.doUntil = doUntil; + exports.doWhilst = doWhilst$1; + exports.during = whilst$1; + exports.each = each; + exports.eachLimit = eachLimit$1; + exports.eachOf = eachOf$1; + exports.eachOfLimit = eachOfLimit$1; + exports.eachOfSeries = eachOfSeries$1; + exports.eachSeries = eachSeries$1; + exports.ensureAsync = ensureAsync; + exports.every = every$1; + exports.everyLimit = everyLimit$1; + exports.everySeries = everySeries$1; + exports.filter = filter$1; + exports.filterLimit = filterLimit$1; + exports.filterSeries = filterSeries$1; + exports.find = detect$1; + exports.findLimit = detectLimit$1; + exports.findSeries = detectSeries$1; + exports.flatMap = concat$1; + exports.flatMapLimit = concatLimit$1; + exports.flatMapSeries = concatSeries$1; + exports.foldl = reduce$1; + exports.foldr = reduceRight; + exports.forEach = each; + exports.forEachLimit = eachLimit$1; + exports.forEachOf = eachOf$1; + exports.forEachOfLimit = eachOfLimit$1; + exports.forEachOfSeries = eachOfSeries$1; + exports.forEachSeries = eachSeries$1; + exports.forever = forever$1; + exports.groupBy = groupBy; + exports.groupByLimit = groupByLimit$1; + exports.groupBySeries = groupBySeries; + exports.inject = reduce$1; + exports.log = log; + exports.map = map$1; + exports.mapLimit = mapLimit$1; + exports.mapSeries = mapSeries$1; + exports.mapValues = mapValues; + exports.mapValuesLimit = mapValuesLimit$1; + exports.mapValuesSeries = mapValuesSeries; + exports.memoize = memoize; + exports.nextTick = nextTick; + exports.parallel = parallel; + exports.parallelLimit = parallelLimit; + exports.priorityQueue = priorityQueue; + exports.queue = queue; + exports.race = race$1; + exports.reduce = reduce$1; + exports.reduceRight = reduceRight; + exports.reflect = reflect; + exports.reflectAll = reflectAll; + exports.reject = reject$1; + exports.rejectLimit = rejectLimit$1; + exports.rejectSeries = rejectSeries$1; + exports.retry = retry; + exports.retryable = retryable; + exports.select = filter$1; + exports.selectLimit = filterLimit$1; + exports.selectSeries = filterSeries$1; + exports.seq = seq; + exports.series = series; + exports.setImmediate = setImmediate$1; + exports.some = some$1; + exports.someLimit = someLimit$1; + exports.someSeries = someSeries$1; + exports.sortBy = sortBy$1; + exports.timeout = timeout; + exports.times = times; + exports.timesLimit = timesLimit; + exports.timesSeries = timesSeries; + exports.transform = transform; + exports.tryEach = tryEach$1; + exports.unmemoize = unmemoize; + exports.until = until; + exports.waterfall = waterfall$1; + exports.whilst = whilst$1; + exports.wrapSync = asyncify; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/dist/async.min.js b/dist/async.min.js index af3069ae8..f0b7fdf5f 100644 --- a/dist/async.min.js +++ b/dist/async.min.js @@ -1,2 +1 @@ -!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}function e(n,e){return e=et(void 0===e?n.length-1:e,0),function(){for(var r=arguments,u=-1,i=et(r.length-e,0),o=Array(i);++u-1&&n%1==0&&ft>=n}function a(n){return null!=n&&f(rt(n))&&!c(n)}function l(){}function s(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function p(n){return at&&n[at]&&n[at]()}function h(n,t){return function(e){return n(t(e))}}function y(n,t){return null!=n&&(ht.call(n,t)||"object"==typeof n&&t in n&&null===st(n))}function v(n,t){for(var e=-1,r=Array(n);++e-1&&n%1==0&&t>n}function k(n){var t=n&&n.constructor,e="function"==typeof t&&t.prototype||xt;return n===e}function w(n){var t=k(n);if(!t&&!a(n))return vt(n);var e=S(n),r=!!e,u=e||[],i=u.length;for(var o in n)!y(n,o)||r&&("length"==o||j(o,i))||t&&"constructor"==o||u.push(o);return u}function L(n){var t=-1,e=n.length;return function(){return++te?{value:n[u],key:u}:null}}function x(n){if(a(n))return L(n);var t=p(n);return t?E(t):O(n)}function A(n){return function(){if(null===n)throw new Error("Callback was already called.");var t=n;n=null,t.apply(this,arguments)}}function _(n){return function(t,e,r){function u(n){if(f-=1,n)c=!0,r(n);else{if(c&&0>=f)return r(null);i()}}function i(){for(;n>f&&!c;){var t=o();if(null===t)return c=!0,void(0>=f&&r(null));f+=1,e(t.value,t.key,A(u))}}if(r=s(r||l),0>=n||!t)return r(null);var o=x(t),c=!1,f=0;i()}}function I(n,t,e,r){_(t)(n,e,r)}function T(n,t){return function(e,r,u){return n(e,t,r,u)}}function F(n,t,e){function r(n){n?e(n):++i===o&&e(null)}e=s(e||l);var u=0,i=0,o=n.length;for(0===o&&e(null);o>u;u++)t(n[u],u,A(r))}function z(n,t,e){var r=a(n)?F:At;r(n,t,e)}function B(n){return function(t,e,r){return n(z,t,e,r)}}function M(n,t,e,r){r=s(r||l),t=t||[];var u=[],i=0;n(t,function(n,t,r){var o=i++;e(n,function(n,t){u[o]=t,r(n)})},function(n){r(n,u)})}function V(n){return function(t,e,r,u){return n(_(e),t,r,u)}}function q(n){return r(function(t,e){var r;try{r=n.apply(this,t)}catch(u){return e(u)}o(r)&&"function"==typeof r.then?r.then(function(n){e(null,n)},function(n){e(n.message?n:new Error(n))}):e(null,r)})}function $(n,t){for(var e=-1,r=n?n.length:0;++em;){var n=b.shift();n()}}function o(n,t){var e=g[n];e||(e=g[n]=[]),e.push(t)}function c(n){var t=g[n]||[];$(t,function(n){n()}),i()}function f(n,t){if(!d){var u=A(e(function(t,e){if(m--,e.length<=1&&(e=e[0]),t){var u={};D(v,function(n,t){u[t]=n}),u[n]=e,d=!0,g=[],r(t,u)}else v[n]=e,c(n)}));m++;var i=t[t.length-1];t.length>1?i(v,u):i(u)}}function a(){for(var n,t=0;S.length;)n=S.pop(),t++,$(p(n),function(n){0===--j[n]&&S.push(n)});if(t!==y)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function p(t){var e=[];return D(n,function(n,r){jt(n)&&U(n,t,0)>=0&&e.push(r)}),e}"function"==typeof t&&(r=t,t=null),r=s(r||l);var h=w(n),y=h.length;if(!y)return r(null);t||(t=y);var v={},m=0,d=!1,g={},b=[],S=[],j={};D(n,function(t,e){if(!jt(t))return u(e,[t]),void S.push(e);var r=t.slice(0,t.length-1),i=r.length;return 0===i?(u(e,t),void S.push(e)):(j[e]=i,void $(r,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency in "+r.join(", "));o(c,function(){i--,0===i&&u(e,t)})}))}),a(),i()}function W(n,t){for(var e=-1,r=n?n.length:0,u=Array(r);++et&&(t=-t>u?0:u+t),e=e>u?u:e,0>e&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(u);++r=r?n:K(n,t,e)}function X(n,t){for(var e=n.length;e--&&U(t,n[e],0)>-1;);return e}function Y(n,t){for(var e=-1,r=n.length;++e-1;);return e}function Z(n){return n.match(ae)}function nn(n){return null==n?"":J(n)}function tn(n,t,e){if(n=nn(n),n&&(e||void 0===t))return n.replace(le,"");if(!n||!(t=J(t)))return n;var r=Z(n),u=Z(t),i=Y(r,u),o=X(r,u)+1;return N(r,i,o).join("")}function en(n){return n=n.toString().replace(ye,""),n=n.match(se)[2].replace(" ",""),n=n?n.split(pe):[],n=n.map(function(n){return tn(n.replace(he,""))})}function rn(n,t){var e={};D(n,function(n,t){function r(t,e){var r=W(u,function(n){return t[n]});r.push(e),n.apply(null,r)}var u;if(jt(n))u=G(n),n=u.pop(),e[t]=u.concat(u.length>0?r:n);else if(1===n.length)e[t]=n;else{if(u=en(n),0===n.length&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");u.pop(),e[t]=u.concat(r)}}),Q(e,t)}function un(n){setTimeout(n,0)}function on(n){return e(function(t,e){n(function(){t.apply(null,e)})})}function cn(){this.head=this.tail=null,this.length=0}function fn(n,t){n.length=1,n.head=n.tail=t}function an(n,t,r){function u(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");return f.started=!0,jt(n)||(n=[n]),0===n.length&&f.idle()?de(function(){f.drain()}):($(n,function(n){var r={data:n,callback:e||l};t?f._tasks.unshift(r):f._tasks.push(r)}),void de(f.process))}function i(n){return e(function(t){o-=1,$(n,function(n){$(c,function(t,e){return t===n?(c.splice(e,1),!1):void 0}),n.callback.apply(n,t),null!=t[0]&&f.error(t[0],n.data)}),o<=f.concurrency-f.buffer&&f.unsaturated(),f.idle()&&f.drain(),f.process()})}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var o=0,c=[],f={_tasks:new cn,concurrency:t,payload:r,saturated:l,unsaturated:l,buffer:t/4,empty:l,drain:l,error:l,started:!1,paused:!1,push:function(n,t){u(n,!1,t)},kill:function(){f.drain=l,f._tasks.empty()},unshift:function(n,t){u(n,!0,t)},process:function(){for(;!f.paused&&ou;u++){var a=f._tasks.shift();t.push(a),e.push(a.data)}0===f._tasks.length&&f.empty(),o+=1,c.push(t[0]),o===f.concurrency&&f.saturated();var l=A(i(t));n(e,l)}},length:function(){return f._tasks.length},running:function(){return o},workersList:function(){return c},idle:function(){return f._tasks.length+o===0},pause:function(){f.paused=!0},resume:function(){if(f.paused!==!1){f.paused=!1;for(var n=Math.min(f.concurrency,f._tasks.length),t=1;n>=t;t++)de(f.process)}}};return f}function ln(n,t){return an(n,1,t)}function sn(n,t,e,r){r=s(r||l),be(n,function(n,r,u){e(t,n,function(n,e){t=e,u(n)})},function(n){r(n,t)})}function pn(n,t,e,r){var u=[];n(t,function(n,t,r){e(n,function(n,t){u=u.concat(t||[]),r(n)})},function(n){r(n,u)})}function hn(n){return function(t,e,r){return n(be,t,e,r)}}function yn(n){return n}function vn(n,t,e){return function(r,u,i,o){function c(n){o&&(n?o(n):o(null,e(!1)))}function f(n,r,u){return o?void i(n,function(r,c){o&&(r?(o(r),o=i=!1):t(c)&&(o(null,e(!0,n)),o=i=!1)),u()}):u()}arguments.length>3?(o=o||l,n(r,u,f,c)):(o=i,o=o||l,i=u,n(r,f,c))}}function mn(n,t){return t}function dn(n){return e(function(t,r){t.apply(null,r.concat([e(function(t,e){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&$(e,function(t){console[n](t)}))})]))})}function gn(n,t,r){function u(t,e){return t?r(t):e?void n(i):r(null)}r=A(r||l);var i=e(function(n,e){return n?r(n):(e.push(u),void t.apply(this,e))});u(null,!0)}function bn(n,t,r){r=A(r||l);var u=e(function(e,i){return e?r(e):t.apply(this,i)?n(u):void r.apply(null,[null].concat(i))});n(u)}function Sn(n,t,e){bn(n,function(){return!t.apply(this,arguments)},e)}function jn(n,t,e){function r(t){return t?e(t):void n(u)}function u(n,u){return n?e(n):u?void t(r):e(null)}e=A(e||l),n(u)}function kn(n){return function(t,e,r){return n(t,r)}}function wn(n,t,e){z(n,kn(t),e)}function Ln(n,t,e,r){_(t)(n,kn(e),r)}function En(n){return r(function(t,e){var r=!0;t.push(function(){var n=arguments;r?de(function(){e.apply(null,n)}):e.apply(null,n)}),n.apply(this,t),r=!1})}function On(n){return!n}function xn(n,t,e,r){r=s(r||l);var u=[];n(t,function(n,t,r){e(n,function(e,i){e?r(e):(i&&u.push({index:t,value:n}),r())})},function(n){n?r(n):r(null,W(u.sort(function(n,t){return n.index-t.index}),i("value")))})}function An(n,t){function e(n){return n?r(n):void u(e)}var r=A(t||l),u=En(n);e()}function _n(n,t,e,r){r=s(r||l);var u={};I(n,t,function(n,t,r){e(n,t,function(n,e){return n?r(n):(u[t]=e,void r())})},function(n){r(n,u)})}function In(n,t){return t in n}function Tn(n,t){var u=Object.create(null),i=Object.create(null);t=t||yn;var o=r(function(r,o){var c=t.apply(null,r);In(u,c)?de(function(){o.apply(null,u[c])}):In(i,c)?i[c].push(o):(i[c]=[o],n.apply(null,r.concat([e(function(n){u[c]=n;var t=i[c];delete i[c];for(var e=0,r=t.length;r>e;e++)t[e].apply(null,n)})])))});return o.memo=u,o.unmemoized=n,o}function Fn(n,t,r){r=r||l;var u=a(t)?[]:{};n(t,function(n,t,r){n(e(function(n,e){e.length<=1&&(e=e[0]),u[t]=e,r(n)}))},function(n){r(n,u)})}function zn(n,t){Fn(z,n,t)}function Bn(n,t,e){Fn(_(t),n,e)}function Mn(n,t){return an(function(t,e){n(t[0],e)},t,1)}function Vn(n,t){var e=Mn(n,t);return e.push=function(n,t,r){if(null==r&&(r=l),"function"!=typeof r)throw new Error("task callback must be a function");if(e.started=!0,jt(n)||(n=[n]),0===n.length)return de(function(){e.drain()});t=t||0;for(var u=e._tasks.head;u&&t>=u.priority;)u=u.next;$(n,function(n){var i={data:n,priority:t,callback:r};u?e._tasks.insertBefore(u,i):e._tasks.push(i)}),de(e.process)},delete e.unshift,e}function qn(n,t){return t=s(t||l),jt(n)?n.length?void $(n,function(n){n(t)}):t():t(new TypeError("First argument to race must be an array of functions"))}function $n(n,t,e,r){var u=De.call(n).reverse();sn(u,t,e,r)}function Cn(n){return r(function(t,r){return t.push(e(function(n,t){if(n)r(null,{error:n});else{var e=null;1===t.length?e=t[0]:t.length>1&&(e=t),r(null,{value:e})}})),n.apply(this,t)})}function Dn(n,t,e,r){xn(n,t,function(n,t){e(n,function(n,e){n?t(n):t(null,!e)})},r)}function Pn(n){var t;return jt(n)?t=W(n,Cn):(t={},D(n,function(n,e){t[e]=Cn.call(this,n)})),t}function Rn(n){return function(){return n}}function Un(n,t,e){function r(n,t){if("object"==typeof t)n.times=+t.times||i,n.intervalFunc="function"==typeof t.interval?t.interval:Rn(+t.interval||o);else{if("number"!=typeof t&&"string"!=typeof t)throw new Error("Invalid arguments for async.retry");n.times=+t||i}}function u(){t(function(n){n&&f++e?-1:e>r?1:0}_t(n,function(n,e){t(n,function(t,r){return t?e(t):void e(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,W(t.sort(r),i("value")))})}function Hn(n,t,e){function u(){f||(o.apply(null,arguments),clearTimeout(c))}function i(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),f=!0,o(r)}var o,c,f=!1;return r(function(e,r){o=r,c=setTimeout(i,t),n.apply(null,e.concat(u))})}function Jn(n,t,e,r){for(var u=-1,i=Je(He((t-n)/(e||1)),0),o=Array(i);i--;)o[r?i:++u]=n,n+=e;return o}function Kn(n,t,e,r){Tt(Jn(0,n,1),t,e,r)}function Nn(n,t,e,r){3===arguments.length&&(r=e,e=t,t=jt(n)?[]:{}),r=s(r||l),z(n,function(n,r,u){e(t,n,r,u)},function(n){r(n,t)})}function Xn(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function Yn(n,t,r){if(r=A(r||l),!n())return r(null);var u=e(function(e,i){return e?r(e):n()?t(u):void r.apply(null,[null].concat(i))});t(u)}function Zn(n,t,e){Yn(function(){return!n.apply(this,arguments)},t,e)}function nt(n,t){function r(i){if(u===n.length)return t.apply(null,[null].concat(i));var o=A(e(function(n,e){return n?t.apply(null,[n].concat(e)):void r(e)}));i.push(o);var c=n[u++];c.apply(null,i)}if(t=s(t||l),!jt(n))return t(new Error("First argument to waterfall must be an array of functions"));if(!n.length)return t();var u=0;r([])}var tt,et=Math.max,rt=i("length"),ut="[object Function]",it="[object GeneratorFunction]",ot=Object.prototype,ct=ot.toString,ft=9007199254740991,at="function"==typeof Symbol&&Symbol.iterator,lt=Object.getPrototypeOf,st=h(lt,Object),pt=Object.prototype,ht=pt.hasOwnProperty,yt=Object.keys,vt=h(yt,Object),mt="[object Arguments]",dt=Object.prototype,gt=dt.hasOwnProperty,bt=dt.toString,St=dt.propertyIsEnumerable,jt=Array.isArray,kt="[object String]",wt=Object.prototype,Lt=wt.toString,Et=9007199254740991,Ot=/^(?:0|[1-9]\d*)$/,xt=Object.prototype,At=T(I,1/0),_t=B(M),It=u(_t),Tt=V(M),Ft=T(Tt,1),zt=u(Ft),Bt=e(function(n,t){return e(function(e){return n.apply(null,t.concat(e))})}),Mt=C(),Vt="object"==typeof global&&global&&global.Object===Object&&global,qt="object"==typeof self&&self&&self.Object===Object&&self,$t=Vt||qt||Function("return this")(),Ct=$t.Symbol,Dt="[object Symbol]",Pt=Object.prototype,Rt=Pt.toString,Ut=1/0,Qt=Ct?Ct.prototype:void 0,Wt=Qt?Qt.toString:void 0,Gt="\\ud800-\\udfff",Ht="\\u0300-\\u036f\\ufe20-\\ufe23",Jt="\\u20d0-\\u20f0",Kt="\\ufe0e\\ufe0f",Nt="["+Gt+"]",Xt="["+Ht+Jt+"]",Yt="\\ud83c[\\udffb-\\udfff]",Zt="(?:"+Xt+"|"+Yt+")",ne="[^"+Gt+"]",te="(?:\\ud83c[\\udde6-\\uddff]){2}",ee="[\\ud800-\\udbff][\\udc00-\\udfff]",re="\\u200d",ue=Zt+"?",ie="["+Kt+"]?",oe="(?:"+re+"(?:"+[ne,te,ee].join("|")+")"+ie+ue+")*",ce=ie+ue+oe,fe="(?:"+[ne+Xt+"?",Xt,te,ee,Nt].join("|")+")",ae=RegExp(Yt+"(?="+Yt+")|"+fe+ce,"g"),le=/^\s+|\s+$/g,se=/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,pe=/,/,he=/(=.+)?(\s*)$/,ye=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,ve="function"==typeof setImmediate&&setImmediate,me="object"==typeof process&&"function"==typeof process.nextTick;tt=ve?setImmediate:me?process.nextTick:un;var de=on(tt);cn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},cn.prototype.empty=cn,cn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},cn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},cn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):fn(this,n)},cn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):fn(this,n)},cn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},cn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)};var ge,be=T(I,1),Se=e(function(n){return e(function(t){var r=this,u=t[t.length-1];"function"==typeof u?t.pop():u=l,sn(n,t,function(n,t,u){t.apply(r,n.concat([e(function(n,t){u(n,t)})]))},function(n,t){u.apply(r,[n].concat(t))})})}),je=e(function(n){return Se.apply(null,n.reverse())}),ke=B(pn),we=hn(pn),Le=e(function(n){var t=[null].concat(n);return r(function(n,e){return e.apply(this,t)})}),Ee=vn(z,yn,mn),Oe=vn(I,yn,mn),xe=vn(be,yn,mn),Ae=dn("dir"),_e=T(Ln,1),Ie=vn(z,On,On),Te=vn(I,On,On),Fe=T(Te,1),ze=B(xn),Be=V(xn),Me=T(Be,1),Ve=dn("log"),qe=T(_n,1/0),$e=T(_n,1);ge=me?process.nextTick:ve?setImmediate:un;var Ce=on(ge),De=Array.prototype.slice,Pe=B(Dn),Re=V(Dn),Ue=T(Re,1),Qe=vn(z,Boolean,yn),We=vn(I,Boolean,yn),Ge=T(We,1),He=Math.ceil,Je=Math.max,Ke=T(Kn,1/0),Ne=T(Kn,1),Xe={applyEach:It,applyEachSeries:zt,apply:Bt,asyncify:q,auto:Q,autoInject:rn,cargo:ln,compose:je,concat:ke,concatSeries:we,constant:Le,detect:Ee,detectLimit:Oe,detectSeries:xe,dir:Ae,doDuring:gn,doUntil:Sn,doWhilst:bn,during:jn,each:wn,eachLimit:Ln,eachOf:z,eachOfLimit:I,eachOfSeries:be,eachSeries:_e,ensureAsync:En,every:Ie,everyLimit:Te,everySeries:Fe,filter:ze,filterLimit:Be,filterSeries:Me,forever:An,log:Ve,map:_t,mapLimit:Tt,mapSeries:Ft,mapValues:qe,mapValuesLimit:_n,mapValuesSeries:$e,memoize:Tn,nextTick:Ce,parallel:zn,parallelLimit:Bn,priorityQueue:Vn,queue:Mn,race:qn,reduce:sn,reduceRight:$n,reflect:Cn,reflectAll:Pn,reject:Pe,rejectLimit:Re,rejectSeries:Ue,retry:Un,retryable:Qn,seq:Se,series:Wn,setImmediate:de,some:Qe,someLimit:We,someSeries:Ge,sortBy:Gn,timeout:Hn,times:Ke,timesLimit:Kn,timesSeries:Ne,transform:Nn,unmemoize:Xn,until:Zn,waterfall:nt,whilst:Yn,all:Ie,any:Qe,forEach:wn,forEachSeries:_e,forEachLimit:Ln,forEachOf:z,forEachOfSeries:be,forEachOfLimit:I,inject:sn,foldl:sn,foldr:$n,select:ze,selectLimit:Be,selectSeries:Me,wrapSync:q};n["default"]=Xe,n.applyEach=It,n.applyEachSeries=zt,n.apply=Bt,n.asyncify=q,n.auto=Q,n.autoInject=rn,n.cargo=ln,n.compose=je,n.concat=ke,n.concatSeries=we,n.constant=Le,n.detect=Ee,n.detectLimit=Oe,n.detectSeries=xe,n.dir=Ae,n.doDuring=gn,n.doUntil=Sn,n.doWhilst=bn,n.during=jn,n.each=wn,n.eachLimit=Ln,n.eachOf=z,n.eachOfLimit=I,n.eachOfSeries=be,n.eachSeries=_e,n.ensureAsync=En,n.every=Ie,n.everyLimit=Te,n.everySeries=Fe,n.filter=ze,n.filterLimit=Be,n.filterSeries=Me,n.forever=An,n.log=Ve,n.map=_t,n.mapLimit=Tt,n.mapSeries=Ft,n.mapValues=qe,n.mapValuesLimit=_n,n.mapValuesSeries=$e,n.memoize=Tn,n.nextTick=Ce,n.parallel=zn,n.parallelLimit=Bn,n.priorityQueue=Vn,n.queue=Mn,n.race=qn,n.reduce=sn,n.reduceRight=$n,n.reflect=Cn,n.reflectAll=Pn,n.reject=Pe,n.rejectLimit=Re,n.rejectSeries=Ue,n.retry=Un,n.retryable=Qn,n.seq=Se,n.series=Wn,n.setImmediate=de,n.some=Qe,n.someLimit=We,n.someSeries=Ge,n.sortBy=Gn,n.timeout=Hn,n.times=Ke,n.timesLimit=Kn,n.timesSeries=Ne,n.transform=Nn,n.unmemoize=Xn,n.until=Zn,n.waterfall=nt,n.whilst=Yn,n.all=Ie,n.allLimit=Te,n.allSeries=Fe,n.any=Qe,n.anyLimit=We,n.anySeries=Ge,n.find=Ee,n.findLimit=Oe,n.findSeries=xe,n.forEach=wn,n.forEachSeries=_e,n.forEachLimit=Ln,n.forEachOf=z,n.forEachOfSeries=be,n.forEachOfLimit=I,n.inject=sn,n.foldl=sn,n.foldr=$n,n.select=ze,n.selectLimit=Be,n.selectSeries=Me,n.wrapSync=q}); -//# sourceMappingURL=async.min.map \ No newline at end of file +(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e="undefined"==typeof globalThis?e||self:globalThis,t(e.async={}))})(this,function(e){"use strict";function t(e,...t){return(...n)=>e(...t,...n)}function n(e){return function(...t){var n=t.pop();return e.call(this,t,n)}}function a(e){setTimeout(e,0)}function i(e){return(t,...n)=>e(()=>t(...n))}function r(e){return d(e)?function(...t){const n=t.pop(),a=e.apply(this,t);return s(a,n)}:n(function(t,n){var a;try{a=e.apply(this,t)}catch(t){return n(t)}return a&&"function"==typeof a.then?s(a,n):void n(null,a)})}function s(e,t){return e.then(e=>{l(t,null,e)},e=>{l(t,e&&(e instanceof Error||e.message)?e:new Error(e))})}function l(e,t,n){try{e(t,n)}catch(e){_e(t=>{throw t},e)}}function d(e){return"AsyncFunction"===e[Symbol.toStringTag]}function u(e){return"AsyncGenerator"===e[Symbol.toStringTag]}function p(e){return"function"==typeof e[Symbol.asyncIterator]}function c(e){if("function"!=typeof e)throw new Error("expected a function");return d(e)?r(e):e}function o(e,t){function n(...n){return"function"==typeof n[t-1]?e.apply(this,n):new Promise((a,i)=>{n[t-1]=(e,...t)=>e?i(e):void a(1{c(e).apply(i,n.concat(t))},a)});return i}}function f(e,t,n,a){t=t||[];var i=[],r=0,s=c(n);return e(t,(e,t,n)=>{var a=r++;s(e,(e,t)=>{i[a]=t,n(e)})},e=>{a(e,i)})}function y(e){return e&&"number"==typeof e.length&&0<=e.length&&0==e.length%1}function m(e){function t(...t){if(null!==e){var n=e;e=null,n.apply(this,t)}}return Object.assign(t,e),t}function g(e){return e[Symbol.iterator]&&e[Symbol.iterator]()}function k(e){var t=-1,n=e.length;return function a(){return++t=t||u||l||(u=!0,e.next().then(({value:e,done:t})=>{if(!(d||l))return u=!1,t?(l=!0,void(0>=p&&a(null))):void(p++,n(e,c,r),c++,i())}).catch(s))}function r(e,t){return p-=1,d?void 0:e?s(e):!1===e?(l=!0,void(d=!0)):t===be||l&&0>=p?(l=!0,a(null)):void i()}function s(e){d||(u=!1,l=!0,a(e))}let l=!1,d=!1,u=!1,p=0,c=0;i()}function O(e,t,n){function a(e,t){!1===e&&(l=!0);!0===l||(e?n(e):(++r===s||t===be)&&n(null))}n=m(n);var i=0,r=0,{length:s}=e,l=!1;for(0===s&&n(null);i{t=e,n=a}),e}function A(e,t,n){function a(e,t){k.push(()=>l(e,t))}function i(){if(!f){if(0===k.length&&0===h)return n(null,o);for(;k.length&&he()),i()}function l(e,t){if(!y){var a=L((t,...a)=>{if(h--,!1===t)return void(f=!0);if(2>a.length&&([a]=a),t){var i={};if(Object.keys(o).forEach(e=>{i[e]=o[e]}),i[e]=a,y=!0,g=Object.create(null),f)return;n(t,i)}else o[e]=a,s(e)});h++;var i=c(t[t.length-1]);1{0==--S[e]&&v.push(e)});if(t!==p)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function u(t){var n=[];return Object.keys(e).forEach(a=>{const i=e[a];Array.isArray(i)&&0<=i.indexOf(t)&&n.push(a)}),n}"number"!=typeof t&&(n=t,t=null),n=m(n||b());var p=Object.keys(e).length;if(!p)return n(null);t||(t=p);var o={},h=0,f=!1,y=!1,g=Object.create(null),k=[],v=[],S={};return Object.keys(e).forEach(t=>{var n=e[t];if(!Array.isArray(n))return a(t,[n]),void v.push(t);var i=n.slice(0,n.length-1),s=i.length;return 0===s?(a(t,n),void v.push(t)):void(S[t]=s,i.forEach(l=>{if(!e[l])throw new Error("async.auto task `"+t+"` has a non-existent dependency `"+l+"` in "+i.join(", "));r(l,()=>{s--,0===s&&a(t,n)})}))}),d(),i(),n[Ce]}function I(e){let t="",n=0,a=e.indexOf("*/");for(;ne.replace(Ne,"").trim())}function j(e,t){var n={};return Object.keys(e).forEach(t=>{function a(e,t){var n=i.map(t=>e[t]);n.push(t),c(r)(...n)}var i,r=e[t],s=d(r),l=!s&&1===r.length||s&&0===r.length;if(Array.isArray(r))i=[...r],r=i.pop(),n[t]=i.concat(0{r(e,n),t(...a)};f[e].push(n)}function r(e,t){return e?t?void(f[e]=f[e].filter(e=>e!==t)):f[e]=[]:Object.keys(f).forEach(e=>f[e]=[])}function s(e,...t){f[e].forEach(e=>e(...t))}function l(e,t,n,a){function i(e,...t){return e?n?s(e):r():1>=t.length?r(t[0]):void r(t)}if(null!=a&&"function"!=typeof a)throw new Error("task callback must be a function");k.started=!0;var r,s,l=k._createTaskItem(e,n?i:a||i);if(t?k._tasks.unshift(l):k._tasks.push(l),y||(y=!0,_e(()=>{y=!1,k.process()})),n||!a)return new Promise((e,t)=>{r=e,s=t})}function d(e){return function(t,...n){o-=1;for(var a=0,r=e.length;as("drain")),!0)}if(null==t)t=1;else if(0===t)throw new RangeError("Concurrency must not be zero");var p=c(e),o=0,h=[];const f={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};var y=!1;const m=e=>t=>t?void(r(e),a(e,t)):new Promise((t,n)=>{i(e,(e,a)=>e?n(e):void t(a))});var g=!1,k={_tasks:new Ve,_createTaskItem(e,t){return{data:e,callback:t}},*[Symbol.iterator](){yield*k._tasks[Symbol.iterator]()},concurrency:t,payload:n,buffer:t/4,started:!1,paused:!1,push(e,t){return Array.isArray(e)?u(e)?void 0:e.map(e=>l(e,!1,!1,t)):l(e,!1,!1,t)},pushAsync(e,t){return Array.isArray(e)?u(e)?void 0:e.map(e=>l(e,!1,!0,t)):l(e,!1,!0,t)},kill(){r(),k._tasks.empty()},unshift(e,t){return Array.isArray(e)?u(e)?void 0:e.map(e=>l(e,!0,!1,t)):l(e,!0,!1,t)},unshiftAsync(e,t){return Array.isArray(e)?u(e)?void 0:e.map(e=>l(e,!0,!0,t)):l(e,!0,!0,t)},remove(e){k._tasks.remove(e)},process(){var e=Math.min;if(!g){for(g=!0;!k.paused&&o{t.apply(n,e.concat((e,...t)=>{a(e,t)}))},(e,t)=>a(e,...t)),a[Ce]}}function P(...e){return C(...e.reverse())}function R(...e){return function(...t){var n=t.pop();return n(null,...e)}}function z(e,t){return(n,a,i,r)=>{var s,l=!1;const d=c(i);n(a,(n,a,i)=>{d(n,(a,r)=>a||!1===a?i(a):e(r)&&!s?(l=!0,s=t(!0,n),i(null,be)):void i())},e=>e?r(e):void r(null,l?s:t(!1)))}}function N(e){return(t,...n)=>c(t)(...n,(t,...n)=>{"object"==typeof console&&(t?console.error&&console.error(t):console[e]&&n.forEach(t=>console[e](t)))})}function V(e,t,n){const a=c(t);return Xe(e,(...e)=>{const t=e.pop();a(...e,(e,n)=>t(e,!n))},n)}function Y(e){return(t,n,a)=>e(t,a)}function q(e){return d(e)?e:function(...t){var n=t.pop(),a=!0;t.push((...e)=>{a?_e(()=>n(...e)):n(...e)}),e.apply(this,t),a=!1}}function D(e,t,n,a){var r=Array(t.length);e(t,(e,t,a)=>{n(e,(e,n)=>{r[t]=!!n,a(e)})},e=>{if(e)return a(e);for(var n=[],s=0;s{n(e,(n,r)=>n?a(n):void(r&&i.push({index:t,value:e}),a(n)))},e=>e?a(e):void a(null,i.sort((e,t)=>e.index-t.index).map(e=>e.value)))}function U(e,t,n,a){var i=y(t)?D:Q;return i(e,t,c(n),a)}function G(e,t,n){return dt(e,1/0,t,n)}function W(e,t,n){return dt(e,1,t,n)}function H(e,t,n){return pt(e,1/0,t,n)}function J(e,t,n){return pt(e,1,t,n)}function K(e,t=e=>e){var a=Object.create(null),r=Object.create(null),s=c(e),l=n((e,n)=>{var d=t(...e);d in a?_e(()=>n(null,...a[d])):d in r?r[d].push(n):(r[d]=[n],s(...e,(e,...t)=>{e||(a[d]=t);var n=r[d];delete r[d];for(var s=0,u=n.length;s{n(e[0],t)},t,1)}function ee(e){return(e<<1)+1}function te(e){return(e+1>>1)-1}function ne(e,t){return e.priority===t.priority?e.pushCount({data:e,priority:t})):{data:e,priority:t}}var a=$(e,t),{push:i,pushAsync:r}=a;return a._tasks=new ht,a._createTaskItem=({data:e,priority:t},n)=>({data:e,priority:t,callback:n}),a.push=function(e,t=0,a){return i(n(e,t),a)},a.pushAsync=function(e,t=0,a){return r(n(e,t),a)},delete a.unshift,delete a.unshiftAsync,a}function ie(e,t,n,a){var i=[...e].reverse();return qe(i,t,n,a)}function re(e){var t=c(e);return n(function a(e,n){return e.push((e,...t)=>{let a={};if(e&&(a.error=e),0=t.length&&([i]=t),a.value=i}n(null,a)}),t.apply(this,e)})}function se(e){var t;return Array.isArray(e)?t=e.map(re):(t={},Object.keys(e).forEach(n=>{t[n]=re.call(this,e[n])})),t}function le(e,t,n,a){const i=c(n);return U(e,t,(e,t)=>{i(e,(e,n)=>{t(e,!n)})},a)}function de(e){return function(){return e}}function ue(e,t,n){function a(){r((e,...t)=>{!1===e||(e&&s++arguments.length&&"function"==typeof e?(n=t||b(),t=e):(pe(i,e),n=n||b()),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var r=c(t),s=1;return a(),n[Ce]}function pe(e,n){if("object"==typeof n)e.times=+n.times||kt,e.intervalFunc="function"==typeof n.interval?n.interval:de(+n.interval||vt),e.errorFilter=n.errorFilter;else if("number"==typeof n||"string"==typeof n)e.times=+n||kt;else throw new Error("Invalid arguments for async.retry")}function ce(e,t){t||(t=e,e=null);let a=e&&e.arity||t.length;d(t)&&(a+=1);var i=c(t);return n((t,n)=>{function r(e){i(...t,e)}return(t.length{function s(){var t=e.name||"anonymous",n=new Error("Callback function \""+t+"\" timed out.");n.code="ETIMEDOUT",a&&(n.info=a),d=!0,r(n)}var l,d=!1;n.push((...e)=>{d||(r(...e),clearTimeout(l))}),l=setTimeout(s,t),i(...n)})}function fe(e){for(var t=Array(e);e--;)t[e]=e;return t}function ye(e,t,n,a){var i=c(n);return De(fe(e),t,i,a)}function me(e,t,n){return ye(e,1/0,t,n)}function ge(e,t,n){return ye(e,1,t,n)}function ke(e,t,n,a){3>=arguments.length&&"function"==typeof t&&(a=n,n=t,t=Array.isArray(e)?[]:{}),a=m(a||b());var i=c(n);return Me(e,(e,n,a)=>{i(t,e,n,a)},e=>a(e,t)),a[Ce]}function ve(e){return(...t)=>(e.unmemoized||e)(...t)}function Se(e,t,n){const a=c(e);return _t(e=>a((t,n)=>e(t,!n)),t,n)}var xe,Le="function"==typeof queueMicrotask&&queueMicrotask,Ee="function"==typeof setImmediate&&setImmediate,Oe="object"==typeof process&&"function"==typeof process.nextTick;xe=Le?queueMicrotask:Ee?setImmediate:Oe?process.nextTick:a;var _e=i(xe);const be={};var Ae=e=>(t,n,a)=>{function i(e,t){if(!d)if(c-=1,e)l=!0,a(e);else if(!1===e)l=!0,d=!0;else{if(t===be||l&&0>=c)return l=!0,a(null);o||r()}}function r(){for(o=!0;c=c&&a(null));c+=1,n(t.value,t.key,L(i))}o=!1}if(a=m(a),0>=e)throw new RangeError("concurrency limit cannot be less than 1");if(!t)return a(null);if(u(t))return E(t,e,n,a);if(p(t))return E(t[Symbol.asyncIterator](),e,n,a);var s=x(t),l=!1,d=!1,c=0,o=!1;r()},Ie=o(function i(e,t,n,a){return Ae(t)(e,c(n),a)},4),Me=o(function a(e,t,n){var i=y(e)?O:_;return i(e,c(t),n)},3),je=o(function a(e,t,n){return f(Me,e,t,n)},3),we=h(je),Be=o(function a(e,t,n){return Ie(e,1,t,n)},3),Te=o(function a(e,t,n){return f(Be,e,t,n)},3),Fe=h(Te);const Ce=Symbol("promiseCallback");var Pe=/^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/,Re=/^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/,ze=/,/,Ne=/(=.+)?(\s*)$/;class Ve{constructor(){this.head=this.tail=null,this.length=0}removeLink(e){return e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=e.next=null,this.length-=1,e}empty(){for(;this.head;)this.shift();return this}insertAfter(e,t){t.prev=e,t.next=e.next,e.next?e.next.prev=t:this.tail=t,e.next=t,this.length+=1}insertBefore(e,t){t.prev=e.prev,t.next=e,e.prev?e.prev.next=t:this.head=t,e.prev=t,this.length+=1}unshift(e){this.head?this.insertBefore(this.head,e):w(this,e)}push(e){this.tail?this.insertAfter(this.tail,e):w(this,e)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){for(var e=this.head;e;)yield e.data,e=e.next}remove(e){for(var t=this.head;t;){var{next:n}=t;e(t)&&this.removeLink(t),t=n}return this}}var Ye,qe=o(function i(e,t,n,a){a=m(a);var r=c(n);return Be(e,(e,n,a)=>{r(t,e,(e,n)=>{t=n,a(e)})},e=>a(e,t))},4),De=o(function i(e,t,n,a){return f(Ae(t),e,n,a)},4),Qe=o(function i(e,t,n,a){var r=c(n);return De(e,t,(e,t)=>{r(e,(e,...n)=>e?t(e):t(e,n))},(e,t)=>{for(var n=[],r=0;re,(e,t)=>t)(Me,e,t,n)},3),He=o(function i(e,t,n,a){return z(e=>e,(e,t)=>t)(Ae(t),e,n,a)},4),Je=o(function a(e,t,n){return z(e=>e,(e,t)=>t)(Ae(1),e,t,n)},3),Ke=N("dir"),Xe=o(function a(e,t,n){function i(e,...t){return e?n(e):void(!1===e||(s=t,d(...t,r)))}function r(e,t){return e?n(e):!1===e?void 0:t?void l(i):n(null,...s)}n=L(n);var s,l=c(e),d=c(t);return r(null,!0)},3),Ze=o(function a(e,t,n){return Me(e,Y(c(t)),n)},3),$e=o(function i(e,t,n,a){return Ae(t)(e,Y(c(n)),a)},4),et=o(function a(e,t,n){return $e(e,1,t,n)},3),tt=o(function a(e,t,n){return z(e=>!e,e=>!e)(Me,e,t,n)},3),nt=o(function i(e,t,n,a){return z(e=>!e,e=>!e)(Ae(t),e,n,a)},4),at=o(function a(e,t,n){return z(e=>!e,e=>!e)(Be,e,t,n)},3),it=o(function a(e,t,n){return U(Me,e,t,n)},3),rt=o(function i(e,t,n,a){return U(Ae(t),e,n,a)},4),st=o(function a(e,t,n){return U(Be,e,t,n)},3),lt=o(function n(e,t){function a(e){return e?i(e):void(!1===e||r(a))}var i=L(t),r=c(q(e));return a()},2),dt=o(function i(e,t,n,a){var r=c(n);return De(e,t,(e,t)=>{r(e,(n,a)=>n?t(n):t(n,{key:a,val:e}))},(e,t)=>{for(var n={},{hasOwnProperty:r}=Object.prototype,s=0;s{s(e,t,(e,a)=>e?n(e):void(r[t]=a,n(e)))},e=>a(e,r))},4);Ye=Oe?process.nextTick:Ee?setImmediate:a;var ct=i(Ye),ot=o((e,t,n)=>{var a=y(t)?[]:{};e(t,(e,t,n)=>{c(e)((e,...i)=>{2>i.length&&([i]=i),a[t]=i,n(e)})},e=>n(e,a))},3);class ht{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(e){for(let n;0e)(Me,e,t,n)},3),xt=o(function i(e,t,n,a){return z(Boolean,e=>e)(Ae(t),e,n,a)},4),Lt=o(function a(e,t,n){return z(Boolean,e=>e)(Be,e,t,n)},3),Et=o(function a(e,t,n){function i(e,t){var n=e.criteria,a=t.criteria;return na?1:0}var r=c(t);return je(e,(e,t)=>{r(e,(n,a)=>n?t(n):void t(n,{value:e,criteria:a}))},(e,t)=>e?n(e):void n(null,t.sort(i).map(e=>e.value)))},3),Ot=o(function n(e,t){var a,i=null;return et(e,(e,t)=>{c(e)((e,...n)=>!1===e?t(e):void(2>n.length?[a]=n:a=n,i=e,t(e?null:{})))},()=>t(i,a))}),_t=o(function a(e,t,n){function i(e,...t){if(e)return n(e);d=t;!1===e||l(r)}function r(e,t){return e?n(e):!1===e?void 0:t?void s(i):n(null,...d)}n=L(n);var s=c(t),l=c(e),d=[];return l(r)},3),bt=o(function n(e,t){function a(t){var n=c(e[r++]);n(...t,L(i))}function i(n,...i){return!1===n?void 0:n||r===e.length?t(n,...i):void a(i)}if(t=m(t),!Array.isArray(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var r=0;a([])});e.all=tt,e.allLimit=nt,e.allSeries=at,e.any=St,e.anyLimit=xt,e.anySeries=Lt,e.apply=t,e.applyEach=we,e.applyEachSeries=Fe,e.asyncify=r,e.auto=A,e.autoInject=j,e.cargo=T,e.cargoQueue=F,e.compose=P,e.concat=Ue,e.concatLimit=Qe,e.concatSeries=Ge,e.constant=R,e.default={apply:t,applyEach:we,applyEachSeries:Fe,asyncify:r,auto:A,autoInject:j,cargo:T,cargoQueue:F,compose:P,concat:Ue,concatLimit:Qe,concatSeries:Ge,constant:R,detect:We,detectLimit:He,detectSeries:Je,dir:Ke,doUntil:V,doWhilst:Xe,each:Ze,eachLimit:$e,eachOf:Me,eachOfLimit:Ie,eachOfSeries:Be,eachSeries:et,ensureAsync:q,every:tt,everyLimit:nt,everySeries:at,filter:it,filterLimit:rt,filterSeries:st,forever:lt,groupBy:G,groupByLimit:dt,groupBySeries:W,log:ut,map:je,mapLimit:De,mapSeries:Te,mapValues:H,mapValuesLimit:pt,mapValuesSeries:J,memoize:K,nextTick:ct,parallel:X,parallelLimit:Z,priorityQueue:ae,queue:$,race:ft,reduce:qe,reduceRight:ie,reflect:re,reflectAll:se,reject:yt,rejectLimit:mt,rejectSeries:gt,retry:ue,retryable:ce,seq:C,series:oe,setImmediate:_e,some:St,someLimit:xt,someSeries:Lt,sortBy:Et,timeout:he,times:me,timesLimit:ye,timesSeries:ge,transform:ke,tryEach:Ot,unmemoize:ve,until:Se,waterfall:bt,whilst:_t,all:tt,allLimit:nt,allSeries:at,any:St,anyLimit:xt,anySeries:Lt,find:We,findLimit:He,findSeries:Je,flatMap:Ue,flatMapLimit:Qe,flatMapSeries:Ge,forEach:Ze,forEachSeries:et,forEachLimit:$e,forEachOf:Me,forEachOfSeries:Be,forEachOfLimit:Ie,inject:qe,foldl:qe,foldr:ie,select:it,selectLimit:rt,selectSeries:st,wrapSync:r,during:_t,doDuring:Xe},e.detect=We,e.detectLimit=He,e.detectSeries=Je,e.dir=Ke,e.doDuring=Xe,e.doUntil=V,e.doWhilst=Xe,e.during=_t,e.each=Ze,e.eachLimit=$e,e.eachOf=Me,e.eachOfLimit=Ie,e.eachOfSeries=Be,e.eachSeries=et,e.ensureAsync=q,e.every=tt,e.everyLimit=nt,e.everySeries=at,e.filter=it,e.filterLimit=rt,e.filterSeries=st,e.find=We,e.findLimit=He,e.findSeries=Je,e.flatMap=Ue,e.flatMapLimit=Qe,e.flatMapSeries=Ge,e.foldl=qe,e.foldr=ie,e.forEach=Ze,e.forEachLimit=$e,e.forEachOf=Me,e.forEachOfLimit=Ie,e.forEachOfSeries=Be,e.forEachSeries=et,e.forever=lt,e.groupBy=G,e.groupByLimit=dt,e.groupBySeries=W,e.inject=qe,e.log=ut,e.map=je,e.mapLimit=De,e.mapSeries=Te,e.mapValues=H,e.mapValuesLimit=pt,e.mapValuesSeries=J,e.memoize=K,e.nextTick=ct,e.parallel=X,e.parallelLimit=Z,e.priorityQueue=ae,e.queue=$,e.race=ft,e.reduce=qe,e.reduceRight=ie,e.reflect=re,e.reflectAll=se,e.reject=yt,e.rejectLimit=mt,e.rejectSeries=gt,e.retry=ue,e.retryable=ce,e.select=it,e.selectLimit=rt,e.selectSeries=st,e.seq=C,e.series=oe,e.setImmediate=_e,e.some=St,e.someLimit=xt,e.someSeries=Lt,e.sortBy=Et,e.timeout=he,e.times=me,e.timesLimit=ye,e.timesSeries=ge,e.transform=ke,e.tryEach=Ot,e.unmemoize=ve,e.until=Se,e.waterfall=bt,e.whilst=_t,e.wrapSync=r,Object.defineProperty(e,"__esModule",{value:!0})}); \ No newline at end of file diff --git a/dist/async.min.map b/dist/async.min.map deleted file mode 100644 index 121df188d..000000000 --- a/dist/async.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"build/dist/async.min.js","sources":["build/dist/async.js"],"names":["global","factory","exports","module","define","amd","async","this","apply","func","thisArg","args","length","call","baseRest","start","nativeMax","undefined","arguments","index","array","Array","otherArgs","initialParams","fn","callback","pop","applyEach$1","eachfn","fns","go","that","cb","concat","baseProperty","key","object","isObject","value","type","isFunction","tag","objectToString","funcTag","genTag","isLength","MAX_SAFE_INTEGER","isArrayLike","getLength","noop","once","callFn","getIterator","coll","iteratorSymbol","overArg","transform","arg","baseHas","hasOwnProperty","getPrototype","baseTimes","n","iteratee","result","isObjectLike","isArrayLikeObject","isArguments","hasOwnProperty$1","propertyIsEnumerable","objectToString$1","argsTag","isString","isArray","objectToString$2","stringTag","indexKeys","String","isIndex","MAX_SAFE_INTEGER$1","reIsUint","test","isPrototype","Ctor","constructor","proto","prototype","objectProto$4","keys","isProto","baseKeys","indexes","skipIndexes","push","createArrayIterator","i","len","createES2015Iterator","iterator","item","next","done","createObjectIterator","obj","okeys","onlyOnce","Error","_eachOfLimit","limit","iterateeCallback","err","running","replenish","elem","nextElem","eachOfLimit","doLimit","iterable","eachOfArrayLike","iteratorCallback","completed","eachOf","eachOfImplementation","eachOfGeneric","doParallel","_asyncMap","arr","results","counter","_","v","doParallelLimit","asyncify","e","then","message","arrayEach","createBaseFor","fromRight","keysFunc","Object","props","baseForOwn","baseFor","baseFindIndex","predicate","fromIndex","baseIsNaN","baseIndexOf","auto","tasks","concurrency","enqueueTask","task","readyTasks","runTask","processQueue","runningTasks","run","shift","addListener","taskName","taskListeners","listeners","taskComplete","hasError","taskCallback","safeResults","val","rkey","taskFn","checkForDeadlocks","currentTask","readyToCheck","getDependents","dependent","uncheckedDependencies","numTasks","keys$$","dependencies","slice","remainingDependencies","dependencyName","join","arrayMap","copyArray","source","isSymbol","objectToString$3","symbolTag","baseToString","symbolToString","INFINITY","baseSlice","end","castSlice","charsEndIndex","strSymbols","chrSymbols","charsStartIndex","stringToArray","string","match","reComplexSymbol","toString","trim","chars","guard","replace","reTrim","parseParams","STRIP_COMMENTS","FN_ARGS","split","FN_ARG_SPLIT","map","FN_ARG","autoInject","newTasks","newTask","taskCb","newArgs","params","name","fallback","setTimeout","wrap","defer","DLL","head","tail","setInitial","dll","node","queue","worker","payload","_insert","data","insertAtFront","q","started","idle","setImmediate$1","drain","_tasks","unshift","process","_next","workers","workersList","splice","error","buffer","unsaturated","saturated","empty","paused","kill","l","Math","min","pause","resume","resumeCount","w","cargo","reduce","memo","eachOfSeries","x","concat$1","y","doSeries","identity","_createTester","check","getResult","wrappedIteratee","_findGetResult","consoleFunc","console","doDuring","truth","doWhilst","doUntil","during","_withoutIndex","eachLimit","eachLimit$1","ensureAsync","sync","innerArgs","notId","_filter","sort","a","b","forever","errback","mapValuesLimit","newObj","has","memoize","hasher","create","queues","memoized","unmemoized","_parallel","parallelLimit","parallelLimit$1","queue$1","items","priorityQueue","priority","nextNode","insertBefore","race","TypeError","reduceRight","reversed","reverse","reflect","reflectCallback","cbArgs","reject$1","reflectAll","constant$1","retry","opts","parseTimes","acc","t","times","DEFAULT_TIMES","intervalFunc","interval","DEFAULT_INTERVAL","retryAttempt","attempt","options","retryable","series","sortBy","comparator","left","right","criteria","timeout","asyncFn","milliseconds","info","injectedCallback","timedOut","originalCallback","clearTimeout","timer","timeoutCallback","code","origCallback","baseRange","step","nativeMax$1","nativeCeil","timeLimit","count","mapLimit","accumulator","k","unmemoize","whilst","until","waterfall","nextTask","taskIndex","_defer","max","objectProto","Symbol","nativeGetPrototype","getPrototypeOf","objectProto$1","nativeKeys","objectProto$2","objectProto$3","Infinity","applyEach","mapSeries","applyEachSeries","apply$1","callArgs","freeGlobal","freeSelf","self","root","Function","Symbol$1","objectProto$5","symbolProto","rsAstralRange","rsComboMarksRange","rsComboSymbolsRange","rsVarRange","rsAstral","rsCombo","rsFitz","rsModifier","rsNonAstral","rsRegional","rsSurrPair","rsZWJ","reOptMod","rsOptVar","rsOptJoin","rsSeq","rsSymbol","RegExp","hasSetImmediate","setImmediate","hasNextTick","nextTick","removeLink","prev","insertAfter","newNode","_defer$1","seq","functions","newargs","nextargs","compose","concatSeries","constant","values","ignoredArgs","detect","detectLimit","detectSeries","dir","eachSeries","every","everyLimit","everySeries","filter","filterLimit","filterSeries","log","mapValues","mapValuesSeries","reject","rejectLimit","rejectSeries","some","Boolean","someLimit","someSeries","ceil","timesSeries","each","parallel","timesLimit","all","any","forEach","forEachSeries","forEachLimit","forEachOf","forEachOfSeries","forEachOfLimit","inject","foldl","foldr","select","selectLimit","selectSeries","wrapSync","allLimit","allSeries","anyLimit","anySeries","find","findLimit","findSeries"],"mappings":"CAAC,SAAUA,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBF,EAAQC,SACrD,kBAAXE,SAAyBA,OAAOC,IAAMD,QAAQ,WAAYH,GAChEA,EAASD,EAAOM,MAAQN,EAAOM,YAChCC,KAAM,SAAUL,GAAW,YAY3B,SAASM,GAAMC,EAAMC,EAASC,GAC5B,OAAQA,EAAKC,QACX,IAAK,GAAG,MAAOH,GAAKI,KAAKH,EACzB,KAAK,GAAG,MAAOD,GAAKI,KAAKH,EAASC,EAAK,GACvC,KAAK,GAAG,MAAOF,GAAKI,KAAKH,EAASC,EAAK,GAAIA,EAAK,GAChD,KAAK,GAAG,MAAOF,GAAKI,KAAKH,EAASC,EAAK,GAAIA,EAAK,GAAIA,EAAK,IAE3D,MAAOF,GAAKD,MAAME,EAASC,GAc7B,QAASG,GAASL,EAAMM,GAEtB,MADAA,GAAQC,GAAoBC,SAAVF,EAAuBN,EAAKG,OAAS,EAAKG,EAAO,GAC5D,WAML,IALA,GAAIJ,GAAOO,UACPC,EAAQ,GACRP,EAASI,GAAUL,EAAKC,OAASG,EAAO,GACxCK,EAAQC,MAAMT,KAETO,EAAQP,GACfQ,EAAMD,GAASR,EAAKI,EAAQI,EAE9BA,GAAQ,EAER,KADA,GAAIG,GAAYD,MAAMN,EAAQ,KACrBI,EAAQJ,GACfO,EAAUH,GAASR,EAAKQ,EAG1B,OADAG,GAAUP,GAASK,EACZZ,EAAMC,EAAMF,KAAMe,IAI7B,QAASC,GAAeC,GACpB,MAAOV,GAAS,SAAUH,GACtB,GAAIc,GAAWd,EAAKe,KACpBF,GAAGX,KAAKN,KAAMI,EAAMc,KAI5B,QAASE,GAAYC,GACjB,MAAOd,GAAS,SAAUe,EAAKlB,GAC3B,GAAImB,GAAKP,EAAc,SAAUZ,EAAMc,GACnC,GAAIM,GAAOxB,IACX,OAAOqB,GAAOC,EAAK,SAAUL,EAAIQ,GAC7BR,EAAGhB,MAAMuB,EAAMpB,EAAKsB,QAAQD,MAC7BP,IAEP,OAAId,GAAKC,OACEkB,EAAGtB,MAAMD,KAAMI,GAEfmB,IAYnB,QAASI,GAAaC,GACpB,MAAO,UAASC,GACd,MAAiB,OAAVA,EAAiBnB,OAAYmB,EAAOD,IA0C/C,QAASE,GAASC,GAChB,GAAIC,SAAcD,EAClB,SAASA,IAAkB,UAARC,GAA4B,YAARA,GAgCzC,QAASC,GAAWF,GAIlB,GAAIG,GAAMJ,EAASC,GAASI,GAAe7B,KAAKyB,GAAS,EACzD,OAAOG,IAAOE,IAAWF,GAAOG,GAiClC,QAASC,GAASP,GAChB,MAAuB,gBAATA,IACZA,EAAQ,IAAMA,EAAQ,GAAK,GAAcQ,IAATR,EA4BpC,QAASS,GAAYT,GACnB,MAAgB,OAATA,GAAiBO,EAASG,GAAUV,MAAYE,EAAWF,GAepE,QAASW,MAIT,QAASC,GAAK1B,GACV,MAAO,YACH,GAAW,OAAPA,EAAJ,CACA,GAAI2B,GAAS3B,CACbA,GAAK,KACL2B,EAAO3C,MAAMD,KAAMW,aAM3B,QAASkC,GAAaC,GAClB,MAAOC,KAAkBD,EAAKC,KAAmBD,EAAKC,MAW1D,QAASC,GAAQ9C,EAAM+C,GACrB,MAAO,UAASC,GACd,MAAOhD,GAAK+C,EAAUC,KA8B1B,QAASC,GAAQtB,EAAQD,GAIvB,MAAiB,OAAVC,IACJuB,GAAe9C,KAAKuB,EAAQD,IACT,gBAAVC,IAAsBD,IAAOC,IAAmC,OAAzBwB,GAAaxB,IAyBlE,QAASyB,GAAUC,EAAGC,GAIpB,IAHA,GAAI5C,GAAQ,GACR6C,EAAS3C,MAAMyC,KAEV3C,EAAQ2C,GACfE,EAAO7C,GAAS4C,EAAS5C,EAE3B,OAAO6C,GA2BT,QAASC,GAAa3B,GACpB,QAASA,GAAyB,gBAATA,GA4B3B,QAAS4B,GAAkB5B,GACzB,MAAO2B,GAAa3B,IAAUS,EAAYT,GAwC5C,QAAS6B,GAAY7B,GAEnB,MAAO4B,GAAkB5B,IAAU8B,GAAiBvD,KAAKyB,EAAO,aAC5D+B,GAAqBxD,KAAKyB,EAAO,WAAagC,GAAiBzD,KAAKyB,IAAUiC,IA0DpF,QAASC,GAASlC,GAChB,MAAuB,gBAATA,KACVmC,GAAQnC,IAAU2B,EAAa3B,IAAUoC,GAAiB7D,KAAKyB,IAAUqC,GAW/E,QAASC,GAAUxC,GACjB,GAAIxB,GAASwB,EAASA,EAAOxB,OAASK,MACtC,OAAI4B,GAASjC,KACR6D,GAAQrC,IAAWoC,EAASpC,IAAW+B,EAAY/B,IAC/CyB,EAAUjD,EAAQiE,QAEpB,KAiBT,QAASC,GAAQxC,EAAO1B,GAEtB,MADAA,GAAmB,MAAVA,EAAiBmE,GAAqBnE,IACtCA,IACU,gBAAT0B,IAAqB0C,GAASC,KAAK3C,KAC1CA,EAAQ,IAAMA,EAAQ,GAAK,GAAa1B,EAAR0B,EAarC,QAAS4C,GAAY5C,GACnB,GAAI6C,GAAO7C,GAASA,EAAM8C,YACtBC,EAAwB,kBAARF,IAAsBA,EAAKG,WAAcC,EAE7D,OAAOjD,KAAU+C,EA+BnB,QAASG,GAAKpD,GACZ,GAAIqD,GAAUP,EAAY9C,EAC1B,KAAMqD,IAAW1C,EAAYX,GAC3B,MAAOsD,IAAStD,EAElB,IAAIuD,GAAUf,EAAUxC,GACpBwD,IAAgBD,EAChB3B,EAAS2B,MACT/E,EAASoD,EAAOpD,MAEpB,KAAK,GAAIuB,KAAOC,IACVsB,EAAQtB,EAAQD,IACdyD,IAAuB,UAAPzD,GAAmB2C,EAAQ3C,EAAKvB,KAChD6E,GAAkB,eAAPtD,GACf6B,EAAO6B,KAAK1D,EAGhB,OAAO6B,GAGT,QAAS8B,GAAoBzC,GACzB,GAAI0C,GAAI,GACJC,EAAM3C,EAAKzC,MACf,OAAO,YACH,QAASmF,EAAIC,GAAQ1D,MAAOe,EAAK0C,GAAI5D,IAAK4D,GAAM,MAIxD,QAASE,GAAqBC,GAC1B,GAAIH,GAAI,EACR,OAAO,YACH,GAAII,GAAOD,EAASE,MACpB,OAAID,GAAKE,KAAa,MACtBN,KACSzD,MAAO6D,EAAK7D,MAAOH,IAAK4D,KAIzC,QAASO,GAAqBC,GAC1B,GAAIC,GAAQhB,EAAKe,GACbR,EAAI,GACJC,EAAMQ,EAAM5F,MAChB,OAAO,YACH,GAAIuB,GAAMqE,IAAQT,EAClB,OAAWC,GAAJD,GAAYzD,MAAOiE,EAAIpE,GAAMA,IAAKA,GAAQ,MAIzD,QAAS+D,GAAS7C,GACd,GAAIN,EAAYM,GACZ,MAAOyC,GAAoBzC,EAG/B,IAAI6C,GAAW9C,EAAYC,EAC3B,OAAO6C,GAAWD,EAAqBC,GAAYI,EAAqBjD,GAG5E,QAASoD,GAASjF,GACd,MAAO,YACH,GAAW,OAAPA,EAAa,KAAM,IAAIkF,OAAM,+BACjC,IAAIvD,GAAS3B,CACbA,GAAK,KACL2B,EAAO3C,MAAMD,KAAMW,YAI3B,QAASyF,GAAaC,GAClB,MAAO,UAAUL,EAAKxC,EAAUtC,GAS5B,QAASoF,GAAiBC,GAEtB,GADAC,GAAW,EACPD,EACAT,GAAO,EACP5E,EAASqF,OACN,CAAA,GAAIT,GAAmB,GAAXU,EACf,MAAOtF,GAAS,KAEhBuF,MAIR,QAASA,KACL,KAAiBJ,EAAVG,IAAoBV,GAAM,CAC7B,GAAIY,GAAOC,GACX,IAAa,OAATD,EAKA,MAJAZ,IAAO,OACQ,GAAXU,GACAtF,EAAS,MAIjBsF,IAAW,EACXhD,EAASkD,EAAK3E,MAAO2E,EAAK9E,IAAKsE,EAASI,KA9BhD,GADApF,EAAWyB,EAAKzB,GAAYwB,GACf,GAAT2D,IAAeL,EACf,MAAO9E,GAAS,KAEpB,IAAIyF,GAAWhB,EAASK,GACpBF,GAAO,EACPU,EAAU,CA6BdC,MA0BR,QAASG,GAAY9D,EAAMuD,EAAO7C,EAAUtC,GAC1CkF,EAAaC,GAAOvD,EAAMU,EAAUtC,GAGtC,QAAS2F,GAAQ5F,EAAIoF,GACjB,MAAO,UAAUS,EAAUtD,EAAUtC,GACjC,MAAOD,GAAG6F,EAAUT,EAAO7C,EAAUtC,IAK7C,QAAS6F,GAAgBjE,EAAMU,EAAUtC,GASrC,QAAS8F,GAAiBT,GAClBA,EACArF,EAASqF,KACAU,IAAc5G,GACvBa,EAAS,MAZjBA,EAAWyB,EAAKzB,GAAYwB,EAC5B,IAAI9B,GAAQ,EACRqG,EAAY,EACZ5G,EAASyC,EAAKzC,MAalB,KAZe,IAAXA,GACAa,EAAS,MAWEb,EAARO,EAAgBA,IACnB4C,EAASV,EAAKlC,GAAQA,EAAOsF,EAASc,IAgD9C,QAASE,GAAQpE,EAAMU,EAAUtC,GAC7B,GAAIiG,GAAuB3E,EAAYM,GAAQiE,EAAkBK,EACjED,GAAqBrE,EAAMU,EAAUtC,GAGzC,QAASmG,GAAWpG,GAChB,MAAO,UAAU+E,EAAKxC,EAAUtC,GAC5B,MAAOD,GAAGiG,EAAQlB,EAAKxC,EAAUtC,IAIzC,QAASoG,GAAUjG,EAAQkG,EAAK/D,EAAUtC,GACtCA,EAAWyB,EAAKzB,GAAYwB,GAC5B6E,EAAMA,KACN,IAAIC,MACAC,EAAU,CAEdpG,GAAOkG,EAAK,SAAUxF,EAAO2F,EAAGxG,GAC5B,GAAIN,GAAQ6G,GACZjE,GAASzB,EAAO,SAAUwE,EAAKoB,GAC3BH,EAAQ5G,GAAS+G,EACjBzG,EAASqF,MAEd,SAAUA,GACTrF,EAASqF,EAAKiB,KA2EtB,QAASI,GAAgB3G,GACrB,MAAO,UAAU+E,EAAKK,EAAO7C,EAAUtC,GACnC,MAAOD,GAAGmF,EAAaC,GAAQL,EAAKxC,EAAUtC,IA2KtD,QAAS2G,GAAS3H,GACd,MAAOc,GAAc,SAAUZ,EAAMc,GACjC,GAAIuC,EACJ,KACIA,EAASvD,EAAKD,MAAMD,KAAMI,GAC5B,MAAO0H,GACL,MAAO5G,GAAS4G,GAGhBhG,EAAS2B,IAAkC,kBAAhBA,GAAOsE,KAClCtE,EAAOsE,KAAK,SAAUhG,GAClBb,EAAS,KAAMa,IAChB,SAAUwE,GACTrF,EAASqF,EAAIyB,QAAUzB,EAAM,GAAIJ,OAAMI,MAG3CrF,EAAS,KAAMuC,KAc3B,QAASwE,GAAUpH,EAAO2C,GAIxB,IAHA,GAAI5C,GAAQ,GACRP,EAASQ,EAAQA,EAAMR,OAAS,IAE3BO,EAAQP,GACXmD,EAAS3C,EAAMD,GAAQA,EAAOC,MAAW,IAI/C,MAAOA,GAUT,QAASqH,GAAcC,GACrB,MAAO,UAAStG,EAAQ2B,EAAU4E,GAMhC,IALA,GAAIxH,GAAQ,GACRkG,EAAWuB,OAAOxG,GAClByG,EAAQF,EAASvG,GACjBxB,EAASiI,EAAMjI,OAEZA,KAAU,CACf,GAAIuB,GAAM0G,EAAMH,EAAY9H,IAAWO,EACvC,IAAI4C,EAASsD,EAASlF,GAAMA,EAAKkF,MAAc,EAC7C,MAGJ,MAAOjF,IAyBX,QAAS0G,GAAW1G,EAAQ2B,GAC1B,MAAO3B,IAAU2G,GAAQ3G,EAAQ2B,EAAUyB,GAc7C,QAASwD,GAAc5H,EAAO6H,EAAWC,EAAWR,GAIlD,IAHA,GAAI9H,GAASQ,EAAMR,OACfO,EAAQ+H,GAAaR,EAAY,EAAI,IAEjCA,EAAYvH,MAAYA,EAAQP,GACtC,GAAIqI,EAAU7H,EAAMD,GAAQA,EAAOC,GACjC,MAAOD,EAGX,OAAO,GAUT,QAASgI,GAAU7G,GACjB,MAAOA,KAAUA,EAYnB,QAAS8G,GAAYhI,EAAOkB,EAAO4G,GACjC,GAAI5G,IAAUA,EACZ,MAAO0G,GAAc5H,EAAO+H,EAAWD,EAKzC,KAHA,GAAI/H,GAAQ+H,EAAY,EACpBtI,EAASQ,EAAMR,SAEVO,EAAQP,GACf,GAAIQ,EAAMD,KAAWmB,EACnB,MAAOnB,EAGX,OAAO,GAkFT,QAASkI,GAAMC,EAAOC,EAAa9H,GA8D/B,QAAS+H,GAAYrH,EAAKsH,GACtBC,EAAW7D,KAAK,WACZ8D,EAAQxH,EAAKsH,KAIrB,QAASG,KACL,GAA0B,IAAtBF,EAAW9I,QAAiC,IAAjBiJ,EAC3B,MAAOpI,GAAS,KAAMsG,EAE1B,MAAO2B,EAAW9I,QAAyB2I,EAAfM,GAA4B,CACpD,GAAIC,GAAMJ,EAAWK,OACrBD,MAIR,QAASE,GAAYC,EAAUzI,GAC3B,GAAI0I,GAAgBC,EAAUF,EACzBC,KACDA,EAAgBC,EAAUF,OAG9BC,EAAcrE,KAAKrE,GAGvB,QAAS4I,GAAaH,GAClB,GAAIC,GAAgBC,EAAUF,MAC9BzB,GAAU0B,EAAe,SAAU1I,GAC/BA,MAEJoI,IAGJ,QAASD,GAAQxH,EAAKsH,GAClB,IAAIY,EAAJ,CAEA,GAAIC,GAAe7D,EAAS3F,EAAS,SAAUgG,EAAKnG,GAKhD,GAJAkJ,IACIlJ,EAAKC,QAAU,IACfD,EAAOA,EAAK,IAEZmG,EAAK,CACL,GAAIyD,KACJzB,GAAWf,EAAS,SAAUyC,EAAKC,GAC/BF,EAAYE,GAAQD,IAExBD,EAAYpI,GAAOxB,EACnB0J,GAAW,EACXF,KAEA1I,EAASqF,EAAKyD,OAEdxC,GAAQ5F,GAAOxB,EACfyJ,EAAajI,KAIrB0H,IACA,IAAIa,GAASjB,EAAKA,EAAK7I,OAAS,EAC5B6I,GAAK7I,OAAS,EACd8J,EAAO3C,EAASuC,GAEhBI,EAAOJ,IAIf,QAASK,KAML,IAFA,GAAIC,GACA5C,EAAU,EACP6C,EAAajK,QAChBgK,EAAcC,EAAanJ,MAC3BsG,IACAQ,EAAUsC,EAAcF,GAAc,SAAUG,GACD,MAArCC,EAAsBD,IACxBF,EAAahF,KAAKkF,IAK9B,IAAI/C,IAAYiD,EACZ,KAAM,IAAIvE,OAAM,iEAIxB,QAASoE,GAAcb,GACnB,GAAIjG,KAMJ,OALA8E,GAAWQ,EAAO,SAAUG,EAAMtH,GAC1BsC,GAAQgF,IAASL,EAAYK,EAAMQ,EAAU,IAAM,GACnDjG,EAAO6B,KAAK1D,KAGb6B,EA3JgB,kBAAhBuF,KAEP9H,EAAW8H,EACXA,EAAc,MAElB9H,EAAWyB,EAAKzB,GAAYwB,EAC5B,IAAIiI,GAAS1F,EAAK8D,GACd2B,EAAWC,EAAOtK,MACtB,KAAKqK,EACD,MAAOxJ,GAAS,KAEf8H,KACDA,EAAc0B,EAGlB,IAAIlD,MACA8B,EAAe,EACfQ,GAAW,EAEXF,KAEAT,KAGAmB,KAEAG,IAEJlC,GAAWQ,EAAO,SAAUG,EAAMtH,GAC9B,IAAKsC,GAAQgF,GAIT,MAFAD,GAAYrH,GAAMsH,QAClBoB,GAAahF,KAAK1D,EAItB,IAAIgJ,GAAe1B,EAAK2B,MAAM,EAAG3B,EAAK7I,OAAS,GAC3CyK,EAAwBF,EAAavK,MACzC,OAA8B,KAA1ByK,GACA7B,EAAYrH,EAAKsH,OACjBoB,GAAahF,KAAK1D,KAGtB6I,EAAsB7I,GAAOkJ,MAE7B7C,GAAU2C,EAAc,SAAUG,GAC9B,IAAKhC,EAAMgC,GACP,KAAM,IAAI5E,OAAM,oBAAsBvE,EAAM,sCAAwCgJ,EAAaI,KAAK,MAE1GvB,GAAYsB,EAAgB,WACxBD,IAC8B,IAA1BA,GACA7B,EAAYrH,EAAKsH,UAMjCkB,IACAf,IA6GJ,QAAS4B,GAASpK,EAAO2C,GAKvB,IAJA,GAAI5C,GAAQ,GACRP,EAASQ,EAAQA,EAAMR,OAAS,EAChCoD,EAAS3C,MAAMT,KAEVO,EAAQP,GACfoD,EAAO7C,GAAS4C,EAAS3C,EAAMD,GAAQA,EAAOC,EAEhD,OAAO4C,GAWT,QAASyH,GAAUC,EAAQtK,GACzB,GAAID,GAAQ,GACRP,EAAS8K,EAAO9K,MAGpB,KADAQ,IAAUA,EAAQC,MAAMT,MACfO,EAAQP,GACfQ,EAAMD,GAASuK,EAAOvK,EAExB,OAAOC,GA6CT,QAASuK,GAASrJ,GAChB,MAAuB,gBAATA,IACX2B,EAAa3B,IAAUsJ,GAAiB/K,KAAKyB,IAAUuJ,GAiB5D,QAASC,GAAaxJ,GAEpB,GAAoB,gBAATA,GACT,MAAOA,EAET,IAAIqJ,EAASrJ,GACX,MAAOyJ,IAAiBA,GAAelL,KAAKyB,GAAS,EAEvD,IAAI0B,GAAU1B,EAAQ,EACtB,OAAkB,KAAV0B,GAAkB,EAAI1B,IAAW0J,GAAY,KAAOhI,EAY9D,QAASiI,GAAU7K,EAAOL,EAAOmL,GAC/B,GAAI/K,GAAQ,GACRP,EAASQ,EAAMR,MAEP,GAARG,IACFA,GAASA,EAAQH,EAAS,EAAKA,EAASG,GAE1CmL,EAAMA,EAAMtL,EAASA,EAASsL,EACpB,EAANA,IACFA,GAAOtL,GAETA,EAASG,EAAQmL,EAAM,EAAMA,EAAMnL,IAAW,EAC9CA,KAAW,CAGX,KADA,GAAIiD,GAAS3C,MAAMT,KACVO,EAAQP,GACfoD,EAAO7C,GAASC,EAAMD,EAAQJ,EAEhC,OAAOiD,GAYT,QAASmI,GAAU/K,EAAOL,EAAOmL,GAC/B,GAAItL,GAASQ,EAAMR,MAEnB,OADAsL,GAAcjL,SAARiL,EAAoBtL,EAASsL,GAC1BnL,GAASmL,GAAOtL,EAAUQ,EAAQ6K,EAAU7K,EAAOL,EAAOmL,GAYrE,QAASE,GAAcC,EAAYC,GAGjC,IAFA,GAAInL,GAAQkL,EAAWzL,OAEhBO,KAAWiI,EAAYkD,EAAYD,EAAWlL,GAAQ,GAAK,KAClE,MAAOA,GAYT,QAASoL,GAAgBF,EAAYC,GAInC,IAHA,GAAInL,GAAQ,GACRP,EAASyL,EAAWzL,SAEfO,EAAQP,GAAUwI,EAAYkD,EAAYD,EAAWlL,GAAQ,GAAK,KAC3E,MAAOA,GA+BT,QAASqL,GAAcC,GACrB,MAAOA,GAAOC,MAAMC,IAwBtB,QAASC,IAAStK,GAChB,MAAgB,OAATA,EAAgB,GAAKwJ,EAAaxJ,GA4B3C,QAASuK,IAAKJ,EAAQK,EAAOC,GAE3B,GADAN,EAASG,GAASH,GACdA,IAAWM,GAAmB9L,SAAV6L,GACtB,MAAOL,GAAOO,QAAQC,GAAQ,GAEhC,KAAKR,KAAYK,EAAQhB,EAAagB,IACpC,MAAOL,EAET,IAAIJ,GAAaG,EAAcC,GAC3BH,EAAaE,EAAcM,GAC3B/L,EAAQwL,EAAgBF,EAAYC,GACpCJ,EAAME,EAAcC,EAAYC,GAAc,CAElD,OAAOH,GAAUE,EAAYtL,EAAOmL,GAAKX,KAAK,IAQhD,QAAS2B,IAAYzM,GAOjB,MANAA,GAAOA,EAAKmM,WAAWI,QAAQG,GAAgB,IAC/C1M,EAAOA,EAAKiM,MAAMU,IAAS,GAAGJ,QAAQ,IAAK,IAC3CvM,EAAOA,EAAOA,EAAK4M,MAAMC,OACzB7M,EAAOA,EAAK8M,IAAI,SAAU9J,GACtB,MAAOoJ,IAAKpJ,EAAIuJ,QAAQQ,GAAQ,OAuFxC,QAASC,IAAWnE,EAAO7H,GACvB,GAAIiM,KAEJ5E,GAAWQ,EAAO,SAAUoB,EAAQvI,GAsBhC,QAASwL,GAAQ5F,EAAS6F,GACtB,GAAIC,GAAUrC,EAASsC,EAAQ,SAAUC,GACrC,MAAOhG,GAAQgG,IAEnBF,GAAQhI,KAAK+H,GACblD,EAAOlK,MAAM,KAAMqN,GA1BvB,GAAIC,EAEJ,IAAIrJ,GAAQiG,GACRoD,EAASrC,EAAUf,GACnBA,EAASoD,EAAOpM,MAEhBgM,EAASvL,GAAO2L,EAAO7L,OAAO6L,EAAOlN,OAAS,EAAI+M,EAAUjD,OACzD,IAAsB,IAAlBA,EAAO9J,OAEd8M,EAASvL,GAAOuI,MACb,CAEH,GADAoD,EAASZ,GAAYxC,GACC,IAAlBA,EAAO9J,QAAkC,IAAlBkN,EAAOlN,OAC9B,KAAM,IAAI8F,OAAM,yDAGpBoH,GAAOpM,MAEPgM,EAASvL,GAAO2L,EAAO7L,OAAO0L,MAYtCtE,EAAKqE,EAAUjM,GAMnB,QAASuM,IAASxM,GACdyM,WAAWzM,EAAI,GAGnB,QAAS0M,IAAKC,GACV,MAAOrN,GAAS,SAAUU,EAAIb,GAC1BwN,EAAM,WACF3M,EAAGhB,MAAM,KAAMG,OAqB3B,QAASyN,MACL7N,KAAK8N,KAAO9N,KAAK+N,KAAO,KACxB/N,KAAKK,OAAS,EAGlB,QAAS2N,IAAWC,EAAKC,GACrBD,EAAI5N,OAAS,EACb4N,EAAIH,KAAOG,EAAIF,KAAOG,EA8C1B,QAASC,IAAMC,EAAQpF,EAAaqF,GAOhC,QAASC,GAAQC,EAAMC,EAAetN,GAClC,GAAgB,MAAZA,GAAwC,kBAAbA,GAC3B,KAAM,IAAIiF,OAAM,mCAMpB,OAJAsI,GAAEC,SAAU,EACPxK,GAAQqK,KACTA,GAAQA,IAEQ,IAAhBA,EAAKlO,QAAgBoO,EAAEE,OAEhBC,GAAe,WAClBH,EAAEI,WAGV5G,EAAUsG,EAAM,SAAUrF,GACtB,GAAItD,IACA2I,KAAMrF,EACNhI,SAAUA,GAAYwB,EAGtB8L,GACAC,EAAEK,OAAOC,QAAQnJ,GAEjB6I,EAAEK,OAAOxJ,KAAKM,SAGtBgJ,IAAeH,EAAEO,UAGrB,QAASC,GAAMlG,GACX,MAAOxI,GAAS,SAAUH,GACtB8O,GAAW,EAEXjH,EAAUc,EAAO,SAAUG,GACvBjB,EAAUkH,EAAa,SAAUf,EAAQxN,GACrC,MAAIwN,KAAWlF,GACXiG,EAAYC,OAAOxO,EAAO,IACnB,GAFX,SAMJsI,EAAKhI,SAASjB,MAAMiJ,EAAM9I,GAEX,MAAXA,EAAK,IACLqO,EAAEY,MAAMjP,EAAK,GAAI8I,EAAKqF,QAI1BW,GAAWT,EAAEzF,YAAcyF,EAAEa,QAC7Bb,EAAEc,cAGFd,EAAEE,QACFF,EAAEI,QAENJ,EAAEO,YA7DV,GAAmB,MAAfhG,EACAA,EAAc,MACX,IAAoB,IAAhBA,EACP,KAAM,IAAI7C,OAAM,+BA8DpB,IAAI+I,GAAU,EACVC,KACAV,GACAK,OAAQ,GAAIjB,IACZ7E,YAAaA,EACbqF,QAASA,EACTmB,UAAW9M,EACX6M,YAAa7M,EACb4M,OAAQtG,EAAc,EACtByG,MAAO/M,EACPmM,MAAOnM,EACP2M,MAAO3M,EACPgM,SAAS,EACTgB,QAAQ,EACRpK,KAAM,SAAUiJ,EAAMrN,GAClBoN,EAAQC,GAAM,EAAOrN,IAEzByO,KAAM,WACFlB,EAAEI,MAAQnM,EACV+L,EAAEK,OAAOW,SAEbV,QAAS,SAAUR,EAAMrN,GACrBoN,EAAQC,GAAM,EAAMrN,IAExB8N,QAAS,WACL,MAAQP,EAAEiB,QAAUR,EAAUT,EAAEzF,aAAeyF,EAAEK,OAAOzO,QAAQ,CAC5D,GAAI0I,MACAwF,KACAqB,EAAInB,EAAEK,OAAOzO,MACboO,GAAEJ,UAASuB,EAAIC,KAAKC,IAAIF,EAAGnB,EAAEJ,SACjC,KAAK,GAAI7I,GAAI,EAAOoK,EAAJpK,EAAOA,IAAK,CACxB,GAAI0I,GAAOO,EAAEK,OAAOtF,OACpBT,GAAMzD,KAAK4I,GACXK,EAAKjJ,KAAK4I,EAAKK,MAGK,IAApBE,EAAEK,OAAOzO,QACToO,EAAEgB,QAENP,GAAW,EACXC,EAAY7J,KAAKyD,EAAM,IAEnBmG,IAAYT,EAAEzF,aACdyF,EAAEe,WAGN,IAAI/N,GAAKyE,EAAS+I,EAAMlG,GACxBqF,GAAOG,EAAM9M,KAGrBpB,OAAQ,WACJ,MAAOoO,GAAEK,OAAOzO,QAEpBmG,QAAS,WACL,MAAO0I,IAEXC,YAAa,WACT,MAAOA,IAEXR,KAAM,WACF,MAAOF,GAAEK,OAAOzO,OAAS6O,IAAY,GAEzCa,MAAO,WACHtB,EAAEiB,QAAS,GAEfM,OAAQ,WACJ,GAAIvB,EAAEiB,UAAW,EAAjB,CAGAjB,EAAEiB,QAAS,CAIX,KAAK,GAHDO,GAAcJ,KAAKC,IAAIrB,EAAEzF,YAAayF,EAAEK,OAAOzO,QAG1C6P,EAAI,EAAQD,GAALC,EAAkBA,IAC9BtB,GAAeH,EAAEO,WAI7B,OAAOP,GAiFX,QAAS0B,IAAM/B,EAAQC,GACrB,MAAOF,IAAMC,EAAQ,EAAGC,GAgE1B,QAAS+B,IAAOtN,EAAMuN,EAAM7M,EAAUtC,GAClCA,EAAWyB,EAAKzB,GAAYwB,GAC5B4N,GAAaxN,EAAM,SAAUyN,EAAG/K,EAAGtE,GAC/BsC,EAAS6M,EAAME,EAAG,SAAUhK,EAAKoB,GAC7B0I,EAAO1I,EACPzG,EAASqF,MAEd,SAAUA,GACTrF,EAASqF,EAAK8J,KAsGtB,QAASG,IAASnP,EAAQkG,EAAKtG,EAAIC,GAC/B,GAAIuC,KACJpC,GAAOkG,EAAK,SAAUgJ,EAAG3P,EAAOa,GAC5BR,EAAGsP,EAAG,SAAUhK,EAAKkK,GACjBhN,EAASA,EAAO/B,OAAO+O,OACvBhP,EAAG8E,MAER,SAAUA,GACTrF,EAASqF,EAAK9C,KAiCtB,QAASiN,IAASzP,GACd,MAAO,UAAU+E,EAAKxC,EAAUtC,GAC5B,MAAOD,GAAGqP,GAActK,EAAKxC,EAAUtC,IA0F/C,QAASyP,IAAS5O,GAChB,MAAOA,GAGT,QAAS6O,IAAcvP,EAAQwP,EAAOC,GAClC,MAAO,UAAUvJ,EAAKlB,EAAO7C,EAAU/B,GACnC,QAASqE,GAAKS,GACN9E,IACI8E,EACA9E,EAAG8E,GAEH9E,EAAG,KAAMqP,GAAU,KAI/B,QAASC,GAAgBR,EAAG7I,EAAGxG,GAC3B,MAAKO,OACL+B,GAAS+M,EAAG,SAAUhK,EAAKoB,GACnBlG,IACI8E,GACA9E,EAAG8E,GACH9E,EAAK+B,GAAW,GACTqN,EAAMlJ,KACblG,EAAG,KAAMqP,GAAU,EAAMP,IACzB9O,EAAK+B,GAAW,IAGxBtC,MAXYA,IAchBP,UAAUN,OAAS,GACnBoB,EAAKA,GAAMiB,EACXrB,EAAOkG,EAAKlB,EAAO0K,EAAiBjL,KAEpCrE,EAAK+B,EACL/B,EAAKA,GAAMiB,EACXc,EAAW6C,EACXhF,EAAOkG,EAAKwJ,EAAiBjL,KAKzC,QAASkL,IAAerJ,EAAG4I,GACvB,MAAOA,GAsFX,QAASU,IAAYzD,GACjB,MAAOjN,GAAS,SAAUU,EAAIb,GAC1Ba,EAAGhB,MAAM,KAAMG,EAAKsB,QAAQnB,EAAS,SAAUgG,EAAKnG,GACzB,gBAAZ8Q,WACH3K,EACI2K,QAAQ7B,OACR6B,QAAQ7B,MAAM9I,GAEX2K,QAAQ1D,IACfvF,EAAU7H,EAAM,SAAUmQ,GACtBW,QAAQ1D,GAAM+C,aA2DtC,QAASY,IAASlQ,EAAIyD,EAAMxD,GASxB,QAAS2P,GAAMtK,EAAK6K,GAChB,MAAI7K,GAAYrF,EAASqF,GACpB6K,MACLnQ,GAAG4E,GADgB3E,EAAS,MAVhCA,EAAWgF,EAAShF,GAAYwB,EAEhC,IAAImD,GAAOtF,EAAS,SAAUgG,EAAKnG,GAC/B,MAAImG,GAAYrF,EAASqF,IACzBnG,EAAKkF,KAAKuL,OACVnM,GAAKzE,MAAMD,KAAMI,KASrByQ,GAAM,MAAM,GA0BhB,QAASQ,IAAS7N,EAAUkB,EAAMxD,GAC9BA,EAAWgF,EAAShF,GAAYwB,EAChC,IAAImD,GAAOtF,EAAS,SAAUgG,EAAKnG,GAC/B,MAAImG,GAAYrF,EAASqF,GACrB7B,EAAKzE,MAAMD,KAAMI,GAAcoD,EAASqC,OAC5C3E,GAASjB,MAAM,MAAO,MAAMyB,OAAOtB,KAEvCoD,GAASqC,GAuBb,QAASyL,IAAQrQ,EAAIyD,EAAMxD,GACvBmQ,GAASpQ,EAAI,WACT,OAAQyD,EAAKzE,MAAMD,KAAMW,YAC1BO,GAwCP,QAASqQ,IAAO7M,EAAMzD,EAAIC,GAGtB,QAAS2E,GAAKU,GACV,MAAIA,GAAYrF,EAASqF,OACzB7B,GAAKmM,GAGT,QAASA,GAAMtK,EAAK6K,GAChB,MAAI7K,GAAYrF,EAASqF,GACpB6K,MACLnQ,GAAG4E,GADgB3E,EAAS,MAThCA,EAAWgF,EAAShF,GAAYwB,GAahCgC,EAAKmM,GAGT,QAASW,IAAchO,GACnB,MAAO,UAAUzB,EAAOnB,EAAOM,GAC3B,MAAOsC,GAASzB,EAAOb,IA+D/B,QAASuQ,IAAU3O,EAAMU,EAAUtC,GACjCgG,EAAOpE,EAAM0O,GAAchO,GAAWtC,GAwBxC,QAASwQ,IAAY5O,EAAMuD,EAAO7C,EAAUtC,GAC1CkF,EAAaC,GAAOvD,EAAM0O,GAAchO,GAAWtC,GA2DrD,QAASyQ,IAAY1Q,GACjB,MAAOD,GAAc,SAAUZ,EAAMc,GACjC,GAAI0Q,IAAO,CACXxR,GAAKkF,KAAK,WACN,GAAIuM,GAAYlR,SACZiR,GACAhD,GAAe,WACX1N,EAASjB,MAAM,KAAM4R,KAGzB3Q,EAASjB,MAAM,KAAM4R,KAG7B5Q,EAAGhB,MAAMD,KAAMI,GACfwR,GAAO,IAIf,QAASE,IAAMnK,GACX,OAAQA,EA4EZ,QAASoK,IAAQ1Q,EAAQkG,EAAK/D,EAAUtC,GACpCA,EAAWyB,EAAKzB,GAAYwB,EAC5B,IAAI8E,KACJnG,GAAOkG,EAAK,SAAUgJ,EAAG3P,EAAOM,GAC5BsC,EAAS+M,EAAG,SAAUhK,EAAKoB,GACnBpB,EACArF,EAASqF,IAELoB,GACAH,EAAQlC,MAAO1E,MAAOA,EAAOmB,MAAOwO,IAExCrP,QAGT,SAAUqF,GACLA,EACArF,EAASqF,GAETrF,EAAS,KAAM+J,EAASzD,EAAQwK,KAAK,SAAUC,EAAGC,GAC9C,MAAOD,GAAErR,MAAQsR,EAAEtR,QACnBe,EAAa,aAuG7B,QAASwQ,IAAQlR,EAAImR,GAIjB,QAASvM,GAAKU,GACV,MAAIA,GAAYT,EAAKS,OACrB2C,GAAKrD,GALT,GAAIC,GAAOI,EAASkM,GAAW1P,GAC3BwG,EAAOyI,GAAY1Q,EAMvB4E,KAoDJ,QAASwM,IAAerM,EAAKK,EAAO7C,EAAUtC,GAC1CA,EAAWyB,EAAKzB,GAAYwB,EAC5B,IAAI4P,KACJ1L,GAAYZ,EAAKK,EAAO,SAAU4D,EAAKrI,EAAKiE,GACxCrC,EAASyG,EAAKrI,EAAK,SAAU2E,EAAK9C,GAC9B,MAAI8C,GAAYV,EAAKU,IACrB+L,EAAO1Q,GAAO6B,MACdoC,SAEL,SAAUU,GACTrF,EAASqF,EAAK+L,KAsEtB,QAASC,IAAIvM,EAAKpE,GACd,MAAOA,KAAOoE,GAwClB,QAASwM,IAAQvR,EAAIwR,GACjB,GAAIpC,GAAOhI,OAAOqK,OAAO,MACrBC,EAAStK,OAAOqK,OAAO,KAC3BD,GAASA,GAAU9B,EACnB,IAAIiC,GAAW5R,EAAc,SAAkBZ,EAAMc,GACjD,GAAIU,GAAM6Q,EAAOxS,MAAM,KAAMG,EACzBmS,IAAIlC,EAAMzO,GACVgN,GAAe,WACX1N,EAASjB,MAAM,KAAMoQ,EAAKzO,MAEvB2Q,GAAII,EAAQ/Q,GACnB+Q,EAAO/Q,GAAK0D,KAAKpE,IAEjByR,EAAO/Q,IAAQV,GACfD,EAAGhB,MAAM,KAAMG,EAAKsB,QAAQnB,EAAS,SAAUH,GAC3CiQ,EAAKzO,GAAOxB,CACZ,IAAIqO,GAAIkE,EAAO/Q,SACR+Q,GAAO/Q,EACd,KAAK,GAAI4D,GAAI,EAAGoK,EAAInB,EAAEpO,OAAYuP,EAAJpK,EAAOA,IACjCiJ,EAAEjJ,GAAGvF,MAAM,KAAMG,UAOjC,OAFAwS,GAASvC,KAAOA,EAChBuC,EAASC,WAAa5R,EACf2R,EA8CX,QAASE,IAAUzR,EAAQ0H,EAAO7H,GAC9BA,EAAWA,GAAYwB,CACvB,IAAI8E,GAAUhF,EAAYuG,QAE1B1H,GAAO0H,EAAO,SAAUG,EAAMtH,EAAKV,GAC/BgI,EAAK3I,EAAS,SAAUgG,EAAKnG,GACrBA,EAAKC,QAAU,IACfD,EAAOA,EAAK,IAEhBoH,EAAQ5F,GAAOxB,EACfc,EAASqF,OAEd,SAAUA,GACTrF,EAASqF,EAAKiB,KAsEtB,QAASuL,IAAchK,EAAO7H,GAC5B4R,GAAU5L,EAAQ6B,EAAO7H,GAuB3B,QAAS8R,IAAgBjK,EAAO1C,EAAOnF,GACrC4R,GAAU1M,EAAaC,GAAQ0C,EAAO7H,GAuGxC,QAAS+R,IAAS7E,EAAQpF,GACxB,MAAOmF,IAAM,SAAU+E,EAAOzR,GAC5B2M,EAAO8E,EAAM,GAAIzR,IAChBuH,EAAa,GA2BlB,QAASmK,IAAe/E,EAAQpF,GAE5B,GAAIyF,GAAIwE,GAAQ7E,EAAQpF,EA4CxB,OAzCAyF,GAAEnJ,KAAO,SAAUiJ,EAAM6E,EAAUlS,GAE/B,GADgB,MAAZA,IAAkBA,EAAWwB,GACT,kBAAbxB,GACP,KAAM,IAAIiF,OAAM,mCAMpB,IAJAsI,EAAEC,SAAU,EACPxK,GAAQqK,KACTA,GAAQA,IAEQ,IAAhBA,EAAKlO,OAEL,MAAOuO,IAAe,WAClBH,EAAEI,SAIVuE,GAAWA,GAAY,CAEvB,KADA,GAAIC,GAAW5E,EAAEK,OAAOhB,KACjBuF,GAAYD,GAAYC,EAASD,UACpCC,EAAWA,EAASxN,IAGxBoC,GAAUsG,EAAM,SAAUrF,GACtB,GAAItD,IACA2I,KAAMrF,EACNkK,SAAUA,EACVlS,SAAUA,EAGVmS,GACA5E,EAAEK,OAAOwE,aAAaD,EAAUzN,GAEhC6I,EAAEK,OAAOxJ,KAAKM,KAGtBgJ,GAAeH,EAAEO,gBAIdP,GAAEM,QAEFN,EAwCX,QAAS8E,IAAKxK,EAAO7H,GAEjB,MADAA,GAAWyB,EAAKzB,GAAYwB,GACvBwB,GAAQ6E,GACRA,EAAM1I,WACX4H,GAAUc,EAAO,SAAUG,GACvBA,EAAKhI,KAFiBA,IADEA,EAAS,GAAIsS,WAAU,yDA+BvD,QAASC,IAAY5S,EAAOwP,EAAM7M,EAAUtC,GAC1C,GAAIwS,GAAW7I,GAAMvK,KAAKO,GAAO8S,SACjCvD,IAAOsD,EAAUrD,EAAM7M,EAAUtC,GA0CnC,QAAS0S,IAAQ3S,GACb,MAAOD,GAAc,SAAmBZ,EAAMyT,GAmB1C,MAlBAzT,GAAKkF,KAAK/E,EAAS,SAAkBgG,EAAKuN,GACtC,GAAIvN,EACAsN,EAAgB,MACZxE,MAAO9I,QAER,CACH,GAAIxE,GAAQ,IACU,KAAlB+R,EAAOzT,OACP0B,EAAQ+R,EAAO,GACRA,EAAOzT,OAAS,IACvB0B,EAAQ+R,GAEZD,EAAgB,MACZ9R,MAAOA,QAKZd,EAAGhB,MAAMD,KAAMI,KAI9B,QAAS2T,IAAS1S,EAAQkG,EAAK/D,EAAUtC,GACrC6Q,GAAQ1Q,EAAQkG,EAAK,SAAUxF,EAAON,GAClC+B,EAASzB,EAAO,SAAUwE,EAAKoB,GACvBpB,EACA9E,EAAG8E,GAEH9E,EAAG,MAAOkG,MAGnBzG,GAiGP,QAAS8S,IAAWjL,GAChB,GAAIvB,EASJ,OARItD,IAAQ6E,GACRvB,EAAUyD,EAASlC,EAAO6K,KAE1BpM,KACAe,EAAWQ,EAAO,SAAUG,EAAMtH,GAC9B4F,EAAQ5F,GAAOgS,GAAQtT,KAAKN,KAAMkJ,MAGnC1B,EA4DX,QAASyM,IAAWlS,GAClB,MAAO,YACL,MAAOA,IA0EX,QAASmS,IAAMC,EAAMjL,EAAMhI,GASvB,QAASkT,GAAWC,EAAKC,GACrB,GAAiB,gBAANA,GACPD,EAAIE,OAASD,EAAEC,OAASC,EAExBH,EAAII,aAAqC,kBAAfH,GAAEI,SAA0BJ,EAAEI,SAAWT,IAAYK,EAAEI,UAAYC,OAC1F,CAAA,GAAiB,gBAANL,IAA+B,gBAANA,GAGvC,KAAM,IAAInO,OAAM,oCAFhBkO,GAAIE,OAASD,GAAKE,GAmB1B,QAASI,KACL1L,EAAK,SAAU3C,GACPA,GAAOsO,IAAYC,EAAQP,MAC3B7G,WAAWkH,EAAcE,EAAQL,aAAaI,IAE9C3T,EAASjB,MAAM,KAAMU,aAtCjC,GAAI6T,GAAgB,EAChBG,EAAmB,EAEnBG,GACAP,MAAOC,EACPC,aAAcR,GAAWU,GAuB7B,IARIhU,UAAUN,OAAS,GAAqB,kBAAT8T,IAC/BjT,EAAWgI,GAAQxG,EACnBwG,EAAOiL,IAEPC,EAAWU,EAASX,GACpBjT,EAAWA,GAAYwB,GAGP,kBAATwG,GACP,KAAM,IAAI/C,OAAM,oCAGpB,IAAI0O,GAAU,CAWdD,KA2BJ,QAASG,IAAWZ,EAAMjL,GAKtB,MAJKA,KACDA,EAAOiL,EACPA,EAAO,MAEJnT,EAAc,SAAUZ,EAAMc,GACjC,QAASiJ,GAAO1I,GACZyH,EAAKjJ,MAAM,KAAMG,EAAKsB,QAAQD,KAG9B0S,EAAMD,GAAMC,EAAMhK,EAAQjJ,GAAegT,GAAM/J,EAAQjJ,KAoEnE,QAAS8T,IAAOjM,EAAO7H,GACrB4R,GAAUxC,GAAcvH,EAAO7H,GA8HjC,QAAS+T,IAAOnS,EAAMU,EAAUtC,GAW5B,QAASgU,GAAWC,EAAMC,GACtB,GAAInD,GAAIkD,EAAKE,SACTnD,EAAIkD,EAAMC,QACd,OAAWnD,GAAJD,EAAQ,GAAKA,EAAIC,EAAI,EAAI,EAbpClF,GAAIlK,EAAM,SAAUyN,EAAGrP,GACnBsC,EAAS+M,EAAG,SAAUhK,EAAK8O,GACvB,MAAI9O,GAAYrF,EAASqF,OACzBrF,GAAS,MAAQa,MAAOwO,EAAG8E,SAAUA,OAE1C,SAAU9O,EAAKiB,GACd,MAAIjB,GAAYrF,EAASqF,OACzBrF,GAAS,KAAM+J,EAASzD,EAAQwK,KAAKkD,GAAavT,EAAa,aAiCvE,QAAS2T,IAAQC,EAASC,EAAcC,GAIpC,QAASC,KACAC,IACDC,EAAiB3V,MAAM,KAAMU,WAC7BkV,aAAaC,IAIrB,QAASC,KACL,GAAIvI,GAAO+H,EAAQ/H,MAAQ,YACvB6B,EAAQ,GAAIlJ,OAAM,sBAAwBqH,EAAO,eACrD6B,GAAM2G,KAAO,YACTP,IACApG,EAAMoG,KAAOA,GAEjBE,GAAW,EACXC,EAAiBvG,GAlBrB,GAAIuG,GAAkBE,EAClBH,GAAW,CAoBf,OAAO3U,GAAc,SAAUZ,EAAM6V,GACjCL,EAAmBK,EAEnBH,EAAQpI,WAAWqI,EAAiBP,GACpCD,EAAQtV,MAAM,KAAMG,EAAKsB,OAAOgU,MAkBxC,QAASQ,IAAU1V,EAAOmL,EAAKwK,EAAMhO,GAKnC,IAJA,GAAIvH,GAAQ,GACRP,EAAS+V,GAAYC,IAAY1K,EAAMnL,IAAU2V,GAAQ,IAAK,GAC9D1S,EAAS3C,MAAMT,GAEZA,KACLoD,EAAO0E,EAAY9H,IAAWO,GAASJ,EACvCA,GAAS2V,CAEX,OAAO1S,GAmBT,QAAS6S,IAAUC,EAAOlQ,EAAO7C,EAAUtC,GACzCsV,GAASN,GAAU,EAAGK,EAAO,GAAIlQ,EAAO7C,EAAUtC,GAkGpD,QAAS+B,IAAUH,EAAM2T,EAAajT,EAAUtC,GACnB,IAArBP,UAAUN,SACVa,EAAWsC,EACXA,EAAWiT,EACXA,EAAcvS,GAAQpB,UAE1B5B,EAAWyB,EAAKzB,GAAYwB,GAE5BwE,EAAOpE,EAAM,SAAU6E,EAAG+O,EAAGjV,GACzB+B,EAASiT,EAAa9O,EAAG+O,EAAGjV,IAC7B,SAAU8E,GACTrF,EAASqF,EAAKkQ,KAiBtB,QAASE,IAAU1V,GACf,MAAO,YACH,OAAQA,EAAG4R,YAAc5R,GAAIhB,MAAM,KAAMU,YAuCjD,QAASiW,IAAOlS,EAAMlB,EAAUtC,GAE5B,GADAA,EAAWgF,EAAShF,GAAYwB,IAC3BgC,IAAQ,MAAOxD,GAAS,KAC7B,IAAI2E,GAAOtF,EAAS,SAAUgG,EAAKnG,GAC/B,MAAImG,GAAYrF,EAASqF,GACrB7B,IAAelB,EAASqC,OAC5B3E,GAASjB,MAAM,MAAO,MAAMyB,OAAOtB,KAEvCoD,GAASqC,GA0Bb,QAASgR,IAAMnS,EAAMzD,EAAIC,GACrB0V,GAAO,WACH,OAAQlS,EAAKzE,MAAMD,KAAMW,YAC1BM,EAAIC,GA4DX,QAAS4V,IAAW/N,EAAO7H,GAMvB,QAAS6V,GAAS3W,GACd,GAAI4W,IAAcjO,EAAM1I,OACpB,MAAOa,GAASjB,MAAM,MAAO,MAAMyB,OAAOtB,GAG9C,IAAI2J,GAAe7D,EAAS3F,EAAS,SAAUgG,EAAKnG,GAChD,MAAImG,GACOrF,EAASjB,MAAM,MAAOsG,GAAK7E,OAAOtB,QAE7C2W,GAAS3W,KAGbA,GAAKkF,KAAKyE,EAEV,IAAIb,GAAOH,EAAMiO,IACjB9N,GAAKjJ,MAAM,KAAMG,GAnBrB,GADAc,EAAWyB,EAAKzB,GAAYwB,IACvBwB,GAAQ6E,GAAQ,MAAO7H,GAAS,GAAIiF,OAAM,6DAC/C,KAAK4C,EAAM1I,OAAQ,MAAOa,IAC1B,IAAI8V,GAAY,CAoBhBD,OA3qJJ,GA60DIE,IA70DAxW,GAAYoP,KAAKqH,IA8EjBzU,GAAYd,EAAa,UAgCzBS,GAAU,oBACVC,GAAS,6BAET8U,GAAc9O,OAAOtD,UAOrB5C,GAAiBgV,GAAY9K,SA4B7B9J,GAAmB,iBAwFnBQ,GAAmC,kBAAXqU,SAAyBA,OAAOzR,SAqBxD0R,GAAqBhP,OAAOiP,eAS5BjU,GAAeL,EAAQqU,GAAoBhP,QAG3CkP,GAAgBlP,OAAOtD,UAGvB3B,GAAiBmU,GAAcnU,eAoB/BoU,GAAanP,OAAOpD,KAUpBE,GAAWnC,EAAQwU,GAAYnP,QA+E/BrE,GAAU,qBAGVyT,GAAgBpP,OAAOtD,UAGvBlB,GAAmB4T,GAAcrU,eAOjCW,GAAmB0T,GAAcpL,SAGjCvI,GAAuB2T,GAAc3T,qBAiDrCI,GAAUpD,MAAMoD,QAGhBE,GAAY,kBAGZsT,GAAgBrP,OAAOtD,UAOvBZ,GAAmBuT,GAAcrL,SA0CjC7H,GAAqB,iBAGrBC,GAAW,mBAkBXO,GAAgBqD,OAAOtD,UA+MvBqC,GAAgBP,EAAQD,EAAa+Q,EAAAA,GA2GrC3K,GAAM3F,EAAWC,GAiCjBsQ,GAAYxW,EAAY4L,IA2BxBwJ,GAAW5O,EAAgBN,GAoB3BuQ,GAAYhR,EAAQ2P,GAAU,GAqB9BsB,GAAkB1W,EAAYyW,IA8C9BE,GAAUxX,EAAS,SAAUU,EAAIb,GACjC,MAAOG,GAAS,SAAUyX,GACtB,MAAO/W,GAAGhB,MAAM,KAAMG,EAAKsB,OAAOsW,QAwItCxP,GAAUN,IA+VV+P,GAA8B,gBAAVxY,SAAsBA,QAAUA,OAAO4I,SAAWA,QAAU5I,OAGhFyY,GAA0B,gBAARC,OAAoBA,MAAQA,KAAK9P,SAAWA,QAAU8P,KAGxEC,GAAOH,IAAcC,IAAYG,SAAS,iBAG1CC,GAAWF,GAAKhB,OAGhB9L,GAAY,kBAGZiN,GAAgBlQ,OAAOtD,UAOvBsG,GAAmBkN,GAAclM,SAyBjCZ,GAAW,EAAI,EAGf+M,GAAcF,GAAWA,GAASvT,UAAYrE,OAC9C8K,GAAiBgN,GAAcA,GAAYnM,SAAW3L,OAoGtD+X,GAAgB,kBAChBC,GAAoB,iCACpBC,GAAsB,kBACtBC,GAAa,iBACbC,GAAW,IAAMJ,GAAgB,IACjCK,GAAU,IAAMJ,GAAoBC,GAAsB,IAC1DI,GAAS,2BACTC,GAAa,MAAQF,GAAU,IAAMC,GAAS,IAC9CE,GAAc,KAAOR,GAAgB,IACrCS,GAAa,kCACbC,GAAa,qCACbC,GAAQ,UACRC,GAAWL,GAAa,IACxBM,GAAW,IAAMV,GAAa,KAC9BW,GAAY,MAAQH,GAAQ,OAASH,GAAaC,GAAYC,IAAYnO,KAAK,KAAO,IAAMsO,GAAWD,GAAW,KAClHG,GAAQF,GAAWD,GAAWE,GAC9BE,GAAW,OAASR,GAAcH,GAAU,IAAKA,GAASI,GAAYC,GAAYN,IAAU7N,KAAK,KAAO,IAExGoB,GAAkBsN,OAAOX,GAAS,MAAQA,GAAS,KAAOU,GAAWD,GAAO,KAuC5E9M,GAAS,aAwCTG,GAAU,wCACVE,GAAe,IACfE,GAAS,eACTL,GAAiB,mCAmIjB+M,GAA0C,kBAAjBC,eAA+BA,aACxDC,GAAiC,gBAAZ7K,UAAoD,kBAArBA,SAAQ8K,QAiB5D7C,IADA0C,GACSC,aACFC,GACE7K,QAAQ8K,SAERrM,EAGb,IAAImB,IAAiBjB,GAAKsJ,GAgB1BpJ,IAAI9I,UAAUgV,WAAa,SAAU7L,GAMjC,MALIA,GAAK8L,KAAM9L,EAAK8L,KAAKnU,KAAOqI,EAAKrI,KAAU7F,KAAK8N,KAAOI,EAAKrI,KAC5DqI,EAAKrI,KAAMqI,EAAKrI,KAAKmU,KAAO9L,EAAK8L,KAAUha,KAAK+N,KAAOG,EAAK8L,KAEhE9L,EAAK8L,KAAO9L,EAAKrI,KAAO,KACxB7F,KAAKK,QAAU,EACR6N,GAGXL,GAAI9I,UAAU0K,MAAQ5B,GAEtBA,GAAI9I,UAAUkV,YAAc,SAAU/L,EAAMgM,GACxCA,EAAQF,KAAO9L,EACfgM,EAAQrU,KAAOqI,EAAKrI,KAChBqI,EAAKrI,KAAMqI,EAAKrI,KAAKmU,KAAOE,EAAala,KAAK+N,KAAOmM,EACzDhM,EAAKrI,KAAOqU,EACZla,KAAKK,QAAU,GAGnBwN,GAAI9I,UAAUuO,aAAe,SAAUpF,EAAMgM,GACzCA,EAAQF,KAAO9L,EAAK8L,KACpBE,EAAQrU,KAAOqI,EACXA,EAAK8L,KAAM9L,EAAK8L,KAAKnU,KAAOqU,EAAala,KAAK8N,KAAOoM,EACzDhM,EAAK8L,KAAOE,EACZla,KAAKK,QAAU,GAGnBwN,GAAI9I,UAAUgK,QAAU,SAAUb,GAC1BlO,KAAK8N,KAAM9N,KAAKsT,aAAatT,KAAK8N,KAAMI,GAAWF,GAAWhO,KAAMkO,IAG5EL,GAAI9I,UAAUO,KAAO,SAAU4I,GACvBlO,KAAK+N,KAAM/N,KAAKia,YAAYja,KAAK+N,KAAMG,GAAWF,GAAWhO,KAAMkO,IAG3EL,GAAI9I,UAAUyE,MAAQ,WAClB,MAAOxJ,MAAK8N,MAAQ9N,KAAK+Z,WAAW/Z,KAAK8N,OAG7CD,GAAI9I,UAAU5D,IAAM,WAChB,MAAOnB,MAAK+N,MAAQ/N,KAAK+Z,WAAW/Z,KAAK+N,MA2P7C,IAusCIoM,IAvsCA7J,GAAezJ,EAAQD,EAAa,GA4FpCwT,GAAM7Z,EAAS,SAAa8Z,GAC5B,MAAO9Z,GAAS,SAAUH,GACtB,GAAIoB,GAAOxB,KAEPyB,EAAKrB,EAAKA,EAAKC,OAAS,EACX,mBAANoB,GACPrB,EAAKe,MAELM,EAAKiB,EAGT0N,GAAOiK,EAAWja,EAAM,SAAUka,EAASrZ,EAAIQ,GAC3CR,EAAGhB,MAAMuB,EAAM8Y,EAAQ5Y,QAAQnB,EAAS,SAAUgG,EAAKgU,GACnD9Y,EAAG8E,EAAKgU,SAEb,SAAUhU,EAAKiB,GACd/F,EAAGxB,MAAMuB,GAAO+E,GAAK7E,OAAO8F,UAwCpCgT,GAAUja,EAAS,SAAUH,GAC/B,MAAOga,IAAIna,MAAM,KAAMG,EAAKuT,aA0C1BjS,GAAS2F,EAAWmJ,IA2BpBiK,GAAe/J,GAASF,IA4CxBkK,GAAWna,EAAS,SAAUoa,GAC9B,GAAIva,IAAQ,MAAMsB,OAAOiZ,EACzB,OAAO3Z,GAAc,SAAU4Z,EAAa1Z,GACxC,MAAOA,GAASjB,MAAMD,KAAMI,OAqGhCya,GAASjK,GAAc1J,EAAQyJ,GAAUK,IAwBzC8J,GAAclK,GAAchK,EAAa+J,GAAUK,IAsBnD+J,GAAenK,GAAcN,GAAcK,GAAUK,IAgDrDgK,GAAM/J,GAAY,OA4QlBgK,GAAapU,EAAQ6K,GAAa,GAsFlCwJ,GAAQtK,GAAc1J,EAAQ4K,GAAOA,IAsBrCqJ,GAAavK,GAAchK,EAAakL,GAAOA,IAqB/CsJ,GAAcvU,EAAQsU,GAAY,GAsDlCE,GAAShU,EAAW0K,IAqBpBuJ,GAAc1T,EAAgBmK,IAmB9BwJ,GAAe1U,EAAQyU,GAAa,GAqEpCE,GAAMvK,GAAY,OAgFlBwK,GAAY5U,EAAQwL,GAAgBsF,EAAAA,GAoBpC+D,GAAkB7U,EAAQwL,GAAgB,EA0G1C8H,IADAN,GACW7K,QAAQ8K,SACZH,GACIC,aAEAnM,EAGf,IAAIqM,IAAWnM,GAAKwM,IAkVhBtP,GAAQ/J,MAAMiE,UAAU8F,MAkIxB8Q,GAAStU,EAAW0M,IAmGpB6H,GAAchU,EAAgBmM,IAkB9B8H,GAAehV,EAAQ+U,GAAa,GAwRpCE,GAAOlL,GAAc1J,EAAQ6U,QAASpL,IAuBtCqL,GAAYpL,GAAchK,EAAamV,QAASpL,IAsBhDsL,GAAapV,EAAQmV,GAAW,GAwHhC3F,GAAaxG,KAAKqM,KAClB9F,GAAcvG,KAAKqH,IA4EnB3C,GAAQ1N,EAAQyP,GAAWqB,EAAAA,GAgB3BwE,GAActV,EAAQyP,GAAW,GAgPjC1V,IACFgX,UAAWA,GACXE,gBAAiBA,GACjB7X,MAAO8X,GACPlQ,SAAUA,EACViB,KAAMA,EACNoE,WAAYA,GACZiD,MAAOA,GACPqK,QAASA,GACT9Y,OAAQA,GACR+Y,aAAcA,GACdC,SAAUA,GACVG,OAAQA,GACRC,YAAaA,GACbC,aAAcA,GACdC,IAAKA,GACL7J,SAAUA,GACVG,QAASA,GACTD,SAAUA,GACVE,OAAQA,GACR6K,KAAM3K,GACNA,UAAWC,GACXxK,OAAQA,EACRN,YAAaA,EACb0J,aAAcA,GACd2K,WAAYA,GACZtJ,YAAaA,GACbuJ,MAAOA,GACPC,WAAYA,GACZC,YAAaA,GACbC,OAAQA,GACRC,YAAaA,GACbC,aAAcA,GACdpJ,QAASA,GACTqJ,IAAKA,GACLxO,IAAKA,GACLwJ,SAAUA,GACVqB,UAAWA,GACX4D,UAAWA,GACXpJ,eAAgBA,GAChBqJ,gBAAiBA,GACjBlJ,QAASA,GACTsH,SAAUA,GACVuC,SAAUtJ,GACVA,cAAeC,GACfG,cAAeA,GACfhF,MAAO8E,GACPM,KAAMA,GACNnD,OAAQA,GACRqD,YAAaA,GACbG,QAASA,GACTI,WAAYA,GACZ2H,OAAQA,GACRC,YAAaA,GACbC,aAAcA,GACd3H,MAAOA,GACPa,UAAWA,GACXqF,IAAKA,GACLpF,OAAQA,GACR4E,aAAchL,GACdkN,KAAMA,GACNE,UAAWA,GACXC,WAAYA,GACZhH,OAAQA,GACRK,QAASA,GACTf,MAAOA,GACP+H,WAAYhG,GACZ6F,YAAaA,GACblZ,UAAWA,GACX0T,UAAWA,GACXE,MAAOA,GACPC,UAAWA,GACXF,OAAQA,GAGR2F,IAAKrB,GACLsB,IAAKV,GACLW,QAAShL,GACTiL,cAAezB,GACf0B,aAAcjL,GACdkL,UAAW1V,EACX2V,gBAAiBvM,GACjBwM,eAAgBlW,EAChBmW,OAAQ3M,GACR4M,MAAO5M,GACP6M,MAAOxJ,GACPyJ,OAAQ7B,GACR8B,YAAa7B,GACb8B,aAAc7B,GACd8B,SAAUxV,EAGZlI,GAAQ,WAAaiB,GACrBjB,EAAQiY,UAAYA,GACpBjY,EAAQmY,gBAAkBA,GAC1BnY,EAAQM,MAAQ8X,GAChBpY,EAAQkI,SAAWA,EACnBlI,EAAQmJ,KAAOA,EACfnJ,EAAQuN,WAAaA,GACrBvN,EAAQwQ,MAAQA,GAChBxQ,EAAQ6a,QAAUA,GAClB7a,EAAQ+B,OAASA,GACjB/B,EAAQ8a,aAAeA,GACvB9a,EAAQ+a,SAAWA,GACnB/a,EAAQkb,OAASA,GACjBlb,EAAQmb,YAAcA,GACtBnb,EAAQob,aAAeA,GACvBpb,EAAQqb,IAAMA,GACdrb,EAAQwR,SAAWA,GACnBxR,EAAQ2R,QAAUA,GAClB3R,EAAQ0R,SAAWA,GACnB1R,EAAQ4R,OAASA,GACjB5R,EAAQyc,KAAO3K,GACf9R,EAAQ8R,UAAYC,GACpB/R,EAAQuH,OAASA,EACjBvH,EAAQiH,YAAcA,EACtBjH,EAAQ2Q,aAAeA,GACvB3Q,EAAQsb,WAAaA,GACrBtb,EAAQgS,YAAcA,GACtBhS,EAAQub,MAAQA,GAChBvb,EAAQwb,WAAaA,GACrBxb,EAAQyb,YAAcA,GACtBzb,EAAQ0b,OAASA,GACjB1b,EAAQ2b,YAAcA,GACtB3b,EAAQ4b,aAAeA,GACvB5b,EAAQwS,QAAUA,GAClBxS,EAAQ6b,IAAMA,GACd7b,EAAQqN,IAAMA,GACdrN,EAAQ6W,SAAWA,GACnB7W,EAAQkY,UAAYA,GACpBlY,EAAQ8b,UAAYA,GACpB9b,EAAQ0S,eAAiBA,GACzB1S,EAAQ+b,gBAAkBA,GAC1B/b,EAAQ6S,QAAUA,GAClB7S,EAAQma,SAAWA,GACnBna,EAAQ0c,SAAWtJ,GACnBpT,EAAQoT,cAAgBC,GACxBrT,EAAQwT,cAAgBA,GACxBxT,EAAQwO,MAAQ8E,GAChBtT,EAAQ4T,KAAOA,GACf5T,EAAQyQ,OAASA,GACjBzQ,EAAQ8T,YAAcA,GACtB9T,EAAQiU,QAAUA,GAClBjU,EAAQqU,WAAaA,GACrBrU,EAAQgc,OAASA,GACjBhc,EAAQic,YAAcA,GACtBjc,EAAQkc,aAAeA,GACvBlc,EAAQuU,MAAQA,GAChBvU,EAAQoV,UAAYA,GACpBpV,EAAQya,IAAMA,GACdza,EAAQqV,OAASA,GACjBrV,EAAQia,aAAehL,GACvBjP,EAAQmc,KAAOA,GACfnc,EAAQqc,UAAYA,GACpBrc,EAAQsc,WAAaA,GACrBtc,EAAQsV,OAASA,GACjBtV,EAAQ2V,QAAUA,GAClB3V,EAAQ4U,MAAQA,GAChB5U,EAAQ2c,WAAahG,GACrB3W,EAAQwc,YAAcA,GACtBxc,EAAQsD,UAAYA,GACpBtD,EAAQgX,UAAYA,GACpBhX,EAAQkX,MAAQA,GAChBlX,EAAQmX,UAAYA,GACpBnX,EAAQiX,OAASA,GACjBjX,EAAQ4c,IAAMrB,GACdvb,EAAQ2d,SAAWnC,GACnBxb,EAAQ4d,UAAYnC,GACpBzb,EAAQ6c,IAAMV,GACdnc,EAAQ6d,SAAWxB,GACnBrc,EAAQ8d,UAAYxB,GACpBtc,EAAQ+d,KAAO7C,GACflb,EAAQge,UAAY7C,GACpBnb,EAAQie,WAAa7C,GACrBpb,EAAQ8c,QAAUhL,GAClB9R,EAAQ+c,cAAgBzB,GACxBtb,EAAQgd,aAAejL,GACvB/R,EAAQid,UAAY1V,EACpBvH,EAAQkd,gBAAkBvM,GAC1B3Q,EAAQmd,eAAiBlW,EACzBjH,EAAQod,OAAS3M,GACjBzQ,EAAQqd,MAAQ5M,GAChBzQ,EAAQsd,MAAQxJ,GAChB9T,EAAQud,OAAS7B,GACjB1b,EAAQwd,YAAc7B,GACtB3b,EAAQyd,aAAe7B,GACvB5b,EAAQ0d,SAAWxV"} \ No newline at end of file diff --git a/docs/.nojekyll b/docs/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 000000000..8f0f3109e --- /dev/null +++ b/docs/index.html @@ -0,0 +1 @@ + diff --git a/docs/v2/apply.js.html b/docs/v2/apply.js.html new file mode 100644 index 000000000..74f9eca9a --- /dev/null +++ b/docs/v2/apply.js.html @@ -0,0 +1,162 @@ + + + + + + + apply.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

apply.js

+ + + + + + + +
+
+
import slice from './internal/slice';
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @returns {Function} the partially-applied function
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ *     async.apply(fs.writeFile, 'testfile1', 'test1'),
+ *     async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ *     function(callback) {
+ *         fs.writeFile('testfile1', 'test1', callback);
+ *     },
+ *     function(callback) {
+ *         fs.writeFile('testfile2', 'test2', callback);
+ *     }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+export default function(fn/*, ...args*/) {
+    var args = slice(arguments, 1);
+    return function(/*callArgs*/) {
+        var callArgs = slice(arguments);
+        return fn.apply(null, args.concat(callArgs));
+    };
+};
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/applyEach.js.html b/docs/v2/applyEach.js.html new file mode 100644 index 000000000..e23335b6f --- /dev/null +++ b/docs/v2/applyEach.js.html @@ -0,0 +1,145 @@ + + + + + + + applyEach.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

applyEach.js

+ + + + + + + +
+
+
import applyEach from './internal/applyEach';
+import map from './map';
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ *     buckets,
+ *     async.applyEach([enableSearch, updateSchema]),
+ *     callback
+ * );
+ */
+export default applyEach(map);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/applyEachSeries.js.html b/docs/v2/applyEachSeries.js.html new file mode 100644 index 000000000..e73e2eab2 --- /dev/null +++ b/docs/v2/applyEachSeries.js.html @@ -0,0 +1,131 @@ + + + + + + + applyEachSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

applyEachSeries.js

+ + + + + + + +
+
+
import applyEach from './internal/applyEach';
+import mapSeries from './mapSeries';
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+export default applyEach(mapSeries);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/asyncify.js.html b/docs/v2/asyncify.js.html new file mode 100644 index 000000000..292df9035 --- /dev/null +++ b/docs/v2/asyncify.js.html @@ -0,0 +1,200 @@ + + + + + + + asyncify.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

asyncify.js

+ + + + + + + +
+
+
import isObject from 'lodash/isObject';
+import initialParams from './internal/initialParams';
+import setImmediate from './internal/setImmediate';
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2017 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function, or Promise-returning
+ * function to convert to an {@link AsyncFunction}.
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
+ * invoked with `(args..., callback)`.
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ *     async.apply(fs.readFile, filename, "utf8"),
+ *     async.asyncify(JSON.parse),
+ *     function (data, next) {
+ *         // data is the result of parsing the text.
+ *         // If there was a parsing error, it would have been caught.
+ *     }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ *     async.apply(fs.readFile, filename, "utf8"),
+ *     async.asyncify(function (contents) {
+ *         return db.model.create(contents);
+ *     }),
+ *     function (model, next) {
+ *         // `model` is the instantiated model object.
+ *         // If there was an error, this function would be skipped.
+ *     }
+ * ], callback);
+ *
+ * // es2017 example, though `asyncify` is not needed if your JS environment
+ * // supports async functions out of the box
+ * var q = async.queue(async.asyncify(async function(file) {
+ *     var intermediateStep = await processFile(file);
+ *     return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+export default function asyncify(func) {
+    return initialParams(function (args, callback) {
+        var result;
+        try {
+            result = func.apply(this, args);
+        } catch (e) {
+            return callback(e);
+        }
+        // if result is Promise object
+        if (isObject(result) && typeof result.then === 'function') {
+            result.then(function(value) {
+                invokeCallback(callback, null, value);
+            }, function(err) {
+                invokeCallback(callback, err.message ? err : new Error(err));
+            });
+        } else {
+            callback(null, result);
+        }
+    });
+}
+
+function invokeCallback(callback, error, value) {
+    try {
+        callback(error, value);
+    } catch (e) {
+        setImmediate(rethrow, e);
+    }
+}
+
+function rethrow(error) {
+    throw error;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/auto.js.html b/docs/v2/auto.js.html new file mode 100644 index 000000000..fdc0f2389 --- /dev/null +++ b/docs/v2/auto.js.html @@ -0,0 +1,365 @@ + + + + + + + auto.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

auto.js

+ + + + + + + +
+
+
import arrayEach from 'lodash/_arrayEach';
+import forOwn from 'lodash/_baseForOwn';
+import indexOf from 'lodash/_baseIndexOf';
+import isArray from 'lodash/isArray';
+import okeys from 'lodash/keys';
+import noop from 'lodash/noop';
+
+import slice from './internal/slice';
+import once from './internal/once';
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * {@link AsyncFunction}s also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the {@link AsyncFunction} itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ *   functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ *   passing an `error` (which can be `null`) and the result of the function's
+ *   execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ *     // this function will just be passed a callback
+ *     readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ *     showData: ['readData', function(results, cb) {
+ *         // results.readData is the file's contents
+ *         // ...
+ *     }]
+ * }, callback);
+ *
+ * async.auto({
+ *     get_data: function(callback) {
+ *         console.log('in get_data');
+ *         // async code to get some data
+ *         callback(null, 'data', 'converted to array');
+ *     },
+ *     make_folder: function(callback) {
+ *         console.log('in make_folder');
+ *         // async code to create a directory to store a file in
+ *         // this is run at the same time as getting the data
+ *         callback(null, 'folder');
+ *     },
+ *     write_file: ['get_data', 'make_folder', function(results, callback) {
+ *         console.log('in write_file', JSON.stringify(results));
+ *         // once there is some data and the directory exists,
+ *         // write the data to a file in the directory
+ *         callback(null, 'filename');
+ *     }],
+ *     email_link: ['write_file', function(results, callback) {
+ *         console.log('in email_link', JSON.stringify(results));
+ *         // once the file is written let's email a link to it...
+ *         // results.write_file contains the filename returned by write_file.
+ *         callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ *     }]
+ * }, function(err, results) {
+ *     console.log('err = ', err);
+ *     console.log('results = ', results);
+ * });
+ */
+export default function (tasks, concurrency, callback) {
+    if (typeof concurrency === 'function') {
+        // concurrency is optional, shift the args.
+        callback = concurrency;
+        concurrency = null;
+    }
+    callback = once(callback || noop);
+    var keys = okeys(tasks);
+    var numTasks = keys.length;
+    if (!numTasks) {
+        return callback(null);
+    }
+    if (!concurrency) {
+        concurrency = numTasks;
+    }
+
+    var results = {};
+    var runningTasks = 0;
+    var hasError = false;
+
+    var listeners = Object.create(null);
+
+    var readyTasks = [];
+
+    // for cycle detection:
+    var readyToCheck = []; // tasks that have been identified as reachable
+    // without the possibility of returning to an ancestor task
+    var uncheckedDependencies = {};
+
+    forOwn(tasks, function (task, key) {
+        if (!isArray(task)) {
+            // no dependencies
+            enqueueTask(key, [task]);
+            readyToCheck.push(key);
+            return;
+        }
+
+        var dependencies = task.slice(0, task.length - 1);
+        var remainingDependencies = dependencies.length;
+        if (remainingDependencies === 0) {
+            enqueueTask(key, task);
+            readyToCheck.push(key);
+            return;
+        }
+        uncheckedDependencies[key] = remainingDependencies;
+
+        arrayEach(dependencies, function (dependencyName) {
+            if (!tasks[dependencyName]) {
+                throw new Error('async.auto task `' + key +
+                    '` has a non-existent dependency `' +
+                    dependencyName + '` in ' +
+                    dependencies.join(', '));
+            }
+            addListener(dependencyName, function () {
+                remainingDependencies--;
+                if (remainingDependencies === 0) {
+                    enqueueTask(key, task);
+                }
+            });
+        });
+    });
+
+    checkForDeadlocks();
+    processQueue();
+
+    function enqueueTask(key, task) {
+        readyTasks.push(function () {
+            runTask(key, task);
+        });
+    }
+
+    function processQueue() {
+        if (readyTasks.length === 0 && runningTasks === 0) {
+            return callback(null, results);
+        }
+        while(readyTasks.length && runningTasks < concurrency) {
+            var run = readyTasks.shift();
+            run();
+        }
+
+    }
+
+    function addListener(taskName, fn) {
+        var taskListeners = listeners[taskName];
+        if (!taskListeners) {
+            taskListeners = listeners[taskName] = [];
+        }
+
+        taskListeners.push(fn);
+    }
+
+    function taskComplete(taskName) {
+        var taskListeners = listeners[taskName] || [];
+        arrayEach(taskListeners, function (fn) {
+            fn();
+        });
+        processQueue();
+    }
+
+
+    function runTask(key, task) {
+        if (hasError) return;
+
+        var taskCallback = onlyOnce(function(err, result) {
+            runningTasks--;
+            if (arguments.length > 2) {
+                result = slice(arguments, 1);
+            }
+            if (err) {
+                var safeResults = {};
+                forOwn(results, function(val, rkey) {
+                    safeResults[rkey] = val;
+                });
+                safeResults[key] = result;
+                hasError = true;
+                listeners = Object.create(null);
+
+                callback(err, safeResults);
+            } else {
+                results[key] = result;
+                taskComplete(key);
+            }
+        });
+
+        runningTasks++;
+        var taskFn = wrapAsync(task[task.length - 1]);
+        if (task.length > 1) {
+            taskFn(results, taskCallback);
+        } else {
+            taskFn(taskCallback);
+        }
+    }
+
+    function checkForDeadlocks() {
+        // Kahn's algorithm
+        // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+        // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+        var currentTask;
+        var counter = 0;
+        while (readyToCheck.length) {
+            currentTask = readyToCheck.pop();
+            counter++;
+            arrayEach(getDependents(currentTask), function (dependent) {
+                if (--uncheckedDependencies[dependent] === 0) {
+                    readyToCheck.push(dependent);
+                }
+            });
+        }
+
+        if (counter !== numTasks) {
+            throw new Error(
+                'async.auto cannot execute tasks due to a recursive dependency'
+            );
+        }
+    }
+
+    function getDependents(taskName) {
+        var result = [];
+        forOwn(tasks, function (task, key) {
+            if (isArray(task) && indexOf(task, taskName, 0) >= 0) {
+                result.push(key);
+            }
+        });
+        return result;
+    }
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/autoInject.js.html b/docs/v2/autoInject.js.html new file mode 100644 index 000000000..c263d63bd --- /dev/null +++ b/docs/v2/autoInject.js.html @@ -0,0 +1,254 @@ + + + + + + + autoInject.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

autoInject.js

+ + + + + + + +
+
+
import auto from './auto';
+import forOwn from 'lodash/_baseForOwn';
+import arrayMap from 'lodash/_arrayMap';
+import isArray from 'lodash/isArray';
+import trim from 'lodash/trim';
+import wrapAsync from './internal/wrapAsync';
+import { isAsync } from './internal/wrapAsync';
+
+var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+function parseParams(func) {
+    func = func.toString().replace(STRIP_COMMENTS, '');
+    func = func.match(FN_ARGS)[2].replace(' ', '');
+    func = func ? func.split(FN_ARG_SPLIT) : [];
+    func = func.map(function (arg){
+        return trim(arg.replace(FN_ARG, ''));
+    });
+    return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ *   when finished, passing an `error` (which can be `null`) and the result of
+ *   the function's execution. The remaining parameters name other tasks on
+ *   which the task is dependent, and the results from those tasks are the
+ *   arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * //  The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ *     get_data: function(callback) {
+ *         // async code to get some data
+ *         callback(null, 'data', 'converted to array');
+ *     },
+ *     make_folder: function(callback) {
+ *         // async code to create a directory to store a file in
+ *         // this is run at the same time as getting the data
+ *         callback(null, 'folder');
+ *     },
+ *     write_file: function(get_data, make_folder, callback) {
+ *         // once there is some data and the directory exists,
+ *         // write the data to a file in the directory
+ *         callback(null, 'filename');
+ *     },
+ *     email_link: function(write_file, callback) {
+ *         // once the file is written let's email a link to it...
+ *         // write_file contains the filename returned by write_file.
+ *         callback(null, {'file':write_file, 'email':'user@example.com'});
+ *     }
+ * }, function(err, results) {
+ *     console.log('err = ', err);
+ *     console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier.  To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ *     //...
+ *     write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ *         callback(null, 'filename');
+ *     }],
+ *     email_link: ['write_file', function(write_file, callback) {
+ *         callback(null, {'file':write_file, 'email':'user@example.com'});
+ *     }]
+ *     //...
+ * }, function(err, results) {
+ *     console.log('err = ', err);
+ *     console.log('email_link = ', results.email_link);
+ * });
+ */
+export default function autoInject(tasks, callback) {
+    var newTasks = {};
+
+    forOwn(tasks, function (taskFn, key) {
+        var params;
+        var fnIsAsync = isAsync(taskFn);
+        var hasNoDeps =
+            (!fnIsAsync && taskFn.length === 1) ||
+            (fnIsAsync && taskFn.length === 0);
+
+        if (isArray(taskFn)) {
+            params = taskFn.slice(0, -1);
+            taskFn = taskFn[taskFn.length - 1];
+
+            newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+        } else if (hasNoDeps) {
+            // no dependencies, use the function as-is
+            newTasks[key] = taskFn;
+        } else {
+            params = parseParams(taskFn);
+            if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
+                throw new Error("autoInject task functions require explicit parameters.");
+            }
+
+            // remove callback param
+            if (!fnIsAsync) params.pop();
+
+            newTasks[key] = params.concat(newTask);
+        }
+
+        function newTask(results, taskCb) {
+            var newArgs = arrayMap(params, function (name) {
+                return results[name];
+            });
+            newArgs.push(taskCb);
+            wrapAsync(taskFn).apply(null, newArgs);
+        }
+    });
+
+    auto(newTasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/cargo.js.html b/docs/v2/cargo.js.html new file mode 100644 index 000000000..48e54bc14 --- /dev/null +++ b/docs/v2/cargo.js.html @@ -0,0 +1,190 @@ + + + + + + + cargo.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

cargo.js

+ + + + + + + +
+
+
import queue from './internal/queue';
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An asynchronous function for processing an array
+ * of queued tasks. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ *     for (var i=0; i<tasks.length; i++) {
+ *         console.log('hello ' + tasks[i].name);
+ *     }
+ *     callback();
+ * }, 2);
+ *
+ * // add some items
+ * cargo.push({name: 'foo'}, function(err) {
+ *     console.log('finished processing foo');
+ * });
+ * cargo.push({name: 'bar'}, function(err) {
+ *     console.log('finished processing bar');
+ * });
+ * cargo.push({name: 'baz'}, function(err) {
+ *     console.log('finished processing baz');
+ * });
+ */
+export default function cargo(worker, payload) {
+    return queue(worker, 1, payload);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/compose.js.html b/docs/v2/compose.js.html new file mode 100644 index 000000000..ece312a54 --- /dev/null +++ b/docs/v2/compose.js.html @@ -0,0 +1,149 @@ + + + + + + + compose.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

compose.js

+ + + + + + + +
+
+
import seq from './seq';
+import slice from './internal/slice';
+
+/**
+ * Creates a function which is a composition of the passed asynchronous
+ * functions. Each function consumes the return value of the function that
+ * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
+ * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name compose
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {...AsyncFunction} functions - the asynchronous functions to compose
+ * @returns {Function} an asynchronous function that is the composed
+ * asynchronous `functions`
+ * @example
+ *
+ * function add1(n, callback) {
+ *     setTimeout(function () {
+ *         callback(null, n + 1);
+ *     }, 10);
+ * }
+ *
+ * function mul3(n, callback) {
+ *     setTimeout(function () {
+ *         callback(null, n * 3);
+ *     }, 10);
+ * }
+ *
+ * var add1mul3 = async.compose(mul3, add1);
+ * add1mul3(4, function (err, result) {
+ *     // result now equals 15
+ * });
+ */
+export default function(/*...args*/) {
+    return seq.apply(null, slice(arguments).reverse());
+};
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/concat.js.html b/docs/v2/concat.js.html new file mode 100644 index 000000000..8c4e071f7 --- /dev/null +++ b/docs/v2/concat.js.html @@ -0,0 +1,137 @@ + + + + + + + concat.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concat.js

+ + + + + + + +
+
+
import doLimit from './internal/doLimit';
+import concatLimit from './concatLimit';
+
+/**
+ * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
+ * the concatenated list. The `iteratee`s are called in parallel, and the
+ * results are concatenated as they return. There is no guarantee that the
+ * results array will be returned in the original order of `coll` passed to the
+ * `iteratee` function.
+ *
+ * @name concat
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
+ * which should use an array as its result. Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @example
+ *
+ * async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+ *     // files is now a list of filenames that exist in the 3 directories
+ * });
+ */
+export default doLimit(concatLimit, Infinity);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/concatLimit.js.html b/docs/v2/concatLimit.js.html new file mode 100644 index 000000000..820ee479d --- /dev/null +++ b/docs/v2/concatLimit.js.html @@ -0,0 +1,152 @@ + + + + + + + concatLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concatLimit.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import wrapAsync from './internal/wrapAsync';
+import slice from './internal/slice';
+import mapLimit from './mapLimit';
+
+var _concat = Array.prototype.concat;
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name concatLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
+ * which should use an array as its result. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ */
+export default function(coll, limit, iteratee, callback) {
+    callback = callback || noop;
+    var _iteratee = wrapAsync(iteratee);
+    mapLimit(coll, limit, function(val, callback) {
+        _iteratee(val, function(err /*, ...args*/) {
+            if (err) return callback(err);
+            return callback(null, slice(arguments, 1));
+        });
+    }, function(err, mapResults) {
+        var result = [];
+        for (var i = 0; i < mapResults.length; i++) {
+            if (mapResults[i]) {
+                result = _concat.apply(result, mapResults[i]);
+            }
+        }
+
+        return callback(err, result);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/concatSeries.js.html b/docs/v2/concatSeries.js.html new file mode 100644 index 000000000..f85e05c2d --- /dev/null +++ b/docs/v2/concatSeries.js.html @@ -0,0 +1,130 @@ + + + + + + + concatSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concatSeries.js

+ + + + + + + +
+
+
import doLimit from './internal/doLimit';
+import concatLimit from './concatLimit';
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
+ *
+ * @name concatSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
+ * The iteratee should complete with an array an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback(err)] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ */
+export default doLimit(concatLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/constant.js.html b/docs/v2/constant.js.html new file mode 100644 index 000000000..720f3b18b --- /dev/null +++ b/docs/v2/constant.js.html @@ -0,0 +1,160 @@ + + + + + + + constant.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

constant.js

+ + + + + + + +
+
+
import slice from './internal/slice';
+
+/**
+ * Returns a function that when called, calls-back with the values provided.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
+ *
+ * @name constant
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {...*} arguments... - Any number of arguments to automatically invoke
+ * callback with.
+ * @returns {AsyncFunction} Returns a function that when invoked, automatically
+ * invokes the callback with the previous given arguments.
+ * @example
+ *
+ * async.waterfall([
+ *     async.constant(42),
+ *     function (value, next) {
+ *         // value === 42
+ *     },
+ *     //...
+ * ], callback);
+ *
+ * async.waterfall([
+ *     async.constant(filename, "utf8"),
+ *     fs.readFile,
+ *     function (fileData, next) {
+ *         //...
+ *     }
+ *     //...
+ * ], callback);
+ *
+ * async.auto({
+ *     hostname: async.constant("https://server.net/"),
+ *     port: findFreePort,
+ *     launchServer: ["hostname", "port", function (options, cb) {
+ *         startServer(options, cb);
+ *     }],
+ *     //...
+ * }, callback);
+ */
+export default function(/*...values*/) {
+    var values = slice(arguments);
+    var args = [null].concat(values);
+    return function (/*...ignoredArgs, callback*/) {
+        var callback = arguments[arguments.length - 1];
+        return callback.apply(this, args);
+    };
+};
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/data/methodNames.json b/docs/v2/data/methodNames.json new file mode 100644 index 000000000..bc1d596ac --- /dev/null +++ b/docs/v2/data/methodNames.json @@ -0,0 +1,79 @@ +[ + "apply", + "applyEach", + "applyEachSeries", + "asyncify (wrapSync)", + "auto", + "autoInject", + "cargo", + "compose", + "concat", + "concatLimit", + "concatSeries", + "constant", + "detect (find)", + "detectLimit (findLimit)", + "detectSeries (findSeries)", + "dir", + "doDuring", + "doUntil", + "doWhilst", + "during", + "each (forEach)", + "eachLimit (forEachLimit)", + "eachOf (forEachOf)", + "eachOfLimit (forEachOfLimit)", + "eachOfSeries (forEachOfSeries)", + "eachSeries (forEachSeries)", + "ensureAsync", + "every (all)", + "everyLimit (allLimit)", + "everySeries (allSeries)", + "filter (select)", + "filterLimit (selectLimit)", + "filterSeries (selectSeries)", + "forever", + "groupBy", + "groupByLimit", + "groupBySeries", + "log", + "map", + "mapLimit", + "mapSeries", + "mapValues", + "mapValuesLimit", + "mapValuesSeries", + "memoize", + "nextTick", + "parallel", + "parallelLimit", + "priorityQueue", + "queue", + "race", + "reduce (foldl)", + "reduceRight (foldr)", + "reflect", + "reflectAll", + "reject", + "rejectLimit", + "rejectSeries", + "retry", + "retryable", + "seq", + "series", + "setImmediate", + "some (any)", + "someLimit (anyLimit)", + "someSeries (anySeries)", + "sortBy", + "timeout", + "times", + "timesLimit", + "timesSeries", + "transform", + "tryEach", + "unmemoize", + "until", + "waterfall", + "whilst" +] diff --git a/docs/v2/data/sourceFiles.json b/docs/v2/data/sourceFiles.json new file mode 100644 index 000000000..2132207dc --- /dev/null +++ b/docs/v2/data/sourceFiles.json @@ -0,0 +1,80 @@ +[ + "apply.js.html", + "applyEach.js.html", + "applyEachSeries.js.html", + "asyncify.js.html", + "auto.js.html", + "autoInject.js.html", + "cargo.js.html", + "compose.js.html", + "concat.js.html", + "concatLimit.js.html", + "concatSeries.js.html", + "constant.js.html", + "detect.js.html", + "detectLimit.js.html", + "detectSeries.js.html", + "dir.js.html", + "doDuring.js.html", + "doUntil.js.html", + "doWhilst.js.html", + "during.js.html", + "each.js.html", + "eachLimit.js.html", + "eachOf.js.html", + "eachOfLimit.js.html", + "eachOfSeries.js.html", + "eachSeries.js.html", + "ensureAsync.js.html", + "every.js.html", + "everyLimit.js.html", + "everySeries.js.html", + "filter.js.html", + "filterLimit.js.html", + "filterSeries.js.html", + "forever.js.html", + "groupBy.js.html", + "groupByLimit.js.html", + "groupBySeries.js.html", + "index.js.html", + "log.js.html", + "map.js.html", + "mapLimit.js.html", + "mapSeries.js.html", + "mapValues.js.html", + "mapValuesLimit.js.html", + "mapValuesSeries.js.html", + "memoize.js.html", + "nextTick.js.html", + "parallel.js.html", + "parallelLimit.js.html", + "priorityQueue.js.html", + "queue.js.html", + "race.js.html", + "reduce.js.html", + "reduceRight.js.html", + "reflect.js.html", + "reflectAll.js.html", + "reject.js.html", + "rejectLimit.js.html", + "rejectSeries.js.html", + "retry.js.html", + "retryable.js.html", + "seq.js.html", + "series.js.html", + "setImmediate.js.html", + "some.js.html", + "someLimit.js.html", + "someSeries.js.html", + "sortBy.js.html", + "timeout.js.html", + "times.js.html", + "timesLimit.js.html", + "timesSeries.js.html", + "transform.js.html", + "tryEach.js.html", + "unmemoize.js.html", + "until.js.html", + "waterfall.js.html", + "whilst.js.html" +] diff --git a/docs/v2/detect.js.html b/docs/v2/detect.js.html new file mode 100644 index 000000000..36e3e1b08 --- /dev/null +++ b/docs/v2/detect.js.html @@ -0,0 +1,150 @@ + + + + + + + detect.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detect.js

+ + + + + + + +
+
+
import identity from 'lodash/identity';
+
+import createTester from './internal/createTester';
+import doParallel from './internal/doParallel';
+import findGetResult from './internal/findGetResult';
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ *     fs.access(filePath, function(err) {
+ *         callback(null, !err)
+ *     });
+ * }, function(err, result) {
+ *     // result now equals the first file in the list that exists
+ * });
+ */
+export default doParallel(createTester(identity, findGetResult));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/detectLimit.js.html b/docs/v2/detectLimit.js.html new file mode 100644 index 000000000..efa5667d9 --- /dev/null +++ b/docs/v2/detectLimit.js.html @@ -0,0 +1,137 @@ + + + + + + + detectLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detectLimit.js

+ + + + + + + +
+
+
import identity from 'lodash/identity';
+
+import createTester from './internal/createTester';
+import doParallelLimit from './internal/doParallelLimit';
+import findGetResult from './internal/findGetResult';
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+export default doParallelLimit(createTester(identity, findGetResult));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/detectSeries.js.html b/docs/v2/detectSeries.js.html new file mode 100644 index 000000000..9aca83c94 --- /dev/null +++ b/docs/v2/detectSeries.js.html @@ -0,0 +1,132 @@ + + + + + + + detectSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detectSeries.js

+ + + + + + + +
+
+
import detectLimit from './detectLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+export default doLimit(detectLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/dir.js.html b/docs/v2/dir.js.html new file mode 100644 index 000000000..357552d9e --- /dev/null +++ b/docs/v2/dir.js.html @@ -0,0 +1,140 @@ + + + + + + + dir.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

dir.js

+ + + + + + + +
+
+
import consoleFunc from './internal/consoleFunc';
+
+/**
+ * Logs the result of an [`async` function]{@link AsyncFunction} to the
+ * `console` using `console.dir` to display the properties of the resulting object.
+ * Only works in Node.js or in browsers that support `console.dir` and
+ * `console.error` (such as FF and Chrome).
+ * If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ *     setTimeout(function() {
+ *         callback(null, {hello: name});
+ *     }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+export default consoleFunc('dir');
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/doDuring.js.html b/docs/v2/doDuring.js.html new file mode 100644 index 000000000..cfad3a203 --- /dev/null +++ b/docs/v2/doDuring.js.html @@ -0,0 +1,155 @@ + + + + + + + doDuring.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

doDuring.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import slice from './internal/slice';
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
+ * the order of operations, the arguments `test` and `fn` are switched.
+ *
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
+ * @name doDuring
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
+ * @category Control Flow
+ * @param {AsyncFunction} fn - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error if one occurred, otherwise `null`.
+ */
+export default function doDuring(fn, test, callback) {
+    callback = onlyOnce(callback || noop);
+    var _fn = wrapAsync(fn);
+    var _test = wrapAsync(test);
+
+    function next(err/*, ...args*/) {
+        if (err) return callback(err);
+        var args = slice(arguments, 1);
+        args.push(check);
+        _test.apply(this, args);
+    };
+
+    function check(err, truth) {
+        if (err) return callback(err);
+        if (!truth) return callback(null);
+        _fn(next);
+    }
+
+    check(null, true);
+
+}
+
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/doUntil.js.html b/docs/v2/doUntil.js.html new file mode 100644 index 000000000..b0f6099bc --- /dev/null +++ b/docs/v2/doUntil.js.html @@ -0,0 +1,135 @@ + + + + + + + doUntil.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

doUntil.js

+ + + + + + + +
+
+
import doWhilst from './doWhilst';
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with any non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ */
+export default function doUntil(iteratee, test, callback) {
+    doWhilst(iteratee, function() {
+        return !test.apply(this, arguments);
+    }, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/doWhilst.js.html b/docs/v2/doWhilst.js.html new file mode 100644 index 000000000..ab0c7d2ec --- /dev/null +++ b/docs/v2/doWhilst.js.html @@ -0,0 +1,147 @@ + + + + + + + doWhilst.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

doWhilst.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import slice from './internal/slice';
+
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - A function which is called each time `test`
+ * passes. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with any non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ */
+export default function doWhilst(iteratee, test, callback) {
+    callback = onlyOnce(callback || noop);
+    var _iteratee = wrapAsync(iteratee);
+    var next = function(err/*, ...args*/) {
+        if (err) return callback(err);
+        var args = slice(arguments, 1);
+        if (test.apply(this, args)) return _iteratee(next);
+        callback.apply(null, [null].concat(args));
+    };
+    _iteratee(next);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/docs.html b/docs/v2/docs.html new file mode 100644 index 000000000..a15648041 --- /dev/null +++ b/docs/v2/docs.html @@ -0,0 +1,17701 @@ + + + + + + + + async - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

async

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via +npm install --save async, it can also be used directly in the browser.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +

Collections

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for manipulating collections, such as +arrays and objects.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) concat(coll, iteratee, callback(err)opt)

+ + + + + +
+
import concat from 'async/concat';

Applies iteratee to each item in coll, concatenating the results. Returns +the concatenated list. The iteratees are called in parallel, and the +results are concatenated as they return. There is no guarantee that the +results array will be returned in the original order of coll passed to the +iteratee function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback(err) + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + +
Example
+ +
async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+    // files is now a list of filenames that exist in the 3 directories
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) concatLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import concatLimit from 'async/concatLimit';

The same as concat but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) concatSeries(coll, iteratee, callback(err)opt)

+ + + + + +
+
import concatSeries from 'async/concatSeries';

The same as concat but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll. +The iteratee should complete with an array an array of results. +Invoked with (item, callback).

callback(err) + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detect(coll, iteratee, callbackopt)

+ + + + + +
+
import detect from 'async/detect';

Returns the first value in coll that passes an async truth test. The +iteratee is applied in parallel, meaning the first iteratee to return +true will fire the detect callback with that result. That means the +result might not be the first item in the original coll (in terms of order) +that passes the test. +If order within the original coll is important, then look at +detectSeries.

+
+ + + +
+
Alias:
+
  • find
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + +
Example
+ +
async.detect(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // result now equals the first file in the list that exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) detectLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import detectLimit from 'async/detectLimit';

The same as detect but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • findLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detectSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import detectSeries from 'async/detectSeries';

The same as detect but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • findSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) each(coll, iteratee, callbackopt)

+ + + + + +
+
import each from 'async/each';

Applies the function iteratee to each item in coll, in parallel. +The iteratee is called with an item from the list, and a callback for when +it has finished. If the iteratee passes an error to its callback, the +main callback (for the each function) is immediately called with the +error.

+

Note, that since this function applies iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEach
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to +each item in coll. Invoked with (item, callback). +The array index is not passed to the iteratee. +If you need the index, use eachOf.

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + +
Example
+ +
// assuming openFiles is an array of file names and saveFile is a function
+// to save the modified contents of that file:
+
+async.each(openFiles, saveFile, function(err){
+  // if any of the saves produced an error, err would equal that error
+});
+
+// assuming openFiles is an array of file names
+async.each(openFiles, function(file, callback) {
+
+    // Perform operation on file here.
+    console.log('Processing file ' + file);
+
+    if( file.length > 32 ) {
+      console.log('This file name is too long');
+      callback('File name too long');
+    } else {
+      // Do work to process file here
+      console.log('File processed');
+      callback();
+    }
+}, function(err) {
+    // if any of the file processing produced an error, err would equal that error
+    if( err ) {
+      // One of the iterations produced an error.
+      // All processing will now stop.
+      console.log('A file failed to process');
+    } else {
+      console.log('All files have been processed successfully');
+    }
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) eachLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import eachLimit from 'async/eachLimit';

The same as each but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • forEachLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfLimit. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOf(coll, iteratee, callbackopt)

+ + + + + +
+
import eachOf from 'async/eachOf';

Like each, except that it passes the key (or index) as the second argument +to the iteratee.

+
+ + + +
+
Alias:
+
  • forEachOf
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each +item in coll. +The key is the item's key, or index in the case of an array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + +
Example
+ +
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+var configs = {};
+
+async.forEachOf(obj, function (value, key, callback) {
+    fs.readFile(__dirname + value, "utf8", function (err, data) {
+        if (err) return callback(err);
+        try {
+            configs[key] = JSON.parse(data);
+        } catch (e) {
+            return callback(e);
+        }
+        callback();
+    });
+}, function (err) {
+    if (err) console.error(err.message);
+    // configs is now a map of JSON data
+    doSomethingWith(configs);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import eachOfLimit from 'async/eachOfLimit';

The same as eachOf but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • forEachOfLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. The key is the item's key, or index in the case of an +array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import eachOfSeries from 'async/eachOfSeries';

The same as eachOf but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachOfSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import eachSeries from 'async/eachSeries';

The same as each but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfSeries. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) every(coll, iteratee, callbackopt)

+ + + + + +
+
import every from 'async/every';

Returns true if every element in coll satisfies an async test. If any +iteratee call returns false, the main callback is immediately called.

+
+ + + +
+
Alias:
+
  • all
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + +
Example
+ +
async.every(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // if result is true then every file exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) everyLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import everyLimit from 'async/everyLimit';

The same as every but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • allLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) everySeries(coll, iteratee, callbackopt)

+ + + + + +
+
import everySeries from 'async/everySeries';

The same as every but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • allSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in series. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filter(coll, iteratee, callbackopt)

+ + + + + +
+
import filter from 'async/filter';

Returns a new array of all the values in coll which pass an async truth +test. This operation is performed in parallel, but the results array will be +in the same order as the original.

+
+ + + +
+
Alias:
+
  • select
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.filter(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, results) {
+    // results now equals an array of the existing files
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) filterLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import filterLimit from 'async/filterLimit';

The same as filter but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • selectLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filterSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import filterSeries from 'async/filterSeries';

The same as filter but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • selectSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results)

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBy(coll, iteratee, callbackopt)

+ + + + + +
+
import groupBy from 'async/groupBy';

Returns a new object, where each value corresponds to an array of items, from +coll, that returned the corresponding key. That is, the keys of the object +correspond to the values passed to the iteratee callback.

+

Note: Since this function applies the iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order. +However, the values for each key in the result will be in the same order as +the original coll. For Objects, the values will roughly be in the order of +the original Objects' keys (but this can vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + +
Example
+ +
async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
+    db.findById(userId, function(err, user) {
+        if (err) return callback(err);
+        return callback(null, user.age);
+    });
+}, function(err, result) {
+    // result is object containing the userIds grouped by age
+    // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) groupByLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import groupByLimit from 'async/groupByLimit';

The same as groupBy but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBySeries(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import groupBySeries from 'async/groupBySeries';

The same as groupBy but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) map(coll, iteratee, callbackopt)

+ + + + + +
+
import map from 'async/map';

Produces a new collection of values by mapping each value in coll through +the iteratee function. The iteratee is called with an item from coll +and a callback for when it has finished processing. Each of these callback +takes 2 arguments: an error, and the transformed item from coll. If +iteratee passes an error to its callback, the main callback (for the +map function) is immediately called with the error.

+

Note, that since this function applies the iteratee to each item in +parallel, there is no guarantee that the iteratee functions will complete +in order. However, the results array will be in the same order as the +original coll.

+

If map is passed an Object, the results will be an Array. The results +will roughly be in the order of the original Objects' keys (but this can +vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an Array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+    // results is now an array of stats for each file
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import mapLimit from 'async/mapLimit';

The same as map but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import mapSeries from 'async/mapSeries';

The same as map but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValues(obj, iteratee, callbackopt)

+ + + + + +
+
import mapValues from 'async/mapValues';

A relative of map, designed for use with objects.

+

Produces a new Object by mapping each value of obj through the iteratee +function. The iteratee is called each value and key from obj and a +callback for when it has finished processing. Each of these callbacks takes +two arguments: an error, and the transformed item from obj. If iteratee +passes an error to its callback, the main callback (for the mapValues +function) is immediately called with the error.

+

Note, the order of the keys in the result is not guaranteed. The keys will +be roughly in the order they complete, (but this is very engine-specific)

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + +
Example
+ +
async.mapValues({
+    f1: 'file1',
+    f2: 'file2',
+    f3: 'file3'
+}, function (file, key, callback) {
+  fs.stat(file, callback);
+}, function(err, result) {
+    // result is now a map of stats for each file, e.g.
+    // {
+    //     f1: [stats for file1],
+    //     f2: [stats for file2],
+    //     f3: [stats for file3]
+    // }
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesLimit(obj, limit, iteratee, callbackopt)

+ + + + + +
+
import mapValuesLimit from 'async/mapValuesLimit';

The same as mapValues but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesSeries(obj, iteratee, callbackopt)

+ + + + + +
+
import mapValuesSeries from 'async/mapValuesSeries';

The same as mapValues but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reduce(coll, memo, iteratee, callbackopt)

+ + + + + +
+
import reduce from 'async/reduce';

Reduces coll into a single value using an async iteratee to return each +successive step. memo is the initial state of the reduction. This function +only operates in series.

+

For performance reasons, it may make sense to split a call to this function +into a parallel map, and then use the normal Array.prototype.reduce on the +results. This function is for situations where each step in the reduction +needs to be async; if you can get the data before reducing it, then it's +probably a good idea to do so.

+
+ + + +
+
Alias:
+
  • foldl
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + + + +
Example
+ +
async.reduce([1,2,3], 0, function(memo, item, callback) {
+    // pointless async:
+    process.nextTick(function() {
+        callback(null, memo + item)
+    });
+}, function(err, result) {
+    // result is now equal to the last value of memo, which is 6
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reduceRight(array, memo, iteratee, callbackopt)

+ + + + + +
+
import reduceRight from 'async/reduceRight';

Same as reduce, only operates on array in reverse order.

+
+ + + +
+
Alias:
+
  • foldr
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
array + + +Array + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reject(coll, iteratee, callbackopt)

+ + + + + +
+
import reject from 'async/reject';

The opposite of filter. Removes values that pass an async truth test.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.reject(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, results) {
+    // results now equals an array of missing files
+    createFiles(results);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import rejectLimit from 'async/rejectLimit';

The same as reject but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import rejectSeries from 'async/rejectSeries';

The same as reject but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) some(coll, iteratee, callbackopt)

+ + + + + +
+
import some from 'async/some';

Returns true if at least one element in the coll satisfies an async test. +If any iteratee call returns true, the main callback is immediately +called.

+
+ + + +
+
Alias:
+
  • any
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + +
Example
+ +
async.some(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // if result is true then at least one of the files exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) someLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import someLimit from 'async/someLimit';

The same as some but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • anyLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) someSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import someSeries from 'async/someSeries';

The same as some but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • anySeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in series. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) sortBy(coll, iteratee, callback)

+ + + + + +
+
import sortBy from 'async/sortBy';

Sorts a list by the results of running each coll value through an async +iteratee.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a value to use as the sort criteria as +its result. +Invoked with (item, callback).

callback + + +function + + + + + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is the items +from the original coll sorted by the values returned by the iteratee +calls. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.sortBy(['file1','file2','file3'], function(file, callback) {
+    fs.stat(file, function(err, stats) {
+        callback(err, stats.mtime);
+    });
+}, function(err, results) {
+    // results is now the original array of files sorted by
+    // modified date
+});
+
+// By modifying the callback parameter the
+// sorting order can be influenced:
+
+// ascending order
+async.sortBy([1,9,3,5], function(x, callback) {
+    callback(null, x);
+}, function(err,result) {
+    // result callback
+});
+
+// descending order
+async.sortBy([1,9,3,5], function(x, callback) {
+    callback(null, x*-1);    //<- x*-1 instead of x, turns the order around
+}, function(err,result) {
+    // result callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) transform(coll, accumulatoropt, iteratee, callbackopt)

+ + + + + +
+
import transform from 'async/transform';

A relative of reduce. Takes an Object or Array, and iterates over each +element in series, each step potentially mutating an accumulator value. +The type of the accumulator defaults to the type of collection passed in.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

accumulator + + +* + + + + + + <optional> + +

The initial state of the transform. If omitted, +it will default to an empty Object or Array, depending on the type of coll

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +collection that potentially modifies the accumulator. +Invoked with (accumulator, item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the transformed accumulator. +Invoked with (err, result).

+ + + + + + +
Examples
+ +
async.transform([1,2,3], function(acc, item, index, callback) {
+    // pointless async:
+    process.nextTick(function() {
+        acc.push(item * 2)
+        callback(null)
+    });
+}, function(err, result) {
+    // result is now equal to [2, 4, 6]
+});
+ +
async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+    setImmediate(function () {
+        obj[key] = val * 2;
+        callback();
+    })
+}, function (err, result) {
+    // result is equal to {a: 2, b: 4, c: 6}
+})
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +

Control Flow

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for controlling the flow through a script.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) applyEach(fns, …argsopt, callbackopt) → {function}

+ + + + + +
+
import applyEach from 'async/applyEach';

Applies the provided arguments to each function in the array, calling +callback after all functions have completed. If you only provide the first +argument, fns, then it will return a function which lets you pass in the +arguments as if it were a single function call. If more arguments are +provided, callback is required while args is still optional.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of AsyncFunctions +to all call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • If only the first argument, fns, is provided, it will +return a function which lets you pass in the arguments as if it were a single +function call. The signature is (..args, callback). If invoked with any +arguments, callback is required.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+
+// partial application example:
+async.each(
+    buckets,
+    async.applyEach([enableSearch, updateSchema]),
+    callback
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) applyEachSeries(fns, …argsopt, callbackopt) → {function}

+ + + + + +
+
import applyEachSeries from 'async/applyEachSeries';

The same as applyEach but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of AsyncFunctions to all +call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • If only the first argument is provided, it will return +a function which lets you pass in the arguments as if it were a single +function call.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) auto(tasks, concurrencyopt, callbackopt)

+ + + + + +
+
import auto from 'async/auto';

Determines the best order for running the AsyncFunctions in tasks, based on +their requirements. Each function can optionally depend on other functions +being completed first, and each function is run as soon as its requirements +are satisfied.

+

If any of the AsyncFunctions pass an error to their callback, the auto sequence +will stop. Further tasks will not execute (so any other functions depending +on it will not run), and the main callback is immediately called with the +error.

+

AsyncFunctions also receive an object containing the results of functions which +have completed so far as the first argument, if they have dependencies. If a +task function has no dependencies, it will only be passed a callback.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
tasks + + +Object + + + + + + + +

An object. Each of its properties is either a +function or an array of requirements, with the AsyncFunction itself the last item +in the array. The object's key of a property serves as the name of the task +defined by that property, i.e. can be used when specifying requirements for +other tasks. The function receives one or two arguments:

+
    +
  • a results object, containing the results of the previously executed +functions, only passed if the task has any dependencies,
  • +
  • a callback(err, result) function, which must be called when finished, +passing an error (which can be null) and the result of the function's +execution.
  • +
concurrency + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for +determining the maximum number of tasks that can be run in parallel. By +default, as many as possible.

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback. Results are always returned; however, if an +error occurs, no further tasks will be performed, and the results object +will only contain partial results. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.auto({
+    // this function will just be passed a callback
+    readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+    showData: ['readData', function(results, cb) {
+        // results.readData is the file's contents
+        // ...
+    }]
+}, callback);
+
+async.auto({
+    get_data: function(callback) {
+        console.log('in get_data');
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        console.log('in make_folder');
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        console.log('in write_file', JSON.stringify(results));
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        console.log('in email_link', JSON.stringify(results));
+        // once the file is written let's email a link to it...
+        // results.write_file contains the filename returned by write_file.
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('results = ', results);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) autoInject(tasks, callbackopt)

+ + + + + +
+
import autoInject from 'async/autoInject';

A dependency-injected version of the async.auto function. Dependent +tasks are specified as parameters to the function, after the usual callback +parameter, with the parameter names matching the names of the tasks it +depends on. This can provide even more readable task graphs which can be +easier to maintain.

+

If a final callback is specified, the task results are similarly injected, +specified as named parameters after the initial error parameter.

+

The autoInject function is purely syntactic sugar and its semantics are +otherwise equivalent to async.auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Object + + + + + +

An object, each of whose properties is an AsyncFunction of +the form 'func([dependencies...], callback). The object's key of a property +serves as the name of the task defined by that property, i.e. can be used +when specifying requirements for other tasks.

+
    +
  • The callback parameter is a callback(err, result) which must be called +when finished, passing an error (which can be null) and the result of +the function's execution. The remaining parameters name other tasks on +which the task is dependent, and the results from those tasks are the +arguments of those parameters.
  • +
callback + + +function + + + + + + <optional> + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback, and a results object with any completed +task results, similar to auto.

+ + + + + + +
Example
+ +
//  The example from `auto` can be rewritten as follows:
+async.autoInject({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: function(get_data, make_folder, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    },
+    email_link: function(write_file, callback) {
+        // once the file is written let's email a link to it...
+        // write_file contains the filename returned by write_file.
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+
+// If you are using a JS minifier that mangles parameter names, `autoInject`
+// will not work with plain functions, since the parameter names will be
+// collapsed to a single letter identifier.  To work around this, you can
+// explicitly specify the names of the parameters your task function needs
+// in an array, similar to Angular.js dependency injection.
+
+// This still has an advantage over plain `auto`, since the results a task
+// depends on are still spread into arguments.
+async.autoInject({
+    //...
+    write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(write_file, callback) {
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }]
+    //...
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargo(worker, payloadopt) → {CargoObject}

+ + + + + +
+
import cargo from 'async/cargo';

Creates a cargo object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the payload limit). If the +worker is in progress, the task is queued until it becomes available. Once +the worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargo object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargo and inner queue.

+
+ + + +
+
+ Type +
+
+ +CargoObject + + +
+
+ + + + +
Example
+ +
// create a cargo object with payload 2
+var cargo = async.cargo(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2);
+
+// add some items
+cargo.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargo.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+cargo.push({name: 'baz'}, function(err) {
+    console.log('finished processing baz');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) compose(…functions) → {function}

+ + + + + +
+
import compose from 'async/compose';

Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions f(), g(), and h() would produce the result +of f(g(h())), only this version uses callbacks to obtain the return values.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

an asynchronous function that is the composed +asynchronous functions

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
function add1(n, callback) {
+    setTimeout(function () {
+        callback(null, n + 1);
+    }, 10);
+}
+
+function mul3(n, callback) {
+    setTimeout(function () {
+        callback(null, n * 3);
+    }, 10);
+}
+
+var add1mul3 = async.compose(mul3, add1);
+add1mul3(4, function (err, result) {
+    // result now equals 15
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) doDuring(fn, test, callbackopt)

+ + + + + +
+
import doDuring from 'async/doDuring';

The post-check version of during. To reflect the difference in +the order of operations, the arguments test and fn are switched.

+

Also a version of doWhilst with asynchronous test function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of fn. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of fn.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of fn has stopped. callback +will be passed an error if one occurred, otherwise null.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doUntil(iteratee, test, callbackopt)

+ + + + + +
+
import doUntil from 'async/doUntil';

Like 'doWhilst', except the test is inverted. Note the +argument ordering differs from until.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

test + + +function + + + + + +

synchronous truth test to perform after each +execution of iteratee. Invoked with any non-error callback results of +iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doWhilst(iteratee, test, callbackopt)

+ + + + + +
+
import doWhilst from 'async/doWhilst';

The post-check version of whilst. To reflect the difference in +the order of operations, the arguments test and iteratee are switched.

+

doWhilst is to whilst as do while is to while in plain JavaScript.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

A function which is called each time test +passes. Invoked with (callback).

test + + +function + + + + + +

synchronous truth test to perform after each +execution of iteratee. Invoked with any non-error callback results of +iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. +callback will be passed an error and any arguments passed to the final +iteratee's callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) during(test, fn, callbackopt)

+ + + + + +
+
import during from 'async/during';

Like whilst, except the test is an asynchronous function that +is passed a callback in the form of function (err, truth). If error is +passed to test or fn, the main callback is immediately called with the +value of the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of fn. Invoked with (callback).

fn + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of fn has stopped. callback +will be passed an error, if one occurred, otherwise null.

+ + + + + + +
Example
+ +
var count = 0;
+
+async.during(
+    function (callback) {
+        return callback(null, count < 5);
+    },
+    function (callback) {
+        count++;
+        setTimeout(callback, 1000);
+    },
+    function (err) {
+        // 5 seconds have passed
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) forever(fn, errbackopt)

+ + + + + +
+
import forever from 'async/forever';

Calls the asynchronous function fn with a callback parameter that allows it +to call itself again, in series, indefinitely. +If an error is passed to the callback then errback is called with the +error, and execution stops, otherwise it will never be called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function to call repeatedly. +Invoked with (next).

errback + + +function + + + + + + <optional> + +

when fn passes an error to it's callback, +this function will be called, and execution stops. Invoked with (err).

+ + + + + + +
Example
+ +
async.forever(
+    function(next) {
+        // next is suitable for passing to things that need a callback(err [, whatever]);
+        // it will result in this function being called again.
+    },
+    function(err) {
+        // if next is called with a value in its first parameter, it will appear
+        // in here as 'err', and execution will stop.
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallel(tasks, callbackopt)

+ + + + + +
+
import parallel from 'async/parallel';

Run the tasks collection of functions in parallel, without waiting until +the previous function has completed. If any of the functions pass an error to +its callback, the main callback is immediately called with the value of the +error. Once the tasks have completed, the results are passed to the final +callback as an array.

+

Note: parallel is about kicking-off I/O tasks in parallel, not about +parallel execution of code. If your tasks do not use any timers or perform +any I/O, they will actually be executed in series. Any synchronous setup +sections for each task will happen one after the other. JavaScript remains +single-threaded.

+

Hint: Use reflect to continue the +execution of other tasks when a task fails.

+

It is also possible to use an object instead of an array. Each property will +be run as a function and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.parallel.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + + + +
Example
+ +
async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// optional callback
+function(err, results) {
+    // the results array will equal ['one','two'] even though
+    // the second function had a shorter timeout.
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    // results is now equals to: {one: 1, two: 2}
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallelLimit(tasks, limit, callbackopt)

+ + + + + +
+
import parallelLimit from 'async/parallelLimit';

The same as parallel but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

limit + + +number + + + + + +

The maximum number of async operations at a time.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) priorityQueue(worker, concurrency) → {QueueObject}

+ + + + + +
+
import priorityQueue from 'async/priorityQueue';

The same as async.queue only tasks are assigned a priority and +completed in ascending priority order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
worker + + +AsyncFunction + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). +Invoked with (task, callback).

concurrency + + +number + + + + + +

An integer for determining how many worker +functions should be run in parallel. If omitted, the concurrency defaults to +1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A priorityQueue object to manage the tasks. There are two +differences between queue and priorityQueue objects:

+
    +
  • push(task, priority, [callback]) - priority should be a number. If an +array of tasks is given, all tasks will be assigned the same priority.
  • +
  • The unshift method was removed.
  • +
+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) queue(worker, concurrencyopt) → {QueueObject}

+ + + + + +
+
import queue from 'async/queue';

Creates a queue object with the specified concurrency. Tasks added to the +queue are processed in parallel (up to the concurrency limit). If all +workers are in progress, the task is queued until one becomes available. +Once a worker completes a task, that task's callback is called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). Invoked with (task, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A queue object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a queue object with concurrency 2
+var q = async.queue(function(task, callback) {
+    console.log('hello ' + task.name);
+    callback();
+}, 2);
+
+// assign a callback
+q.drain = function() {
+    console.log('all items have been processed');
+};
+
+// add some items to the queue
+q.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+q.push({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+
+// add some items to the queue (batch-wise)
+q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+    console.log('finished processing item');
+});
+
+// add some items to the front of the queue
+q.unshift({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) race(tasks, callback)

+ + + + + +
+
import race from 'async/race';

Runs the tasks array of functions in parallel, without waiting until the +previous function has completed. Once any of the tasks complete or pass an +error to its callback, the main callback is immediately called. It's +equivalent to Promise.race().

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array containing async functions +to run. Each function can complete with an optional result value.

callback + + +function + + + + + +

A callback to run once any of the functions have +completed. This function gets an error or result from the first function that +completed. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.race([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// main callback
+function(err, result) {
+    // the result will be equal to 'two' as it finishes earlier
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) retry(optsopt, task, callbackopt)

+ + + + + +
+
import retry from 'async/retry';

Attempts to get a successful response from task no more than times times +before returning an error. If the task is successful, the callback will be +passed the result of the successful task. If all attempts fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

Can be either an +object with times and interval or a number.

+
    +
  • times - The number of attempts to make before giving up. The default +is 5.
  • +
  • interval - The time to wait between retries, in milliseconds. The +default is 0. The interval may also be specified as a function of the +retry count (see example).
  • +
  • errorFilter - An optional synchronous function that is invoked on +erroneous result. If it returns true the retry attempts will continue; +if the function returns false the retry flow is aborted with the current +attempt's error and result being returned to the final callback. +Invoked with (err).
  • +
  • If opts is a number, the number specifies the number of times to retry, +with the default interval of 0.
  • +
task + + +AsyncFunction + + + + + + + +

An async function to retry. +Invoked with (callback).

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when the +task has succeeded, or after the final failed attempt. It receives the err +and result arguments of the last attempt at completing the task. Invoked +with (err, results).

+ + + + + + +
Example
+ +
// The `retry` function can be used as a stand-alone control flow by passing
+// a callback, as shown below:
+
+// try calling apiMethod 3 times
+async.retry(3, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 3 times, waiting 200 ms between each retry
+async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 10 times with exponential backoff
+// (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+async.retry({
+  times: 10,
+  interval: function(retryCount) {
+    return 50 * Math.pow(2, retryCount);
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod the default 5 times no delay between each retry
+async.retry(apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod only when error condition satisfies, all other
+// errors will abort the retry control flow and return to final callback
+async.retry({
+  errorFilter: function(err) {
+    return err.message === 'Temporary error'; // only retry on a specific error
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// to retry individual methods that are not as reliable within other
+// control flow functions, use the `retryable` wrapper:
+async.auto({
+    users: api.getUsers.bind(api),
+    payments: async.retryable(3, api.getPayments.bind(api))
+}, function(err, results) {
+    // do something with the results
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) retryable(optsopt, task) → {AsyncFunction}

+ + + + + +
+
import retryable from 'async/retryable';

A close relative of retry. This method +wraps a task and makes it retryable, rather than immediately calling it +with retries.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

optional +options, exactly the same as from retry

task + + +AsyncFunction + + + + + + + +

the asynchronous function to wrap. +This function will be passed any arguments passed to the returned wrapper. +Invoked with (...args, callback).

+ + + + +
Returns:
+ + +
+

The wrapped function, which when invoked, will +retry on an error, based on the parameters specified in opts. +This function will accept the same parameters as task.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.auto({
+    dep1: async.retryable(3, getFromFlakyService),
+    process: ["dep1", async.retryable(3, function (results, cb) {
+        maybeProcessData(results.dep1, cb);
+    })]
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) seq(…functions) → {function}

+ + + + + +
+
import seq from 'async/seq';

Version of the compose function that is more natural to read. Each function +consumes the return value of the previous function. It is the equivalent of +compose with the arguments reversed.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

a function that composes the functions in order

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// Requires lodash (or underscore), express3 and dresende's orm2.
+// Part of an app, that fetches cats of the logged user.
+// This example uses `seq` function to avoid overnesting and error
+// handling clutter.
+app.get('/cats', function(request, response) {
+    var User = request.models.User;
+    async.seq(
+        _.bind(User.get, User),  // 'User.get' has signature (id, callback(err, data))
+        function(user, fn) {
+            user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+        }
+    )(req.session.user_id, function (err, cats) {
+        if (err) {
+            console.error(err);
+            response.json({ status: 'error', message: err.message });
+        } else {
+            response.json({ status: 'ok', message: 'Cats found', data: cats });
+        }
+    });
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) series(tasks, callbackopt)

+ + + + + +
+
import series from 'async/series';

Run the functions in the tasks collection in series, each one running once +the previous function has completed. If any functions in the series pass an +error to its callback, no more functions are run, and callback is +immediately called with the value of the error. Otherwise, callback +receives an array of results when tasks have completed.

+

It is also possible to use an object instead of an array. Each property will +be run as a function, and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling + results from async.series.

+

Note that while many implementations preserve the order of object +properties, the ECMAScript Language Specification +explicitly states that

+
+

The mechanics and order of enumerating the properties is not specified.

+
+

So if you rely on the order in which your series of functions are executed, +and want this to work on all platforms, consider using an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection containing +async functions to run in series. +Each function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This function gets a results array (or object) +containing all the result arguments passed to the task callbacks. Invoked +with (err, result).

+ + + + + + +
Example
+ +
async.series([
+    function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    },
+    function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    }
+],
+// optional callback
+function(err, results) {
+    // results is now equal to ['one', 'two']
+});
+
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback){
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    // results is now equal to: {one: 1, two: 2}
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) times(n, iteratee, callback)

+ + + + + +
+
import times from 'async/times';

Calls the iteratee function n times, and accumulates results in the same +manner you would use with map.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + + + +
Example
+ +
// Pretend this is some complicated async factory
+var createUser = function(id, callback) {
+    callback(null, {
+        id: 'user' + id
+    });
+};
+
+// generate 5 users
+async.times(5, function(n, next) {
+    createUser(n, function(err, user) {
+        next(err, user);
+    });
+}, function(err, users) {
+    // we should now have 5 users
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesLimit(count, limit, iteratee, callback)

+ + + + + +
+
import timesLimit from 'async/timesLimit';

The same as times but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
count + + +number + + + + + +

The number of times to run the function.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see async.map.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesSeries(n, iteratee, callback)

+ + + + + +
+
import timesSeries from 'async/timesSeries';

The same as times but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) tryEach(tasks, callbackopt)

+ + + + + +
+
import tryEach from 'async/tryEach';

It runs each task in series but stops whenever any of the functions were +successful. If one of the tasks were successful, the callback will be +passed the result of the successful task. If all tasks fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection containing functions to +run, each function is passed a callback(err, result) it must call on +completion with an error err (which can be null) and an optional result +value.

callback + + +function + + + + + + <optional> + +

An optional callback which is called when one +of the tasks has succeeded, or all have failed. It receives the err and +result arguments of the last attempt at completing the task. Invoked with +(err, results).

+ + + + + + +
Example
+ +
async.tryEach([
+    function getDataFromFirstWebsite(callback) {
+        // Try getting the data from the first website
+        callback(err, data);
+    },
+    function getDataFromSecondWebsite(callback) {
+        // First website failed,
+        // Try getting the data from the backup website
+        callback(err, data);
+    }
+],
+// optional callback
+function(err, results) {
+    Now do something with the data.
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) until(test, iteratee, callbackopt)

+ + + + + +
+
import until from 'async/until';

Repeatedly call iteratee until test returns true. Calls callback when +stopped, or an error occurs. callback will be passed an error and any +arguments passed to the final iteratee's callback.

+

The inverse of whilst.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +function + + + + + +

synchronous truth test to perform before each +execution of iteratee. Invoked with ().

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) waterfall(tasks, callbackopt)

+ + + + + +
+
import waterfall from 'async/waterfall';

Runs the tasks array of functions in series, each passing their results to +the next in the array. However, if any of the tasks pass an error to their +own callback, the next function is not executed, and the main callback is +immediately called with the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array of async functions +to run. +Each function should complete with any number of result values. +The result values will be passed as arguments, in order, to the next task.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This will be passed the results of the last task's +callback. Invoked with (err, [results]).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.waterfall([
+    function(callback) {
+        callback(null, 'one', 'two');
+    },
+    function(arg1, arg2, callback) {
+        // arg1 now equals 'one' and arg2 now equals 'two'
+        callback(null, 'three');
+    },
+    function(arg1, callback) {
+        // arg1 now equals 'three'
+        callback(null, 'done');
+    }
+], function (err, result) {
+    // result now equals 'done'
+});
+
+// Or, with named functions:
+async.waterfall([
+    myFirstFunction,
+    mySecondFunction,
+    myLastFunction,
+], function (err, result) {
+    // result now equals 'done'
+});
+function myFirstFunction(callback) {
+    callback(null, 'one', 'two');
+}
+function mySecondFunction(arg1, arg2, callback) {
+    // arg1 now equals 'one' and arg2 now equals 'two'
+    callback(null, 'three');
+}
+function myLastFunction(arg1, callback) {
+    // arg1 now equals 'three'
+    callback(null, 'done');
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) whilst(test, iteratee, callbackopt)

+ + + + + +
+
import whilst from 'async/whilst';

Repeatedly call iteratee, while test returns true. Calls callback when +stopped, or an error occurs.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +function + + + + + +

synchronous truth test to perform before each +execution of iteratee. Invoked with ().

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
var count = 0;
+async.whilst(
+    function() { return count < 5; },
+    function(callback) {
+        count++;
+        setTimeout(function() {
+            callback(null, count);
+        }, 1000);
+    },
+    function (err, n) {
+        // 5 seconds have passed, n = 5
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + +

CargoObject

+ + + + +
+
import cargo from 'async/cargo';

A cargo of tasks for the worker function to complete. Cargo inherits all of +the same methods and event callbacks as queue.

+
+ + + +
Type:
+
    +
  • + +Object + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

A function returning the number of items +waiting to be processed. Invoke like cargo.length().

payload + + +number + + + +

An integer for determining how many tasks +should be process per round. This property can be changed after a cargo is +created to alter the payload on-the-fly.

push + + +function + + + +

Adds task to the queue. The callback is +called once the worker has finished processing the task. Instead of a +single task, an array of tasks can be submitted. The respective callback is +used for every task in the list. Invoke like cargo.push(task, [callback]).

saturated + + +function + + + +

A callback that is called when the +queue.length() hits the concurrency and further tasks will be queued.

empty + + +function + + + +

A callback that is called when the last item +from the queue is given to a worker.

drain + + +function + + + +

A callback that is called when the last item +from the queue has returned from the worker.

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke like cargo.idle().

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke like cargo.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke like cargo.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. Invoke like cargo.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

QueueObject

+ + + + +
+
import queue from 'async/queue';

A queue of tasks for the worker function to complete.

+
+ + + +
Type:
+
    +
  • + +Object + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

a function returning the number of items +waiting to be processed. Invoke with queue.length().

started + + +boolean + + + +

a boolean indicating whether or not any +items have been pushed and processed by the queue.

running + + +function + + + +

a function returning the number of items +currently being processed. Invoke with queue.running().

workersList + + +function + + + +

a function returning the array of items +currently being processed. Invoke with queue.workersList().

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke with queue.idle().

concurrency + + +number + + + +

an integer for determining how many worker +functions should be run in parallel. This property can be changed after a +queue is created to alter the concurrency on-the-fly.

push + + +function + + + +

add a new task to the queue. Calls callback +once the worker has finished processing the task. Instead of a single task, +a tasks array can be submitted. The respective callback is used for every +task in the list. Invoke with queue.push(task, [callback]),

unshift + + +function + + + +

add a new task to the front of the queue. +Invoke with queue.unshift(task, [callback]).

remove + + +function + + + +

remove items from the queue that match a test +function. The test function will be passed an object with a data property, +and a priority property, if this is a +priorityQueue object. +Invoked with queue.remove(testFn), where testFn is of the form +function ({data, priority}) {} and returns a Boolean.

saturated + + +function + + + +

a callback that is called when the number of +running workers hits the concurrency limit, and further tasks will be +queued.

unsaturated + + +function + + + +

a callback that is called when the number +of running workers is less than the concurrency & buffer limits, and +further tasks will not be queued.

buffer + + +number + + + +

A minimum threshold buffer in order to say that +the queue is unsaturated.

empty + + +function + + + +

a callback that is called when the last item +from the queue is given to a worker.

drain + + +function + + + +

a callback that is called when the last item +from the queue has returned from the worker.

error + + +function + + + +

a callback that is called when a task errors. +Has the signature function(error, task).

paused + + +boolean + + + +

a boolean for determining whether the queue is +in a paused state.

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke with queue.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke with queue.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. No more tasks +should be pushed to the queue after calling this function. Invoke with queue.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + +

Utils

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async utility functions.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) apply(fn) → {function}

+ + + + + +
+
import apply from 'async/apply';

Creates a continuation function with some arguments already applied.

+

Useful as a shorthand when combined with other control flow functions. Any +arguments passed to the returned function are added to the arguments +originally passed to apply.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function you want to eventually apply all +arguments to. Invokes with (arguments...).

arguments... + + +* + + + + + +

Any number of arguments to automatically apply +when the continuation is called.

+ + + + +
Returns:
+ + +
+

the partially-applied function

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// using apply
+async.parallel([
+    async.apply(fs.writeFile, 'testfile1', 'test1'),
+    async.apply(fs.writeFile, 'testfile2', 'test2')
+]);
+
+
+// the same process without using apply
+async.parallel([
+    function(callback) {
+        fs.writeFile('testfile1', 'test1', callback);
+    },
+    function(callback) {
+        fs.writeFile('testfile2', 'test2', callback);
+    }
+]);
+
+// It's possible to pass any number of additional arguments when calling the
+// continuation:
+
+node> var fn = async.apply(sys.puts, 'one');
+node> fn('two', 'three');
+one
+two
+three
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) asyncify(func) → {AsyncFunction}

+ + + + + +
+
import asyncify from 'async/asyncify';

Take a sync function and make it async, passing its return value to a +callback. This is useful for plugging sync functions into a waterfall, +series, or other async functions. Any arguments passed to the generated +function will be passed to the wrapped function (except for the final +callback argument). Errors thrown will be passed to the callback.

+

If the function passed to asyncify returns a Promise, that promises's +resolved/rejected state will be used to call the callback, rather than simply +the synchronous return value.

+

This also means you can asyncify ES2017 async functions.

+
+ + + +
+
Alias:
+
  • wrapSync
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
func + + +function + + + + + +

The synchronous function, or Promise-returning +function to convert to an AsyncFunction.

+ + + + +
Returns:
+ + +
+

An asynchronous wrapper of the func. To be +invoked with (args..., callback).

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
// passing a regular synchronous function
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(JSON.parse),
+    function (data, next) {
+        // data is the result of parsing the text.
+        // If there was a parsing error, it would have been caught.
+    }
+], callback);
+
+// passing a function returning a promise
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(function (contents) {
+        return db.model.create(contents);
+    }),
+    function (model, next) {
+        // `model` is the instantiated model object.
+        // If there was an error, this function would be skipped.
+    }
+], callback);
+
+// es2017 example, though `asyncify` is not needed if your JS environment
+// supports async functions out of the box
+var q = async.queue(async.asyncify(async function(file) {
+    var intermediateStep = await processFile(file);
+    return await somePromise(intermediateStep)
+}));
+
+q.push(files);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) constant() → {AsyncFunction}

+ + + + + +
+
import constant from 'async/constant';

Returns a function that when called, calls-back with the values provided. +Useful as the first function in a waterfall, or for plugging values in to +auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
arguments... + + +* + + + + + +

Any number of arguments to automatically invoke +callback with.

+ + + + +
Returns:
+ + +
+

Returns a function that when invoked, automatically +invokes the callback with the previous given arguments.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    async.constant(42),
+    function (value, next) {
+        // value === 42
+    },
+    //...
+], callback);
+
+async.waterfall([
+    async.constant(filename, "utf8"),
+    fs.readFile,
+    function (fileData, next) {
+        //...
+    }
+    //...
+], callback);
+
+async.auto({
+    hostname: async.constant("https://server.net/"),
+    port: findFreePort,
+    launchServer: ["hostname", "port", function (options, cb) {
+        startServer(options, cb);
+    }],
+    //...
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) dir(function)

+ + + + + +
+
import dir from 'async/dir';

Logs the result of an async function to the +console using console.dir to display the properties of the resulting object. +Only works in Node.js or in browsers that support console.dir and +console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, +console.dir is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, {hello: name});
+    }, 1000);
+};
+
+// in the node repl
+node> async.dir(hello, 'world');
+{hello: 'world'}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) ensureAsync(fn) → {AsyncFunction}

+ + + + + +
+
import ensureAsync from 'async/ensureAsync';

Wrap an async function and ensure it calls its callback on a later tick of +the event loop. If the function already calls its callback on a next tick, +no extra deferral is added. This is useful for preventing stack overflows +(RangeError: Maximum call stack size exceeded) and generally keeping +Zalgo +contained. ES2017 async functions are returned as-is -- they are immune +to Zalgo's corrupting influences, as they always resolve on a later tick.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function, one that expects a node-style +callback as its last argument.

+ + + + +
Returns:
+ + +
+

Returns a wrapped function with the exact same call +signature as the function passed in.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function sometimesAsync(arg, callback) {
+    if (cache[arg]) {
+        return callback(null, cache[arg]); // this would be synchronous!!
+    } else {
+        doSomeIO(arg, callback); // this IO would be asynchronous
+    }
+}
+
+// this has a risk of stack overflows if many results are cached in a row
+async.mapSeries(args, sometimesAsync, done);
+
+// this will defer sometimesAsync's callback if necessary,
+// preventing stack overflows
+async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) log(function)

+ + + + + +
+
import log from 'async/log';

Logs the result of an async function to the console. Only works in +Node.js or in browsers that support console.log and console.error (such +as FF and Chrome). If multiple arguments are returned from the async +function, console.log is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, 'hello ' + name);
+    }, 1000);
+};
+
+// in the node repl
+node> async.log(hello, 'world');
+'hello world'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) memoize(fn, hasher) → {AsyncFunction}

+ + + + + +
+
import memoize from 'async/memoize';

Caches the results of an async function. When creating a hash to store +function results against, the callback is omitted from the hash and an +optional hash function can be used.

+

If no hash function is specified, the first argument is used as a hash key, +which may work reasonably if it is a string or a data type that converts to a +distinct string. Note that objects and arrays will not behave reasonably. +Neither will cases where the other arguments are significant. In such cases, +specify your own hash function.

+

The cache of results is exposed as the memo property of the function +returned by memoize.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function to proxy and cache results from.

hasher + + +function + + + + + +

An optional function for generating a custom hash +for storing results. It has all the arguments applied to it apart from the +callback, and must be synchronous.

+ + + + +
Returns:
+ + +
+

a memoized version of fn

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
var slow_fn = function(name, callback) {
+    // do something
+    callback(null, result);
+};
+var fn = async.memoize(slow_fn);
+
+// fn can now be used as if it were slow_fn
+fn('some name', function() {
+    // callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) nextTick(callback)

+ + + + + +
+
import nextTick from 'async/nextTick';

Calls callback on a later loop around the event loop. In Node.js this just +calls process.nextTick. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reflect(fn) → {function}

+ + + + + +
+
import reflect from 'async/reflect';

Wraps the async function in another function that always completes with a +result object, even when it errors.

+

The result object has either the property error or value.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function you want to wrap

+ + + + +
Returns:
+ + +
+
    +
  • A function that always passes null to it's callback as +the error. The second argument to the callback will be an object with +either an error or a value property.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.parallel([
+    async.reflect(function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff but error ...
+        callback('bad stuff happened');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    })
+],
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = 'bad stuff happened'
+    // results[2].value = 'two'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reflectAll(tasks) → {Array}

+ + + + + +
+
import reflectAll from 'async/reflectAll';

A helper function that wraps an array or an object of functions with reflect.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Object +| + +Iterable + + + + + +

The collection of +async functions to wrap in async.reflect.

+ + + + +
Returns:
+ + +
+

Returns an array of async functions, each wrapped in +async.reflect

+
+ + + +
+
+ Type +
+
+ +Array + + +
+
+ + + + +
Example
+ +
let tasks = [
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        // do some more stuff but error ...
+        callback(new Error('bad stuff happened'));
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+];
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = Error('bad stuff happened')
+    // results[2].value = 'two'
+});
+
+// an example using an object instead of an array
+let tasks = {
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    two: function(callback) {
+        callback('two');
+    },
+    three: function(callback) {
+        setTimeout(function() {
+            callback(null, 'three');
+        }, 100);
+    }
+};
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results.one.value = 'one'
+    // results.two.error = 'two'
+    // results.three.value = 'three'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) setImmediate(callback)

+ + + + + +
+
import setImmediate from 'async/setImmediate';

Calls callback on a later loop around the event loop. In Node.js this just +calls setImmediate. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timeout(asyncFn, milliseconds, infoopt) → {AsyncFunction}

+ + + + + +
+
import timeout from 'async/timeout';

Sets a time limit on an asynchronous function. If the function does not call +its callback within the specified milliseconds, it will be called with a +timeout error. The code property for the error object will be 'ETIMEDOUT'.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
asyncFn + + +AsyncFunction + + + + + +

The async function to limit in time.

milliseconds + + +number + + + + + +

The specified time limit.

info + + +* + + + + + + <optional> + +

Any variable you want attached (string, object, etc) +to timeout Error for more information..

+ + + + +
Returns:
+ + +
+

Returns a wrapped function that can be used with any +of the control flow functions. +Invoke this function with the same parameters as you would asyncFunc.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function myFunction(foo, callback) {
+    doAsyncTask(foo, function(err, data) {
+        // handle errors
+        if (err) return callback(err);
+
+        // do some stuff ...
+
+        // return processed data
+        return callback(null, data);
+    });
+}
+
+var wrapped = async.timeout(myFunction, 1000);
+
+// call `wrapped` as you would `myFunction`
+wrapped({ bar: 'bar' }, function(err, data) {
+    // if `myFunction` takes < 1000 ms to execute, `err`
+    // and `data` will have their expected values
+
+    // else `err` will be an Error with the code 'ETIMEDOUT'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) unmemoize(fn) → {AsyncFunction}

+ + + + + +
+
import unmemoize from 'async/unmemoize';

Undoes a memoized function, reverting it to the original, +unmemoized form. Handy for testing.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

the memoized function

+ + + + +
Returns:
+ + +
+

a function that calls the original unmemoized function

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + diff --git a/docs/v2/during.js.html b/docs/v2/during.js.html new file mode 100644 index 000000000..c85ea4d2c --- /dev/null +++ b/docs/v2/during.js.html @@ -0,0 +1,166 @@ + + + + + + + during.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

during.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
+ * is passed a callback in the form of `function (err, truth)`. If error is
+ * passed to `test` or `fn`, the main callback is immediately called with the
+ * value of the error.
+ *
+ * @name during
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (callback).
+ * @param {AsyncFunction} fn - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error, if one occurred, otherwise `null`.
+ * @example
+ *
+ * var count = 0;
+ *
+ * async.during(
+ *     function (callback) {
+ *         return callback(null, count < 5);
+ *     },
+ *     function (callback) {
+ *         count++;
+ *         setTimeout(callback, 1000);
+ *     },
+ *     function (err) {
+ *         // 5 seconds have passed
+ *     }
+ * );
+ */
+export default function during(test, fn, callback) {
+    callback = onlyOnce(callback || noop);
+    var _fn = wrapAsync(fn);
+    var _test = wrapAsync(test);
+
+    function next(err) {
+        if (err) return callback(err);
+        _test(check);
+    }
+
+    function check(err, truth) {
+        if (err) return callback(err);
+        if (!truth) return callback(null);
+        _fn(next);
+    }
+
+    _test(check);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/each.js.html b/docs/v2/each.js.html new file mode 100644 index 000000000..8e796aafb --- /dev/null +++ b/docs/v2/each.js.html @@ -0,0 +1,172 @@ + + + + + + + each.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

each.js

+ + + + + + + +
+
+
import eachOf from './eachOf';
+import withoutIndex from './internal/withoutIndex';
+import wrapAsync from './internal/wrapAsync'
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to
+ * each item in `coll`. Invoked with (item, callback).
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ *   // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ *     // Perform operation on file here.
+ *     console.log('Processing file ' + file);
+ *
+ *     if( file.length > 32 ) {
+ *       console.log('This file name is too long');
+ *       callback('File name too long');
+ *     } else {
+ *       // Do work to process file here
+ *       console.log('File processed');
+ *       callback();
+ *     }
+ * }, function(err) {
+ *     // if any of the file processing produced an error, err would equal that error
+ *     if( err ) {
+ *       // One of the iterations produced an error.
+ *       // All processing will now stop.
+ *       console.log('A file failed to process');
+ *     } else {
+ *       console.log('All files have been processed successfully');
+ *     }
+ * });
+ */
+export default function eachLimit(coll, iteratee, callback) {
+    eachOf(coll, withoutIndex(wrapAsync(iteratee)), callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/eachLimit.js.html b/docs/v2/eachLimit.js.html new file mode 100644 index 000000000..9dc258e1e --- /dev/null +++ b/docs/v2/eachLimit.js.html @@ -0,0 +1,135 @@ + + + + + + + eachLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './internal/eachOfLimit';
+import withoutIndex from './internal/withoutIndex';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfLimit`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+export default function eachLimit(coll, limit, iteratee, callback) {
+    eachOfLimit(limit)(coll, withoutIndex(wrapAsync(iteratee)), callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/eachOf.js.html b/docs/v2/eachOf.js.html new file mode 100644 index 000000000..8e5abc850 --- /dev/null +++ b/docs/v2/eachOf.js.html @@ -0,0 +1,187 @@ + + + + + + + eachOf.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOf.js

+ + + + + + + +
+
+
import isArrayLike from 'lodash/isArrayLike';
+
+import breakLoop from './internal/breakLoop';
+import eachOfLimit from './eachOfLimit';
+import doLimit from './internal/doLimit';
+import noop from 'lodash/noop';
+import once from './internal/once';
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+    callback = once(callback || noop);
+    var index = 0,
+        completed = 0,
+        length = coll.length;
+    if (length === 0) {
+        callback(null);
+    }
+
+    function iteratorCallback(err, value) {
+        if (err) {
+            callback(err);
+        } else if ((++completed === length) || value === breakLoop) {
+            callback(null);
+        }
+    }
+
+    for (; index < length; index++) {
+        iteratee(coll[index], index, onlyOnce(iteratorCallback));
+    }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = doLimit(eachOfLimit, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each
+ * item in `coll`.
+ * The `key` is the item's key, or index in the case of an array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ *     fs.readFile(__dirname + value, "utf8", function (err, data) {
+ *         if (err) return callback(err);
+ *         try {
+ *             configs[key] = JSON.parse(data);
+ *         } catch (e) {
+ *             return callback(e);
+ *         }
+ *         callback();
+ *     });
+ * }, function (err) {
+ *     if (err) console.error(err.message);
+ *     // configs is now a map of JSON data
+ *     doSomethingWith(configs);
+ * });
+ */
+export default function(coll, iteratee, callback) {
+    var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
+    eachOfImplementation(coll, wrapAsync(iteratee), callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/eachOfLimit.js.html b/docs/v2/eachOfLimit.js.html new file mode 100644 index 000000000..2af7bbef5 --- /dev/null +++ b/docs/v2/eachOfLimit.js.html @@ -0,0 +1,134 @@ + + + + + + + eachOfLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOfLimit.js

+ + + + + + + +
+
+
import _eachOfLimit from './internal/eachOfLimit';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+export default function eachOfLimit(coll, limit, iteratee, callback) {
+    _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/eachOfSeries.js.html b/docs/v2/eachOfSeries.js.html new file mode 100644 index 000000000..1772374e0 --- /dev/null +++ b/docs/v2/eachOfSeries.js.html @@ -0,0 +1,129 @@ + + + + + + + eachOfSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOfSeries.js

+ + + + + + + +
+
+
import eachOfLimit from './eachOfLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+export default doLimit(eachOfLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/eachSeries.js.html b/docs/v2/eachSeries.js.html new file mode 100644 index 000000000..cd7db11d8 --- /dev/null +++ b/docs/v2/eachSeries.js.html @@ -0,0 +1,131 @@ + + + + + + + eachSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachSeries.js

+ + + + + + + +
+
+
import eachLimit from './eachLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfSeries`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+export default doLimit(eachLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/ensureAsync.js.html b/docs/v2/ensureAsync.js.html new file mode 100644 index 000000000..eba23f181 --- /dev/null +++ b/docs/v2/ensureAsync.js.html @@ -0,0 +1,165 @@ + + + + + + + ensureAsync.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

ensureAsync.js

+ + + + + + + +
+
+
import setImmediate from './internal/setImmediate';
+import initialParams from './internal/initialParams';
+import { isAsync } from './internal/wrapAsync';
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop.  If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained. ES2017 `async` functions are returned as-is -- they are immune
+ * to Zalgo's corrupting influences, as they always resolve on a later tick.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {AsyncFunction} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ *     if (cache[arg]) {
+ *         return callback(null, cache[arg]); // this would be synchronous!!
+ *     } else {
+ *         doSomeIO(arg, callback); // this IO would be asynchronous
+ *     }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+export default function ensureAsync(fn) {
+    if (isAsync(fn)) return fn;
+    return initialParams(function (args, callback) {
+        var sync = true;
+        args.push(function () {
+            var innerArgs = arguments;
+            if (sync) {
+                setImmediate(function () {
+                    callback.apply(null, innerArgs);
+                });
+            } else {
+                callback.apply(null, innerArgs);
+            }
+        });
+        fn.apply(this, args);
+        sync = false;
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/every.js.html b/docs/v2/every.js.html new file mode 100644 index 000000000..202a22315 --- /dev/null +++ b/docs/v2/every.js.html @@ -0,0 +1,141 @@ + + + + + + + every.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

every.js

+ + + + + + + +
+
+
import createTester from './internal/createTester';
+import doParallel from './internal/doParallel';
+import notId from './internal/notId';
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ *     fs.access(filePath, function(err) {
+ *         callback(null, !err)
+ *     });
+ * }, function(err, result) {
+ *     // if result is true then every file exists
+ * });
+ */
+export default doParallel(createTester(notId, notId));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/everyLimit.js.html b/docs/v2/everyLimit.js.html new file mode 100644 index 000000000..84b003ae2 --- /dev/null +++ b/docs/v2/everyLimit.js.html @@ -0,0 +1,133 @@ + + + + + + + everyLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

everyLimit.js

+ + + + + + + +
+
+
import createTester from './internal/createTester';
+import doParallelLimit from './internal/doParallelLimit';
+import notId from './internal/notId';
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+export default doParallelLimit(createTester(notId, notId));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/everySeries.js.html b/docs/v2/everySeries.js.html new file mode 100644 index 000000000..2849fc738 --- /dev/null +++ b/docs/v2/everySeries.js.html @@ -0,0 +1,131 @@ + + + + + + + everySeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

everySeries.js

+ + + + + + + +
+
+
import everyLimit from './everyLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in series.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+export default doLimit(everyLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/favicon.ico b/docs/v2/favicon.ico new file mode 100755 index 000000000..4a90dff47 Binary files /dev/null and b/docs/v2/favicon.ico differ diff --git a/docs/v2/filter.js.html b/docs/v2/filter.js.html new file mode 100644 index 000000000..2a491ea46 --- /dev/null +++ b/docs/v2/filter.js.html @@ -0,0 +1,139 @@ + + + + + + + filter.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filter.js

+ + + + + + + +
+
+
import filter from './internal/filter';
+import doParallel from './internal/doParallel';
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ *     fs.access(filePath, function(err) {
+ *         callback(null, !err)
+ *     });
+ * }, function(err, results) {
+ *     // results now equals an array of the existing files
+ * });
+ */
+export default doParallel(filter);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/filterLimit.js.html b/docs/v2/filterLimit.js.html new file mode 100644 index 000000000..7874ec7a5 --- /dev/null +++ b/docs/v2/filterLimit.js.html @@ -0,0 +1,131 @@ + + + + + + + filterLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filterLimit.js

+ + + + + + + +
+
+
import filter from './internal/filter';
+import doParallelLimit from './internal/doParallelLimit';
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+export default doParallelLimit(filter);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/filterSeries.js.html b/docs/v2/filterSeries.js.html new file mode 100644 index 000000000..dd6cdb39d --- /dev/null +++ b/docs/v2/filterSeries.js.html @@ -0,0 +1,129 @@ + + + + + + + filterSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filterSeries.js

+ + + + + + + +
+
+
import filterLimit from './filterLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+export default doLimit(filterLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Bold-webfont.eot b/docs/v2/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 000000000..5d20d9163 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Bold-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-Bold-webfont.svg b/docs/v2/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 000000000..3ed7be4bc --- /dev/null +++ b/docs/v2/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Bold-webfont.woff b/docs/v2/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 000000000..1205787b0 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Bold-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-BoldItalic-webfont.eot b/docs/v2/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 000000000..1f639a15f Binary files /dev/null and b/docs/v2/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-BoldItalic-webfont.svg b/docs/v2/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 000000000..6a2607b9d --- /dev/null +++ b/docs/v2/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-BoldItalic-webfont.woff b/docs/v2/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 000000000..ed760c062 Binary files /dev/null and b/docs/v2/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-Italic-webfont.eot b/docs/v2/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 000000000..0c8a0ae06 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Italic-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-Italic-webfont.svg b/docs/v2/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 000000000..e1075dcc2 --- /dev/null +++ b/docs/v2/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Italic-webfont.woff b/docs/v2/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 000000000..ff652e643 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Italic-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-Light-webfont.eot b/docs/v2/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 000000000..14868406a Binary files /dev/null and b/docs/v2/fonts/OpenSans-Light-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-Light-webfont.svg b/docs/v2/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 000000000..11a472ca8 --- /dev/null +++ b/docs/v2/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Light-webfont.woff b/docs/v2/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 000000000..e78607481 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Light-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-LightItalic-webfont.eot b/docs/v2/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 000000000..8f445929f Binary files /dev/null and b/docs/v2/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-LightItalic-webfont.svg b/docs/v2/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 000000000..431d7e354 --- /dev/null +++ b/docs/v2/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-LightItalic-webfont.woff b/docs/v2/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 000000000..43e8b9e6c Binary files /dev/null and b/docs/v2/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-Regular-webfont.eot b/docs/v2/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 000000000..6bbc3cf58 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Regular-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-Regular-webfont.svg b/docs/v2/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 000000000..25a395234 --- /dev/null +++ b/docs/v2/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Regular-webfont.woff b/docs/v2/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 000000000..e231183dc Binary files /dev/null and b/docs/v2/fonts/OpenSans-Regular-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-Semibold-webfont.eot b/docs/v2/fonts/OpenSans-Semibold-webfont.eot new file mode 100644 index 000000000..d8375dd0a Binary files /dev/null and b/docs/v2/fonts/OpenSans-Semibold-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-Semibold-webfont.svg b/docs/v2/fonts/OpenSans-Semibold-webfont.svg new file mode 100644 index 000000000..eec4db8bd --- /dev/null +++ b/docs/v2/fonts/OpenSans-Semibold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-Semibold-webfont.ttf b/docs/v2/fonts/OpenSans-Semibold-webfont.ttf new file mode 100644 index 000000000..b3290843a Binary files /dev/null and b/docs/v2/fonts/OpenSans-Semibold-webfont.ttf differ diff --git a/docs/v2/fonts/OpenSans-Semibold-webfont.woff b/docs/v2/fonts/OpenSans-Semibold-webfont.woff new file mode 100644 index 000000000..28d6adee0 Binary files /dev/null and b/docs/v2/fonts/OpenSans-Semibold-webfont.woff differ diff --git a/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.eot b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.eot new file mode 100644 index 000000000..0ab1db22e Binary files /dev/null and b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.eot differ diff --git a/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.svg b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.svg new file mode 100644 index 000000000..7166ec1b9 --- /dev/null +++ b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.ttf b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.ttf new file mode 100644 index 000000000..d2d6318f6 Binary files /dev/null and b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.ttf differ diff --git a/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.woff b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.woff new file mode 100644 index 000000000..d4dfca402 Binary files /dev/null and b/docs/v2/fonts/OpenSans-SemiboldItalic-webfont.woff differ diff --git a/docs/v2/forever.js.html b/docs/v2/forever.js.html new file mode 100644 index 000000000..2a158e1a6 --- /dev/null +++ b/docs/v2/forever.js.html @@ -0,0 +1,153 @@ + + + + + + + forever.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

forever.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+
+import onlyOnce from './internal/onlyOnce';
+import ensureAsync from './ensureAsync';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the callback then `errback` is called with the
+ * error, and execution stops, otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} fn - an async function to call repeatedly.
+ * Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ *     function(next) {
+ *         // next is suitable for passing to things that need a callback(err [, whatever]);
+ *         // it will result in this function being called again.
+ *     },
+ *     function(err) {
+ *         // if next is called with a value in its first parameter, it will appear
+ *         // in here as 'err', and execution will stop.
+ *     }
+ * );
+ */
+export default function forever(fn, errback) {
+    var done = onlyOnce(errback || noop);
+    var task = wrapAsync(ensureAsync(fn));
+
+    function next(err) {
+        if (err) return done(err);
+        task(next);
+    }
+    next();
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/global.html b/docs/v2/global.html new file mode 100644 index 000000000..6e1a2c792 --- /dev/null +++ b/docs/v2/global.html @@ -0,0 +1,299 @@ + + + + + + + Global - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Global

+ + + + + + + +
+ +
+ +

+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + + + + +

AsyncFunction()

+ + + + + +
+

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. +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, +because the async function will be compiled to an ordinary function that +returns a promise.

+
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/groupBy.js.html b/docs/v2/groupBy.js.html new file mode 100644 index 000000000..cc4d48e8d --- /dev/null +++ b/docs/v2/groupBy.js.html @@ -0,0 +1,148 @@ + + + + + + + groupBy.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupBy.js

+ + + + + + + +
+
+
import doLimit from './internal/doLimit';
+import groupByLimit from './groupByLimit';
+
+/**
+ * Returns a new object, where each value corresponds to an array of items, from
+ * `coll`, that returned the corresponding key. That is, the keys of the object
+ * correspond to the values passed to the `iteratee` callback.
+ *
+ * Note: Since this function applies the `iteratee` to each item in parallel,
+ * there is no guarantee that the `iteratee` functions will complete in order.
+ * However, the values for each key in the `result` will be in the same order as
+ * the original `coll`. For Objects, the values will roughly be in the order of
+ * the original Objects' keys (but this can vary across JavaScript engines).
+ *
+ * @name groupBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ * @example
+ *
+ * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
+ *     db.findById(userId, function(err, user) {
+ *         if (err) return callback(err);
+ *         return callback(null, user.age);
+ *     });
+ * }, function(err, result) {
+ *     // result is object containing the userIds grouped by age
+ *     // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
+ * });
+ */
+export default doLimit(groupByLimit, Infinity);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/groupByLimit.js.html b/docs/v2/groupByLimit.js.html new file mode 100644 index 000000000..6933e191d --- /dev/null +++ b/docs/v2/groupByLimit.js.html @@ -0,0 +1,159 @@ + + + + + + + groupByLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupByLimit.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import mapLimit from './mapLimit';
+import wrapAsync from './internal/wrapAsync';
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name groupByLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+export default function(coll, limit, iteratee, callback) {
+    callback = callback || noop;
+    var _iteratee = wrapAsync(iteratee);
+    mapLimit(coll, limit, function(val, callback) {
+        _iteratee(val, function(err, key) {
+            if (err) return callback(err);
+            return callback(null, {key: key, val: val});
+        });
+    }, function(err, mapResults) {
+        var result = {};
+        // from MDN, handle object having an `hasOwnProperty` prop
+        var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+        for (var i = 0; i < mapResults.length; i++) {
+            if (mapResults[i]) {
+                var key = mapResults[i].key;
+                var val = mapResults[i].val;
+
+                if (hasOwnProperty.call(result, key)) {
+                    result[key].push(val);
+                } else {
+                    result[key] = [val];
+                }
+            }
+        }
+
+        return callback(err, result);
+    });
+};
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/groupBySeries.js.html b/docs/v2/groupBySeries.js.html new file mode 100644 index 000000000..d3fd56672 --- /dev/null +++ b/docs/v2/groupBySeries.js.html @@ -0,0 +1,131 @@ + + + + + + + groupBySeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupBySeries.js

+ + + + + + + +
+
+
import doLimit from './internal/doLimit';
+import groupByLimit from './groupByLimit';
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
+ *
+ * @name groupBySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+export default doLimit(groupByLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/img/async-logo.svg b/docs/v2/img/async-logo.svg new file mode 100644 index 000000000..d108be788 --- /dev/null +++ b/docs/v2/img/async-logo.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + diff --git a/docs/v2/index.html b/docs/v2/index.html new file mode 100644 index 000000000..9d75ff5ae --- /dev/null +++ b/docs/v2/index.html @@ -0,0 +1,266 @@ + + + + + + + Home - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +
+

Async Logo

+

Build Status via Travis CI +NPM version +Coverage Status +Join the chat at https://gitter.im/caolan/async

+

For Async v1.5.x documentation, go HERE

+

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via npm install --save async, +it can also be used directly in the browser.

+

Async is also installable via:

+
    +
  • yarn: yarn add async
  • +
  • bower: bower install async
  • +
+

Async provides around 70 functions that include the usual 'functional' +suspects (map, reduce, filter, each…) as well as some common patterns +for asynchronous control flow (parallel, series, waterfall…). All these +functions assume you follow the Node.js convention of providing a single +callback as the last argument of your asynchronous function -- a callback which expects an Error as its first argument -- and calling the callback once.

+

Quick Examples

async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+    // results is now an array of stats for each file
+});
+
+async.filter(['file1','file2','file3'], function(filePath, callback) {
+  fs.access(filePath, function(err) {
+    callback(null, !err)
+  });
+}, function(err, results) {
+    // results now equals an array of the existing files
+});
+
+async.parallel([
+    function(callback) { ... },
+    function(callback) { ... }
+], function(err, results) {
+    // optional callback
+});
+
+async.series([
+    function(callback) { ... },
+    function(callback) { ... }
+]);

There are many more functions available so take a look at the docs below for a +full list. This module aims to be comprehensive, so if you feel anything is +missing please create a GitHub issue for it.

+

Common Pitfalls (StackOverflow)

Synchronous iteration functions

If you get an error like RangeError: Maximum call stack size exceeded. or other stack overflow issues when using async, you are likely using a synchronous iteratee. By synchronous we mean a function that calls its callback on the same tick in the javascript event loop, without doing any I/O or using any timers. Calling many callbacks iteratively will quickly overflow the stack. If you run into this issue, just defer your callback with async.setImmediate to start a new call stack on the next tick of the event loop.

+

This can also arise by accident if you callback early in certain cases:

+
async.eachSeries(hugeArray, function iteratee(item, callback) {
+    if (inCache(item)) {
+        callback(null, cache[item]); // if many items are cached, you'll overflow
+    } else {
+        doSomeIO(item, callback);
+    }
+}, function done() {
+    //...
+});

Just change it to:

+
async.eachSeries(hugeArray, function iteratee(item, callback) {
+    if (inCache(item)) {
+        async.setImmediate(function() {
+            callback(null, cache[item]);
+        });
+    } else {
+        doSomeIO(item, callback);
+        //...
+    }
+});

Async does not guard against synchronous iteratees for performance reasons. If you are still running into stack overflows, you can defer as suggested above, or wrap functions with async.ensureAsync Functions that are asynchronous by their nature do not have this problem and don't need the extra callback deferral.

+

If JavaScript's event loop is still a bit nebulous, check out this article or this talk for more detailed information about how it works.

+

Multiple callbacks

Make sure to always return when calling a callback early, otherwise you will cause multiple callbacks and unpredictable behavior in many cases.

+
async.waterfall([
+    function(callback) {
+        getSomething(options, function (err, result) {
+            if (err) {
+                callback(new Error("failed getting something:" + err.message));
+                // we should return here
+            }
+            // since we did not return, this callback still will be called and
+            // `processData` will be called twice
+            callback(null, result);
+        });
+    },
+    processData
+], done)

It is always good practice to return callback(err, result) whenever a callback call is not the last statement of a function.

+

Using ES2017 async functions

Async accepts async functions wherever we accept a Node-style callback function. However, we do not pass them a callback, and instead use the return value and handle any promise rejections or errors thrown.

+
async.mapLimit(files, async file => { // <- no callback!
+    const text = await util.promisify(fs.readFile)(dir + file, 'utf8')
+    const body = JSON.parse(text) // <- a parse error herre will be caught automatically
+    if (!(await checkValidity(body))) {
+        throw new Error(`${file} has invalid contents`) // <- this error will also be caught
+    }
+    return body // <- return a value!
+}, (err, contents) => {
+    if (err) throw err
+    console.log(contents)
+})

We can only detect native async functions, not transpiled versions (e.g. with Babel). Otherwise, you can wrap async functions in async.asyncify().

+

Binding a context to an iteratee

This section is really about bind, not about Async. If you are wondering how to +make Async execute your iteratees in a given context, or are confused as to why +a method of another library isn't working as an iteratee, study this example:

+
// Here is a simple object with an (unnecessarily roundabout) squaring method
+var AsyncSquaringLibrary = {
+    squareExponent: 2,
+    square: function(number, callback){
+        var result = Math.pow(number, this.squareExponent);
+        setTimeout(function(){
+            callback(null, result);
+        }, 200);
+    }
+};
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result) {
+    // result is [NaN, NaN, NaN]
+    // This fails because the `this.squareExponent` expression in the square
+    // function is not evaluated in the context of AsyncSquaringLibrary, and is
+    // therefore undefined.
+});
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result) {
+    // result is [1, 4, 9]
+    // With the help of bind we can attach a context to the iteratee before
+    // passing it to Async. Now the square function will be executed in its
+    // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`
+    // will be as expected.
+});

Download

The source is available for download from +GitHub. +Alternatively, you can install using npm:

+
$ npm install --save async

As well as using Bower:

+
$ bower install async

You can then require() async as normal:

+
var async = require("async");

Or require individual methods:

+
var waterfall = require("async/waterfall");
+var map = require("async/map");

Development: async.js - 29.6kb Uncompressed

+

In the Browser

Async should work in any ES5 environment (IE9 and above).

+

Usage:

+
<script type="text/javascript" src="async.js"></script>
+<script type="text/javascript">
+
+    async.map(data, asyncProcess, function(err, results) {
+        alert(results);
+    });
+
+</script>

The portable versions of Async, including async.js and async.min.js, are +included in the /dist folder. Async can also be found on the jsDelivr CDN.

+

ES Modules

We also provide Async as a collection of ES2015 modules, in an alternative async-es package on npm.

+
$ npm install --save async-es
import waterfall from 'async-es/waterfall';
+import async from 'async-es';

Other Libraries

    +
  • limiter a package for rate-limiting based on requests per sec/hour.
  • +
  • neo-async an altername implementation of Async, focusing on speed.
  • +
  • co-async a library inspired by Async for use with co and generator functions.
  • +
  • promise-async a version of Async where all the methods are Promisified.
  • +
+
+ + + + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + diff --git a/docs/v2/index.js.html b/docs/v2/index.js.html new file mode 100644 index 000000000..fe374cf3b --- /dev/null +++ b/docs/v2/index.js.html @@ -0,0 +1,459 @@ + + + + + + + index.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

index.js

+ + + + + + + +
+
+
/**
+ * 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
+ */
+
+import apply from './apply'
+import applyEach from './applyEach'
+import applyEachSeries from './applyEachSeries'
+import asyncify from './asyncify'
+import auto from './auto'
+import autoInject from './autoInject'
+import cargo from './cargo'
+import compose from './compose'
+import concat from './concat'
+import concatLimit from './concatLimit'
+import concatSeries from './concatSeries'
+import constant from './constant'
+import detect from './detect'
+import detectLimit from './detectLimit'
+import detectSeries from './detectSeries'
+import dir from './dir'
+import doDuring from './doDuring'
+import doUntil from './doUntil'
+import doWhilst from './doWhilst'
+import during from './during'
+import each from './each'
+import eachLimit from './eachLimit'
+import eachOf from './eachOf'
+import eachOfLimit from './eachOfLimit'
+import eachOfSeries from './eachOfSeries'
+import eachSeries from './eachSeries'
+import ensureAsync from './ensureAsync'
+import every from './every'
+import everyLimit from './everyLimit'
+import everySeries from './everySeries'
+import filter from './filter'
+import filterLimit from './filterLimit'
+import filterSeries from './filterSeries'
+import forever from './forever'
+import groupBy from './groupBy'
+import groupByLimit from './groupByLimit'
+import groupBySeries from './groupBySeries'
+import log from './log'
+import map from './map'
+import mapLimit from './mapLimit'
+import mapSeries from './mapSeries'
+import mapValues from './mapValues'
+import mapValuesLimit from './mapValuesLimit'
+import mapValuesSeries from './mapValuesSeries'
+import memoize from './memoize'
+import nextTick from './nextTick'
+import parallel from './parallel'
+import parallelLimit from './parallelLimit'
+import priorityQueue from './priorityQueue'
+import queue from './queue'
+import race from './race'
+import reduce from './reduce'
+import reduceRight from './reduceRight'
+import reflect from './reflect'
+import reflectAll from './reflectAll'
+import reject from './reject'
+import rejectLimit from './rejectLimit'
+import rejectSeries from './rejectSeries'
+import retry from './retry'
+import retryable from './retryable'
+import seq from './seq'
+import series from './series'
+import setImmediate from './setImmediate'
+import some from './some'
+import someLimit from './someLimit'
+import someSeries from './someSeries'
+import sortBy from './sortBy'
+import timeout from './timeout'
+import times from './times'
+import timesLimit from './timesLimit'
+import timesSeries from './timesSeries'
+import transform from './transform'
+import tryEach from './tryEach'
+import unmemoize from './unmemoize'
+import until from './until'
+import waterfall from './waterfall'
+import whilst from './whilst'
+
+export default {
+    apply: apply,
+    applyEach: applyEach,
+    applyEachSeries: applyEachSeries,
+    asyncify: asyncify,
+    auto: auto,
+    autoInject: autoInject,
+    cargo: cargo,
+    compose: compose,
+    concat: concat,
+    concatLimit: concatLimit,
+    concatSeries: concatSeries,
+    constant: constant,
+    detect: detect,
+    detectLimit: detectLimit,
+    detectSeries: detectSeries,
+    dir: dir,
+    doDuring: doDuring,
+    doUntil: doUntil,
+    doWhilst: doWhilst,
+    during: during,
+    each: each,
+    eachLimit: eachLimit,
+    eachOf: eachOf,
+    eachOfLimit: eachOfLimit,
+    eachOfSeries: eachOfSeries,
+    eachSeries: eachSeries,
+    ensureAsync: ensureAsync,
+    every: every,
+    everyLimit: everyLimit,
+    everySeries: everySeries,
+    filter: filter,
+    filterLimit: filterLimit,
+    filterSeries: filterSeries,
+    forever: forever,
+    groupBy: groupBy,
+    groupByLimit: groupByLimit,
+    groupBySeries: groupBySeries,
+    log: log,
+    map: map,
+    mapLimit: mapLimit,
+    mapSeries: mapSeries,
+    mapValues: mapValues,
+    mapValuesLimit: mapValuesLimit,
+    mapValuesSeries: mapValuesSeries,
+    memoize: memoize,
+    nextTick: nextTick,
+    parallel: parallel,
+    parallelLimit: parallelLimit,
+    priorityQueue: priorityQueue,
+    queue: queue,
+    race: race,
+    reduce: reduce,
+    reduceRight: reduceRight,
+    reflect: reflect,
+    reflectAll: reflectAll,
+    reject: reject,
+    rejectLimit: rejectLimit,
+    rejectSeries: rejectSeries,
+    retry: retry,
+    retryable: retryable,
+    seq: seq,
+    series: series,
+    setImmediate: setImmediate,
+    some: some,
+    someLimit: someLimit,
+    someSeries: someSeries,
+    sortBy: sortBy,
+    timeout: timeout,
+    times: times,
+    timesLimit: timesLimit,
+    timesSeries: timesSeries,
+    transform: transform,
+    tryEach: tryEach,
+    unmemoize: unmemoize,
+    until: until,
+    waterfall: waterfall,
+    whilst: whilst,
+
+    // aliases
+    all: every,
+    allLimit: everyLimit,
+    allSeries: everySeries,
+    any: some,
+    anyLimit: someLimit,
+    anySeries: someSeries,
+    find: detect,
+    findLimit: detectLimit,
+    findSeries: detectSeries,
+    forEach: each,
+    forEachSeries: eachSeries,
+    forEachLimit: eachLimit,
+    forEachOf: eachOf,
+    forEachOfSeries: eachOfSeries,
+    forEachOfLimit: eachOfLimit,
+    inject: reduce,
+    foldl: reduce,
+    foldr: reduceRight,
+    select: filter,
+    selectLimit: filterLimit,
+    selectSeries: filterSeries,
+    wrapSync: asyncify
+};
+
+export {
+    apply as apply,
+    applyEach as applyEach,
+    applyEachSeries as applyEachSeries,
+    asyncify as asyncify,
+    auto as auto,
+    autoInject as autoInject,
+    cargo as cargo,
+    compose as compose,
+    concat as concat,
+    concatLimit as concatLimit,
+    concatSeries as concatSeries,
+    constant as constant,
+    detect as detect,
+    detectLimit as detectLimit,
+    detectSeries as detectSeries,
+    dir as dir,
+    doDuring as doDuring,
+    doUntil as doUntil,
+    doWhilst as doWhilst,
+    during as during,
+    each as each,
+    eachLimit as eachLimit,
+    eachOf as eachOf,
+    eachOfLimit as eachOfLimit,
+    eachOfSeries as eachOfSeries,
+    eachSeries as eachSeries,
+    ensureAsync as ensureAsync,
+    every as every,
+    everyLimit as everyLimit,
+    everySeries as everySeries,
+    filter as filter,
+    filterLimit as filterLimit,
+    filterSeries as filterSeries,
+    forever as forever,
+    groupBy as groupBy,
+    groupByLimit as groupByLimit,
+    groupBySeries as groupBySeries,
+    log as log,
+    map as map,
+    mapLimit as mapLimit,
+    mapSeries as mapSeries,
+    mapValues as mapValues,
+    mapValuesLimit as mapValuesLimit,
+    mapValuesSeries as mapValuesSeries,
+    memoize as memoize,
+    nextTick as nextTick,
+    parallel as parallel,
+    parallelLimit as parallelLimit,
+    priorityQueue as priorityQueue,
+    queue as queue,
+    race as race,
+    reduce as reduce,
+    reduceRight as reduceRight,
+    reflect as reflect,
+    reflectAll as reflectAll,
+    reject as reject,
+    rejectLimit as rejectLimit,
+    rejectSeries as rejectSeries,
+    retry as retry,
+    retryable as retryable,
+    seq as seq,
+    series as series,
+    setImmediate as setImmediate,
+    some as some,
+    someLimit as someLimit,
+    someSeries as someSeries,
+    sortBy as sortBy,
+    timeout as timeout,
+    times as times,
+    timesLimit as timesLimit,
+    timesSeries as timesSeries,
+    transform as transform,
+    tryEach as tryEach,
+    unmemoize as unmemoize,
+    until as until,
+    waterfall as waterfall,
+    whilst as whilst,
+
+    // Aliases
+    every as all,
+    everyLimit as allLimit,
+    everySeries as allSeries,
+    some as any,
+    someLimit as anyLimit,
+    someSeries as anySeries,
+    detect as find,
+    detectLimit as findLimit,
+    detectSeries as findSeries,
+    each as forEach,
+    eachSeries as forEachSeries,
+    eachLimit as forEachLimit,
+    eachOf as forEachOf,
+    eachOfSeries as forEachOfSeries,
+    eachOfLimit as forEachOfLimit,
+    reduce as inject,
+    reduce as foldl,
+    reduceRight as foldr,
+    filter as select,
+    filterLimit as selectLimit,
+    filterSeries as selectSeries,
+    asyncify as wrapSync
+};
+
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/log.js.html b/docs/v2/log.js.html new file mode 100644 index 000000000..26064fda1 --- /dev/null +++ b/docs/v2/log.js.html @@ -0,0 +1,138 @@ + + + + + + + log.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

log.js

+ + + + + + + +
+
+
import consoleFunc from './internal/consoleFunc';
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ *     setTimeout(function() {
+ *         callback(null, 'hello ' + name);
+ *     }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+export default consoleFunc('log');
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/map.js.html b/docs/v2/map.js.html new file mode 100644 index 000000000..916788014 --- /dev/null +++ b/docs/v2/map.js.html @@ -0,0 +1,148 @@ + + + + + + + map.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

map.js

+ + + + + + + +
+
+
import doParallel from './internal/doParallel';
+import map from './internal/map';
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array.  The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines).
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ *     // results is now an array of stats for each file
+ * });
+ */
+export default doParallel(map);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/mapLimit.js.html b/docs/v2/mapLimit.js.html new file mode 100644 index 000000000..42f4bc63d --- /dev/null +++ b/docs/v2/mapLimit.js.html @@ -0,0 +1,131 @@ + + + + + + + mapLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapLimit.js

+ + + + + + + +
+
+
import doParallelLimit from './internal/doParallelLimit';
+import map from './internal/map';
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+export default doParallelLimit(map);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/mapSeries.js.html b/docs/v2/mapSeries.js.html new file mode 100644 index 000000000..036b16b81 --- /dev/null +++ b/docs/v2/mapSeries.js.html @@ -0,0 +1,130 @@ + + + + + + + mapSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapSeries.js

+ + + + + + + +
+
+
import mapLimit from './mapLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+export default doLimit(mapLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/mapValues.js.html b/docs/v2/mapValues.js.html new file mode 100644 index 000000000..cf8959552 --- /dev/null +++ b/docs/v2/mapValues.js.html @@ -0,0 +1,158 @@ + + + + + + + mapValues.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValues.js

+ + + + + + + +
+
+
import mapValuesLimit from './mapValuesLimit';
+import doLimit from './internal/doLimit';
+
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed.  The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ *     f1: 'file1',
+ *     f2: 'file2',
+ *     f3: 'file3'
+ * }, function (file, key, callback) {
+ *   fs.stat(file, callback);
+ * }, function(err, result) {
+ *     // result is now a map of stats for each file, e.g.
+ *     // {
+ *     //     f1: [stats for file1],
+ *     //     f2: [stats for file2],
+ *     //     f3: [stats for file3]
+ *     // }
+ * });
+ */
+
+export default doLimit(mapValuesLimit, Infinity);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/mapValuesLimit.js.html b/docs/v2/mapValuesLimit.js.html new file mode 100644 index 000000000..80d4f1076 --- /dev/null +++ b/docs/v2/mapValuesLimit.js.html @@ -0,0 +1,149 @@ + + + + + + + mapValuesLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValuesLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './eachOfLimit';
+
+import noop from 'lodash/noop';
+import once from './internal/once';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+export default function mapValuesLimit(obj, limit, iteratee, callback) {
+    callback = once(callback || noop);
+    var newObj = {};
+    var _iteratee = wrapAsync(iteratee)
+    eachOfLimit(obj, limit, function(val, key, next) {
+        _iteratee(val, key, function (err, result) {
+            if (err) return next(err);
+            newObj[key] = result;
+            next();
+        });
+    }, function (err) {
+        callback(err, newObj);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/mapValuesSeries.js.html b/docs/v2/mapValuesSeries.js.html new file mode 100644 index 000000000..169945840 --- /dev/null +++ b/docs/v2/mapValuesSeries.js.html @@ -0,0 +1,131 @@ + + + + + + + mapValuesSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValuesSeries.js

+ + + + + + + +
+
+
import mapValuesLimit from './mapValuesLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+export default doLimit(mapValuesLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/memoize.js.html b/docs/v2/memoize.js.html new file mode 100644 index 000000000..039b1bb59 --- /dev/null +++ b/docs/v2/memoize.js.html @@ -0,0 +1,186 @@ + + + + + + + memoize.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

memoize.js

+ + + + + + + +
+
+
import identity from 'lodash/identity';
+import slice from './internal/slice';
+
+import setImmediate from './internal/setImmediate';
+import initialParams from './internal/initialParams';
+import wrapAsync from './internal/wrapAsync';
+
+function has(obj, key) {
+    return key in obj;
+}
+
+/**
+ * Caches the results of an async function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {AsyncFunction} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ *     // do something
+ *     callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ *     // callback
+ * });
+ */
+export default function memoize(fn, hasher) {
+    var memo = Object.create(null);
+    var queues = Object.create(null);
+    hasher = hasher || identity;
+    var _fn = wrapAsync(fn);
+    var memoized = initialParams(function memoized(args, callback) {
+        var key = hasher.apply(null, args);
+        if (has(memo, key)) {
+            setImmediate(function() {
+                callback.apply(null, memo[key]);
+            });
+        } else if (has(queues, key)) {
+            queues[key].push(callback);
+        } else {
+            queues[key] = [callback];
+            _fn.apply(null, args.concat(function(/*args*/) {
+                var args = slice(arguments);
+                memo[key] = args;
+                var q = queues[key];
+                delete queues[key];
+                for (var i = 0, l = q.length; i < l; i++) {
+                    q[i].apply(null, args);
+                }
+            }));
+        }
+    });
+    memoized.memo = memo;
+    memoized.unmemoized = fn;
+    return memoized;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/module-Collections.html b/docs/v2/module-Collections.html new file mode 100644 index 000000000..fc7cfa2d5 --- /dev/null +++ b/docs/v2/module-Collections.html @@ -0,0 +1,8170 @@ + + + + + + + Collections - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Collections

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for manipulating collections, such as +arrays and objects.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) concat(coll, iteratee, callback(err)opt)

+ + + + + +
+
import concat from 'async/concat';

Applies iteratee to each item in coll, concatenating the results. Returns +the concatenated list. The iteratees are called in parallel, and the +results are concatenated as they return. There is no guarantee that the +results array will be returned in the original order of coll passed to the +iteratee function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback(err) + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + +
Example
+ +
async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files) {
+    // files is now a list of filenames that exist in the 3 directories
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) concatLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import concatLimit from 'async/concatLimit';

The same as concat but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) concatSeries(coll, iteratee, callback(err)opt)

+ + + + + +
+
import concatSeries from 'async/concatSeries';

The same as concat but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll. +The iteratee should complete with an array an array of results. +Invoked with (item, callback).

callback(err) + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detect(coll, iteratee, callbackopt)

+ + + + + +
+
import detect from 'async/detect';

Returns the first value in coll that passes an async truth test. The +iteratee is applied in parallel, meaning the first iteratee to return +true will fire the detect callback with that result. That means the +result might not be the first item in the original coll (in terms of order) +that passes the test. +If order within the original coll is important, then look at +detectSeries.

+
+ + + +
+
Alias:
+
  • find
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + +
Example
+ +
async.detect(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // result now equals the first file in the list that exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) detectLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import detectLimit from 'async/detectLimit';

The same as detect but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • findLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detectSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import detectSeries from 'async/detectSeries';

The same as detect but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • findSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) each(coll, iteratee, callbackopt)

+ + + + + +
+
import each from 'async/each';

Applies the function iteratee to each item in coll, in parallel. +The iteratee is called with an item from the list, and a callback for when +it has finished. If the iteratee passes an error to its callback, the +main callback (for the each function) is immediately called with the +error.

+

Note, that since this function applies iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEach
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to +each item in coll. Invoked with (item, callback). +The array index is not passed to the iteratee. +If you need the index, use eachOf.

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + +
Example
+ +
// assuming openFiles is an array of file names and saveFile is a function
+// to save the modified contents of that file:
+
+async.each(openFiles, saveFile, function(err){
+  // if any of the saves produced an error, err would equal that error
+});
+
+// assuming openFiles is an array of file names
+async.each(openFiles, function(file, callback) {
+
+    // Perform operation on file here.
+    console.log('Processing file ' + file);
+
+    if( file.length > 32 ) {
+      console.log('This file name is too long');
+      callback('File name too long');
+    } else {
+      // Do work to process file here
+      console.log('File processed');
+      callback();
+    }
+}, function(err) {
+    // if any of the file processing produced an error, err would equal that error
+    if( err ) {
+      // One of the iterations produced an error.
+      // All processing will now stop.
+      console.log('A file failed to process');
+    } else {
+      console.log('All files have been processed successfully');
+    }
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) eachLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import eachLimit from 'async/eachLimit';

The same as each but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • forEachLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfLimit. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOf(coll, iteratee, callbackopt)

+ + + + + +
+
import eachOf from 'async/eachOf';

Like each, except that it passes the key (or index) as the second argument +to the iteratee.

+
+ + + +
+
Alias:
+
  • forEachOf
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each +item in coll. +The key is the item's key, or index in the case of an array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + +
Example
+ +
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+var configs = {};
+
+async.forEachOf(obj, function (value, key, callback) {
+    fs.readFile(__dirname + value, "utf8", function (err, data) {
+        if (err) return callback(err);
+        try {
+            configs[key] = JSON.parse(data);
+        } catch (e) {
+            return callback(e);
+        }
+        callback();
+    });
+}, function (err) {
+    if (err) console.error(err.message);
+    // configs is now a map of JSON data
+    doSomethingWith(configs);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import eachOfLimit from 'async/eachOfLimit';

The same as eachOf but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • forEachOfLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. The key is the item's key, or index in the case of an +array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import eachOfSeries from 'async/eachOfSeries';

The same as eachOf but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachOfSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import eachSeries from 'async/eachSeries';

The same as each but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfSeries. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) every(coll, iteratee, callbackopt)

+ + + + + +
+
import every from 'async/every';

Returns true if every element in coll satisfies an async test. If any +iteratee call returns false, the main callback is immediately called.

+
+ + + +
+
Alias:
+
  • all
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + +
Example
+ +
async.every(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // if result is true then every file exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) everyLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import everyLimit from 'async/everyLimit';

The same as every but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • allLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) everySeries(coll, iteratee, callbackopt)

+ + + + + +
+
import everySeries from 'async/everySeries';

The same as every but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • allSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in series. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filter(coll, iteratee, callbackopt)

+ + + + + +
+
import filter from 'async/filter';

Returns a new array of all the values in coll which pass an async truth +test. This operation is performed in parallel, but the results array will be +in the same order as the original.

+
+ + + +
+
Alias:
+
  • select
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.filter(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, results) {
+    // results now equals an array of the existing files
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) filterLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import filterLimit from 'async/filterLimit';

The same as filter but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • selectLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filterSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import filterSeries from 'async/filterSeries';

The same as filter but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • selectSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results)

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBy(coll, iteratee, callbackopt)

+ + + + + +
+
import groupBy from 'async/groupBy';

Returns a new object, where each value corresponds to an array of items, from +coll, that returned the corresponding key. That is, the keys of the object +correspond to the values passed to the iteratee callback.

+

Note: Since this function applies the iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order. +However, the values for each key in the result will be in the same order as +the original coll. For Objects, the values will roughly be in the order of +the original Objects' keys (but this can vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + +
Example
+ +
async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
+    db.findById(userId, function(err, user) {
+        if (err) return callback(err);
+        return callback(null, user.age);
+    });
+}, function(err, result) {
+    // result is object containing the userIds grouped by age
+    // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) groupByLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import groupByLimit from 'async/groupByLimit';

The same as groupBy but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBySeries(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import groupBySeries from 'async/groupBySeries';

The same as groupBy but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) map(coll, iteratee, callbackopt)

+ + + + + +
+
import map from 'async/map';

Produces a new collection of values by mapping each value in coll through +the iteratee function. The iteratee is called with an item from coll +and a callback for when it has finished processing. Each of these callback +takes 2 arguments: an error, and the transformed item from coll. If +iteratee passes an error to its callback, the main callback (for the +map function) is immediately called with the error.

+

Note, that since this function applies the iteratee to each item in +parallel, there is no guarantee that the iteratee functions will complete +in order. However, the results array will be in the same order as the +original coll.

+

If map is passed an Object, the results will be an Array. The results +will roughly be in the order of the original Objects' keys (but this can +vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an Array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+    // results is now an array of stats for each file
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import mapLimit from 'async/mapLimit';

The same as map but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import mapSeries from 'async/mapSeries';

The same as map but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValues(obj, iteratee, callbackopt)

+ + + + + +
+
import mapValues from 'async/mapValues';

A relative of map, designed for use with objects.

+

Produces a new Object by mapping each value of obj through the iteratee +function. The iteratee is called each value and key from obj and a +callback for when it has finished processing. Each of these callbacks takes +two arguments: an error, and the transformed item from obj. If iteratee +passes an error to its callback, the main callback (for the mapValues +function) is immediately called with the error.

+

Note, the order of the keys in the result is not guaranteed. The keys will +be roughly in the order they complete, (but this is very engine-specific)

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + +
Example
+ +
async.mapValues({
+    f1: 'file1',
+    f2: 'file2',
+    f3: 'file3'
+}, function (file, key, callback) {
+  fs.stat(file, callback);
+}, function(err, result) {
+    // result is now a map of stats for each file, e.g.
+    // {
+    //     f1: [stats for file1],
+    //     f2: [stats for file2],
+    //     f3: [stats for file3]
+    // }
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesLimit(obj, limit, iteratee, callbackopt)

+ + + + + +
+
import mapValuesLimit from 'async/mapValuesLimit';

The same as mapValues but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesSeries(obj, iteratee, callbackopt)

+ + + + + +
+
import mapValuesSeries from 'async/mapValuesSeries';

The same as mapValues but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reduce(coll, memo, iteratee, callbackopt)

+ + + + + +
+
import reduce from 'async/reduce';

Reduces coll into a single value using an async iteratee to return each +successive step. memo is the initial state of the reduction. This function +only operates in series.

+

For performance reasons, it may make sense to split a call to this function +into a parallel map, and then use the normal Array.prototype.reduce on the +results. This function is for situations where each step in the reduction +needs to be async; if you can get the data before reducing it, then it's +probably a good idea to do so.

+
+ + + +
+
Alias:
+
  • foldl
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + + + +
Example
+ +
async.reduce([1,2,3], 0, function(memo, item, callback) {
+    // pointless async:
+    process.nextTick(function() {
+        callback(null, memo + item)
+    });
+}, function(err, result) {
+    // result is now equal to the last value of memo, which is 6
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reduceRight(array, memo, iteratee, callbackopt)

+ + + + + +
+
import reduceRight from 'async/reduceRight';

Same as reduce, only operates on array in reverse order.

+
+ + + +
+
Alias:
+
  • foldr
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
array + + +Array + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee complete with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reject(coll, iteratee, callbackopt)

+ + + + + +
+
import reject from 'async/reject';

The opposite of filter. Removes values that pass an async truth test.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.reject(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, results) {
+    // results now equals an array of missing files
+    createFiles(results);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import rejectLimit from 'async/rejectLimit';

The same as reject but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import rejectSeries from 'async/rejectSeries';

The same as reject but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) some(coll, iteratee, callbackopt)

+ + + + + +
+
import some from 'async/some';

Returns true if at least one element in the coll satisfies an async test. +If any iteratee call returns true, the main callback is immediately +called.

+
+ + + +
+
Alias:
+
  • any
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + +
Example
+ +
async.some(['file1','file2','file3'], function(filePath, callback) {
+    fs.access(filePath, function(err) {
+        callback(null, !err)
+    });
+}, function(err, result) {
+    // if result is true then at least one of the files exists
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) someLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import someLimit from 'async/someLimit';

The same as some but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • anyLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) someSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import someSeries from 'async/someSeries';

The same as some but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • anySeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in series. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) sortBy(coll, iteratee, callback)

+ + + + + +
+
import sortBy from 'async/sortBy';

Sorts a list by the results of running each coll value through an async +iteratee.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a value to use as the sort criteria as +its result. +Invoked with (item, callback).

callback + + +function + + + + + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is the items +from the original coll sorted by the values returned by the iteratee +calls. Invoked with (err, results).

+ + + + + + +
Example
+ +
async.sortBy(['file1','file2','file3'], function(file, callback) {
+    fs.stat(file, function(err, stats) {
+        callback(err, stats.mtime);
+    });
+}, function(err, results) {
+    // results is now the original array of files sorted by
+    // modified date
+});
+
+// By modifying the callback parameter the
+// sorting order can be influenced:
+
+// ascending order
+async.sortBy([1,9,3,5], function(x, callback) {
+    callback(null, x);
+}, function(err,result) {
+    // result callback
+});
+
+// descending order
+async.sortBy([1,9,3,5], function(x, callback) {
+    callback(null, x*-1);    //<- x*-1 instead of x, turns the order around
+}, function(err,result) {
+    // result callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) transform(coll, accumulatoropt, iteratee, callbackopt)

+ + + + + +
+
import transform from 'async/transform';

A relative of reduce. Takes an Object or Array, and iterates over each +element in series, each step potentially mutating an accumulator value. +The type of the accumulator defaults to the type of collection passed in.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +Object + + + + + +

A collection to iterate over.

accumulator + + +* + + + + + + <optional> + +

The initial state of the transform. If omitted, +it will default to an empty Object or Array, depending on the type of coll

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +collection that potentially modifies the accumulator. +Invoked with (accumulator, item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the transformed accumulator. +Invoked with (err, result).

+ + + + + + +
Examples
+ +
async.transform([1,2,3], function(acc, item, index, callback) {
+    // pointless async:
+    process.nextTick(function() {
+        acc.push(item * 2)
+        callback(null)
+    });
+}, function(err, result) {
+    // result is now equal to [2, 4, 6]
+});
+ +
async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+    setImmediate(function () {
+        obj[key] = val * 2;
+        callback();
+    })
+}, function (err, result) {
+    // result is equal to {a: 2, b: 4, c: 6}
+})
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/module-ControlFlow.html b/docs/v2/module-ControlFlow.html new file mode 100644 index 000000000..c40cd7551 --- /dev/null +++ b/docs/v2/module-ControlFlow.html @@ -0,0 +1,6848 @@ + + + + + + + ControlFlow - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Control Flow

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for controlling the flow through a script.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) applyEach(fns, …argsopt, callbackopt) → {function}

+ + + + + +
+
import applyEach from 'async/applyEach';

Applies the provided arguments to each function in the array, calling +callback after all functions have completed. If you only provide the first +argument, fns, then it will return a function which lets you pass in the +arguments as if it were a single function call. If more arguments are +provided, callback is required while args is still optional.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of AsyncFunctions +to all call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • If only the first argument, fns, is provided, it will +return a function which lets you pass in the arguments as if it were a single +function call. The signature is (..args, callback). If invoked with any +arguments, callback is required.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+
+// partial application example:
+async.each(
+    buckets,
+    async.applyEach([enableSearch, updateSchema]),
+    callback
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) applyEachSeries(fns, …argsopt, callbackopt) → {function}

+ + + + + +
+
import applyEachSeries from 'async/applyEachSeries';

The same as applyEach but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of AsyncFunctions to all +call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • If only the first argument is provided, it will return +a function which lets you pass in the arguments as if it were a single +function call.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) auto(tasks, concurrencyopt, callbackopt)

+ + + + + +
+
import auto from 'async/auto';

Determines the best order for running the AsyncFunctions in tasks, based on +their requirements. Each function can optionally depend on other functions +being completed first, and each function is run as soon as its requirements +are satisfied.

+

If any of the AsyncFunctions pass an error to their callback, the auto sequence +will stop. Further tasks will not execute (so any other functions depending +on it will not run), and the main callback is immediately called with the +error.

+

AsyncFunctions also receive an object containing the results of functions which +have completed so far as the first argument, if they have dependencies. If a +task function has no dependencies, it will only be passed a callback.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
tasks + + +Object + + + + + + + +

An object. Each of its properties is either a +function or an array of requirements, with the AsyncFunction itself the last item +in the array. The object's key of a property serves as the name of the task +defined by that property, i.e. can be used when specifying requirements for +other tasks. The function receives one or two arguments:

+
    +
  • a results object, containing the results of the previously executed +functions, only passed if the task has any dependencies,
  • +
  • a callback(err, result) function, which must be called when finished, +passing an error (which can be null) and the result of the function's +execution.
  • +
concurrency + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for +determining the maximum number of tasks that can be run in parallel. By +default, as many as possible.

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback. Results are always returned; however, if an +error occurs, no further tasks will be performed, and the results object +will only contain partial results. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.auto({
+    // this function will just be passed a callback
+    readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+    showData: ['readData', function(results, cb) {
+        // results.readData is the file's contents
+        // ...
+    }]
+}, callback);
+
+async.auto({
+    get_data: function(callback) {
+        console.log('in get_data');
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        console.log('in make_folder');
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        console.log('in write_file', JSON.stringify(results));
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        console.log('in email_link', JSON.stringify(results));
+        // once the file is written let's email a link to it...
+        // results.write_file contains the filename returned by write_file.
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('results = ', results);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) autoInject(tasks, callbackopt)

+ + + + + +
+
import autoInject from 'async/autoInject';

A dependency-injected version of the async.auto function. Dependent +tasks are specified as parameters to the function, after the usual callback +parameter, with the parameter names matching the names of the tasks it +depends on. This can provide even more readable task graphs which can be +easier to maintain.

+

If a final callback is specified, the task results are similarly injected, +specified as named parameters after the initial error parameter.

+

The autoInject function is purely syntactic sugar and its semantics are +otherwise equivalent to async.auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Object + + + + + +

An object, each of whose properties is an AsyncFunction of +the form 'func([dependencies...], callback). The object's key of a property +serves as the name of the task defined by that property, i.e. can be used +when specifying requirements for other tasks.

+
    +
  • The callback parameter is a callback(err, result) which must be called +when finished, passing an error (which can be null) and the result of +the function's execution. The remaining parameters name other tasks on +which the task is dependent, and the results from those tasks are the +arguments of those parameters.
  • +
callback + + +function + + + + + + <optional> + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback, and a results object with any completed +task results, similar to auto.

+ + + + + + +
Example
+ +
//  The example from `auto` can be rewritten as follows:
+async.autoInject({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: function(get_data, make_folder, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    },
+    email_link: function(write_file, callback) {
+        // once the file is written let's email a link to it...
+        // write_file contains the filename returned by write_file.
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+
+// If you are using a JS minifier that mangles parameter names, `autoInject`
+// will not work with plain functions, since the parameter names will be
+// collapsed to a single letter identifier.  To work around this, you can
+// explicitly specify the names of the parameters your task function needs
+// in an array, similar to Angular.js dependency injection.
+
+// This still has an advantage over plain `auto`, since the results a task
+// depends on are still spread into arguments.
+async.autoInject({
+    //...
+    write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(write_file, callback) {
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }]
+    //...
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargo(worker, payloadopt) → {CargoObject}

+ + + + + +
+
import cargo from 'async/cargo';

Creates a cargo object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the payload limit). If the +worker is in progress, the task is queued until it becomes available. Once +the worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargo object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargo and inner queue.

+
+ + + +
+
+ Type +
+
+ +CargoObject + + +
+
+ + + + +
Example
+ +
// create a cargo object with payload 2
+var cargo = async.cargo(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2);
+
+// add some items
+cargo.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargo.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+cargo.push({name: 'baz'}, function(err) {
+    console.log('finished processing baz');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) compose(…functions) → {function}

+ + + + + +
+
import compose from 'async/compose';

Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions f(), g(), and h() would produce the result +of f(g(h())), only this version uses callbacks to obtain the return values.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

an asynchronous function that is the composed +asynchronous functions

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
function add1(n, callback) {
+    setTimeout(function () {
+        callback(null, n + 1);
+    }, 10);
+}
+
+function mul3(n, callback) {
+    setTimeout(function () {
+        callback(null, n * 3);
+    }, 10);
+}
+
+var add1mul3 = async.compose(mul3, add1);
+add1mul3(4, function (err, result) {
+    // result now equals 15
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) doDuring(fn, test, callbackopt)

+ + + + + +
+
import doDuring from 'async/doDuring';

The post-check version of during. To reflect the difference in +the order of operations, the arguments test and fn are switched.

+

Also a version of doWhilst with asynchronous test function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of fn. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of fn.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of fn has stopped. callback +will be passed an error if one occurred, otherwise null.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doUntil(iteratee, test, callbackopt)

+ + + + + +
+
import doUntil from 'async/doUntil';

Like 'doWhilst', except the test is inverted. Note the +argument ordering differs from until.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

test + + +function + + + + + +

synchronous truth test to perform after each +execution of iteratee. Invoked with any non-error callback results of +iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doWhilst(iteratee, test, callbackopt)

+ + + + + +
+
import doWhilst from 'async/doWhilst';

The post-check version of whilst. To reflect the difference in +the order of operations, the arguments test and iteratee are switched.

+

doWhilst is to whilst as do while is to while in plain JavaScript.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

A function which is called each time test +passes. Invoked with (callback).

test + + +function + + + + + +

synchronous truth test to perform after each +execution of iteratee. Invoked with any non-error callback results of +iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. +callback will be passed an error and any arguments passed to the final +iteratee's callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) during(test, fn, callbackopt)

+ + + + + +
+
import during from 'async/during';

Like whilst, except the test is an asynchronous function that +is passed a callback in the form of function (err, truth). If error is +passed to test or fn, the main callback is immediately called with the +value of the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of fn. Invoked with (callback).

fn + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of fn has stopped. callback +will be passed an error, if one occurred, otherwise null.

+ + + + + + +
Example
+ +
var count = 0;
+
+async.during(
+    function (callback) {
+        return callback(null, count < 5);
+    },
+    function (callback) {
+        count++;
+        setTimeout(callback, 1000);
+    },
+    function (err) {
+        // 5 seconds have passed
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) forever(fn, errbackopt)

+ + + + + +
+
import forever from 'async/forever';

Calls the asynchronous function fn with a callback parameter that allows it +to call itself again, in series, indefinitely. +If an error is passed to the callback then errback is called with the +error, and execution stops, otherwise it will never be called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function to call repeatedly. +Invoked with (next).

errback + + +function + + + + + + <optional> + +

when fn passes an error to it's callback, +this function will be called, and execution stops. Invoked with (err).

+ + + + + + +
Example
+ +
async.forever(
+    function(next) {
+        // next is suitable for passing to things that need a callback(err [, whatever]);
+        // it will result in this function being called again.
+    },
+    function(err) {
+        // if next is called with a value in its first parameter, it will appear
+        // in here as 'err', and execution will stop.
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallel(tasks, callbackopt)

+ + + + + +
+
import parallel from 'async/parallel';

Run the tasks collection of functions in parallel, without waiting until +the previous function has completed. If any of the functions pass an error to +its callback, the main callback is immediately called with the value of the +error. Once the tasks have completed, the results are passed to the final +callback as an array.

+

Note: parallel is about kicking-off I/O tasks in parallel, not about +parallel execution of code. If your tasks do not use any timers or perform +any I/O, they will actually be executed in series. Any synchronous setup +sections for each task will happen one after the other. JavaScript remains +single-threaded.

+

Hint: Use reflect to continue the +execution of other tasks when a task fails.

+

It is also possible to use an object instead of an array. Each property will +be run as a function and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.parallel.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + + + +
Example
+ +
async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// optional callback
+function(err, results) {
+    // the results array will equal ['one','two'] even though
+    // the second function had a shorter timeout.
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    // results is now equals to: {one: 1, two: 2}
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallelLimit(tasks, limit, callbackopt)

+ + + + + +
+
import parallelLimit from 'async/parallelLimit';

The same as parallel but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

limit + + +number + + + + + +

The maximum number of async operations at a time.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) priorityQueue(worker, concurrency) → {QueueObject}

+ + + + + +
+
import priorityQueue from 'async/priorityQueue';

The same as async.queue only tasks are assigned a priority and +completed in ascending priority order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
worker + + +AsyncFunction + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). +Invoked with (task, callback).

concurrency + + +number + + + + + +

An integer for determining how many worker +functions should be run in parallel. If omitted, the concurrency defaults to +1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A priorityQueue object to manage the tasks. There are two +differences between queue and priorityQueue objects:

+
    +
  • push(task, priority, [callback]) - priority should be a number. If an +array of tasks is given, all tasks will be assigned the same priority.
  • +
  • The unshift method was removed.
  • +
+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) queue(worker, concurrencyopt) → {QueueObject}

+ + + + + +
+
import queue from 'async/queue';

Creates a queue object with the specified concurrency. Tasks added to the +queue are processed in parallel (up to the concurrency limit). If all +workers are in progress, the task is queued until one becomes available. +Once a worker completes a task, that task's callback is called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). Invoked with (task, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A queue object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a queue object with concurrency 2
+var q = async.queue(function(task, callback) {
+    console.log('hello ' + task.name);
+    callback();
+}, 2);
+
+// assign a callback
+q.drain = function() {
+    console.log('all items have been processed');
+};
+
+// add some items to the queue
+q.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+q.push({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+
+// add some items to the queue (batch-wise)
+q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+    console.log('finished processing item');
+});
+
+// add some items to the front of the queue
+q.unshift({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) race(tasks, callback)

+ + + + + +
+
import race from 'async/race';

Runs the tasks array of functions in parallel, without waiting until the +previous function has completed. Once any of the tasks complete or pass an +error to its callback, the main callback is immediately called. It's +equivalent to Promise.race().

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array containing async functions +to run. Each function can complete with an optional result value.

callback + + +function + + + + + +

A callback to run once any of the functions have +completed. This function gets an error or result from the first function that +completed. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.race([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// main callback
+function(err, result) {
+    // the result will be equal to 'two' as it finishes earlier
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) retry(optsopt, task, callbackopt)

+ + + + + +
+
import retry from 'async/retry';

Attempts to get a successful response from task no more than times times +before returning an error. If the task is successful, the callback will be +passed the result of the successful task. If all attempts fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

Can be either an +object with times and interval or a number.

+
    +
  • times - The number of attempts to make before giving up. The default +is 5.
  • +
  • interval - The time to wait between retries, in milliseconds. The +default is 0. The interval may also be specified as a function of the +retry count (see example).
  • +
  • errorFilter - An optional synchronous function that is invoked on +erroneous result. If it returns true the retry attempts will continue; +if the function returns false the retry flow is aborted with the current +attempt's error and result being returned to the final callback. +Invoked with (err).
  • +
  • If opts is a number, the number specifies the number of times to retry, +with the default interval of 0.
  • +
task + + +AsyncFunction + + + + + + + +

An async function to retry. +Invoked with (callback).

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when the +task has succeeded, or after the final failed attempt. It receives the err +and result arguments of the last attempt at completing the task. Invoked +with (err, results).

+ + + + + + +
Example
+ +
// The `retry` function can be used as a stand-alone control flow by passing
+// a callback, as shown below:
+
+// try calling apiMethod 3 times
+async.retry(3, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 3 times, waiting 200 ms between each retry
+async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 10 times with exponential backoff
+// (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+async.retry({
+  times: 10,
+  interval: function(retryCount) {
+    return 50 * Math.pow(2, retryCount);
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod the default 5 times no delay between each retry
+async.retry(apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod only when error condition satisfies, all other
+// errors will abort the retry control flow and return to final callback
+async.retry({
+  errorFilter: function(err) {
+    return err.message === 'Temporary error'; // only retry on a specific error
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// to retry individual methods that are not as reliable within other
+// control flow functions, use the `retryable` wrapper:
+async.auto({
+    users: api.getUsers.bind(api),
+    payments: async.retryable(3, api.getPayments.bind(api))
+}, function(err, results) {
+    // do something with the results
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) retryable(optsopt, task) → {AsyncFunction}

+ + + + + +
+
import retryable from 'async/retryable';

A close relative of retry. This method +wraps a task and makes it retryable, rather than immediately calling it +with retries.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

optional +options, exactly the same as from retry

task + + +AsyncFunction + + + + + + + +

the asynchronous function to wrap. +This function will be passed any arguments passed to the returned wrapper. +Invoked with (...args, callback).

+ + + + +
Returns:
+ + +
+

The wrapped function, which when invoked, will +retry on an error, based on the parameters specified in opts. +This function will accept the same parameters as task.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.auto({
+    dep1: async.retryable(3, getFromFlakyService),
+    process: ["dep1", async.retryable(3, function (results, cb) {
+        maybeProcessData(results.dep1, cb);
+    })]
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) seq(…functions) → {function}

+ + + + + +
+
import seq from 'async/seq';

Version of the compose function that is more natural to read. Each function +consumes the return value of the previous function. It is the equivalent of +compose with the arguments reversed.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

a function that composes the functions in order

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// Requires lodash (or underscore), express3 and dresende's orm2.
+// Part of an app, that fetches cats of the logged user.
+// This example uses `seq` function to avoid overnesting and error
+// handling clutter.
+app.get('/cats', function(request, response) {
+    var User = request.models.User;
+    async.seq(
+        _.bind(User.get, User),  // 'User.get' has signature (id, callback(err, data))
+        function(user, fn) {
+            user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+        }
+    )(req.session.user_id, function (err, cats) {
+        if (err) {
+            console.error(err);
+            response.json({ status: 'error', message: err.message });
+        } else {
+            response.json({ status: 'ok', message: 'Cats found', data: cats });
+        }
+    });
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) series(tasks, callbackopt)

+ + + + + +
+
import series from 'async/series';

Run the functions in the tasks collection in series, each one running once +the previous function has completed. If any functions in the series pass an +error to its callback, no more functions are run, and callback is +immediately called with the value of the error. Otherwise, callback +receives an array of results when tasks have completed.

+

It is also possible to use an object instead of an array. Each property will +be run as a function, and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling + results from async.series.

+

Note that while many implementations preserve the order of object +properties, the ECMAScript Language Specification +explicitly states that

+
+

The mechanics and order of enumerating the properties is not specified.

+
+

So if you rely on the order in which your series of functions are executed, +and want this to work on all platforms, consider using an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection containing +async functions to run in series. +Each function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This function gets a results array (or object) +containing all the result arguments passed to the task callbacks. Invoked +with (err, result).

+ + + + + + +
Example
+ +
async.series([
+    function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    },
+    function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    }
+],
+// optional callback
+function(err, results) {
+    // results is now equal to ['one', 'two']
+});
+
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback){
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    // results is now equal to: {one: 1, two: 2}
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) times(n, iteratee, callback)

+ + + + + +
+
import times from 'async/times';

Calls the iteratee function n times, and accumulates results in the same +manner you would use with map.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + + + +
Example
+ +
// Pretend this is some complicated async factory
+var createUser = function(id, callback) {
+    callback(null, {
+        id: 'user' + id
+    });
+};
+
+// generate 5 users
+async.times(5, function(n, next) {
+    createUser(n, function(err, user) {
+        next(err, user);
+    });
+}, function(err, users) {
+    // we should now have 5 users
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesLimit(count, limit, iteratee, callback)

+ + + + + +
+
import timesLimit from 'async/timesLimit';

The same as times but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
count + + +number + + + + + +

The number of times to run the function.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see async.map.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesSeries(n, iteratee, callback)

+ + + + + +
+
import timesSeries from 'async/timesSeries';

The same as times but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) tryEach(tasks, callbackopt)

+ + + + + +
+
import tryEach from 'async/tryEach';

It runs each task in series but stops whenever any of the functions were +successful. If one of the tasks were successful, the callback will be +passed the result of the successful task. If all tasks fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +Object + + + + + +

A collection containing functions to +run, each function is passed a callback(err, result) it must call on +completion with an error err (which can be null) and an optional result +value.

callback + + +function + + + + + + <optional> + +

An optional callback which is called when one +of the tasks has succeeded, or all have failed. It receives the err and +result arguments of the last attempt at completing the task. Invoked with +(err, results).

+ + + + + + +
Example
+ +
async.tryEach([
+    function getDataFromFirstWebsite(callback) {
+        // Try getting the data from the first website
+        callback(err, data);
+    },
+    function getDataFromSecondWebsite(callback) {
+        // First website failed,
+        // Try getting the data from the backup website
+        callback(err, data);
+    }
+],
+// optional callback
+function(err, results) {
+    Now do something with the data.
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) until(test, iteratee, callbackopt)

+ + + + + +
+
import until from 'async/until';

Repeatedly call iteratee until test returns true. Calls callback when +stopped, or an error occurs. callback will be passed an error and any +arguments passed to the final iteratee's callback.

+

The inverse of whilst.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +function + + + + + +

synchronous truth test to perform before each +execution of iteratee. Invoked with ().

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) waterfall(tasks, callbackopt)

+ + + + + +
+
import waterfall from 'async/waterfall';

Runs the tasks array of functions in series, each passing their results to +the next in the array. However, if any of the tasks pass an error to their +own callback, the next function is not executed, and the main callback is +immediately called with the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array of async functions +to run. +Each function should complete with any number of result values. +The result values will be passed as arguments, in order, to the next task.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This will be passed the results of the last task's +callback. Invoked with (err, [results]).

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
async.waterfall([
+    function(callback) {
+        callback(null, 'one', 'two');
+    },
+    function(arg1, arg2, callback) {
+        // arg1 now equals 'one' and arg2 now equals 'two'
+        callback(null, 'three');
+    },
+    function(arg1, callback) {
+        // arg1 now equals 'three'
+        callback(null, 'done');
+    }
+], function (err, result) {
+    // result now equals 'done'
+});
+
+// Or, with named functions:
+async.waterfall([
+    myFirstFunction,
+    mySecondFunction,
+    myLastFunction,
+], function (err, result) {
+    // result now equals 'done'
+});
+function myFirstFunction(callback) {
+    callback(null, 'one', 'two');
+}
+function mySecondFunction(arg1, arg2, callback) {
+    // arg1 now equals 'one' and arg2 now equals 'two'
+    callback(null, 'three');
+}
+function myLastFunction(arg1, callback) {
+    // arg1 now equals 'three'
+    callback(null, 'done');
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) whilst(test, iteratee, callbackopt)

+ + + + + +
+
import whilst from 'async/whilst';

Repeatedly call iteratee, while test returns true. Calls callback when +stopped, or an error occurs.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +function + + + + + +

synchronous truth test to perform before each +execution of iteratee. Invoked with ().

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

undefined

+
+ + + + + + +
Example
+ +
var count = 0;
+async.whilst(
+    function() { return count < 5; },
+    function(callback) {
+        count++;
+        setTimeout(function() {
+            callback(null, count);
+        }, 1000);
+    },
+    function (err, n) {
+        // 5 seconds have passed, n = 5
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + +

CargoObject

+ + + + +
+
import cargo from 'async/cargo';

A cargo of tasks for the worker function to complete. Cargo inherits all of +the same methods and event callbacks as queue.

+
+ + + +
Type:
+
    +
  • + +Object + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

A function returning the number of items +waiting to be processed. Invoke like cargo.length().

payload + + +number + + + +

An integer for determining how many tasks +should be process per round. This property can be changed after a cargo is +created to alter the payload on-the-fly.

push + + +function + + + +

Adds task to the queue. The callback is +called once the worker has finished processing the task. Instead of a +single task, an array of tasks can be submitted. The respective callback is +used for every task in the list. Invoke like cargo.push(task, [callback]).

saturated + + +function + + + +

A callback that is called when the +queue.length() hits the concurrency and further tasks will be queued.

empty + + +function + + + +

A callback that is called when the last item +from the queue is given to a worker.

drain + + +function + + + +

A callback that is called when the last item +from the queue has returned from the worker.

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke like cargo.idle().

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke like cargo.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke like cargo.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. Invoke like cargo.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

QueueObject

+ + + + +
+
import queue from 'async/queue';

A queue of tasks for the worker function to complete.

+
+ + + +
Type:
+
    +
  • + +Object + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

a function returning the number of items +waiting to be processed. Invoke with queue.length().

started + + +boolean + + + +

a boolean indicating whether or not any +items have been pushed and processed by the queue.

running + + +function + + + +

a function returning the number of items +currently being processed. Invoke with queue.running().

workersList + + +function + + + +

a function returning the array of items +currently being processed. Invoke with queue.workersList().

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke with queue.idle().

concurrency + + +number + + + +

an integer for determining how many worker +functions should be run in parallel. This property can be changed after a +queue is created to alter the concurrency on-the-fly.

push + + +function + + + +

add a new task to the queue. Calls callback +once the worker has finished processing the task. Instead of a single task, +a tasks array can be submitted. The respective callback is used for every +task in the list. Invoke with queue.push(task, [callback]),

unshift + + +function + + + +

add a new task to the front of the queue. +Invoke with queue.unshift(task, [callback]).

remove + + +function + + + +

remove items from the queue that match a test +function. The test function will be passed an object with a data property, +and a priority property, if this is a +priorityQueue object. +Invoked with queue.remove(testFn), where testFn is of the form +function ({data, priority}) {} and returns a Boolean.

saturated + + +function + + + +

a callback that is called when the number of +running workers hits the concurrency limit, and further tasks will be +queued.

unsaturated + + +function + + + +

a callback that is called when the number +of running workers is less than the concurrency & buffer limits, and +further tasks will not be queued.

buffer + + +number + + + +

A minimum threshold buffer in order to say that +the queue is unsaturated.

empty + + +function + + + +

a callback that is called when the last item +from the queue is given to a worker.

drain + + +function + + + +

a callback that is called when the last item +from the queue has returned from the worker.

error + + +function + + + +

a callback that is called when a task errors. +Has the signature function(error, task).

paused + + +boolean + + + +

a boolean for determining whether the queue is +in a paused state.

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke with queue.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke with queue.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. No more tasks +should be pushed to the queue after calling this function. Invoke with queue.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/module-Utils.html b/docs/v2/module-Utils.html new file mode 100644 index 000000000..d1e2ccf5b --- /dev/null +++ b/docs/v2/module-Utils.html @@ -0,0 +1,2720 @@ + + + + + + + Utils - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Utils

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async utility functions.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) apply(fn) → {function}

+ + + + + +
+
import apply from 'async/apply';

Creates a continuation function with some arguments already applied.

+

Useful as a shorthand when combined with other control flow functions. Any +arguments passed to the returned function are added to the arguments +originally passed to apply.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function you want to eventually apply all +arguments to. Invokes with (arguments...).

arguments... + + +* + + + + + +

Any number of arguments to automatically apply +when the continuation is called.

+ + + + +
Returns:
+ + +
+

the partially-applied function

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// using apply
+async.parallel([
+    async.apply(fs.writeFile, 'testfile1', 'test1'),
+    async.apply(fs.writeFile, 'testfile2', 'test2')
+]);
+
+
+// the same process without using apply
+async.parallel([
+    function(callback) {
+        fs.writeFile('testfile1', 'test1', callback);
+    },
+    function(callback) {
+        fs.writeFile('testfile2', 'test2', callback);
+    }
+]);
+
+// It's possible to pass any number of additional arguments when calling the
+// continuation:
+
+node> var fn = async.apply(sys.puts, 'one');
+node> fn('two', 'three');
+one
+two
+three
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) asyncify(func) → {AsyncFunction}

+ + + + + +
+
import asyncify from 'async/asyncify';

Take a sync function and make it async, passing its return value to a +callback. This is useful for plugging sync functions into a waterfall, +series, or other async functions. Any arguments passed to the generated +function will be passed to the wrapped function (except for the final +callback argument). Errors thrown will be passed to the callback.

+

If the function passed to asyncify returns a Promise, that promises's +resolved/rejected state will be used to call the callback, rather than simply +the synchronous return value.

+

This also means you can asyncify ES2017 async functions.

+
+ + + +
+
Alias:
+
  • wrapSync
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
func + + +function + + + + + +

The synchronous function, or Promise-returning +function to convert to an AsyncFunction.

+ + + + +
Returns:
+ + +
+

An asynchronous wrapper of the func. To be +invoked with (args..., callback).

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
// passing a regular synchronous function
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(JSON.parse),
+    function (data, next) {
+        // data is the result of parsing the text.
+        // If there was a parsing error, it would have been caught.
+    }
+], callback);
+
+// passing a function returning a promise
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(function (contents) {
+        return db.model.create(contents);
+    }),
+    function (model, next) {
+        // `model` is the instantiated model object.
+        // If there was an error, this function would be skipped.
+    }
+], callback);
+
+// es2017 example, though `asyncify` is not needed if your JS environment
+// supports async functions out of the box
+var q = async.queue(async.asyncify(async function(file) {
+    var intermediateStep = await processFile(file);
+    return await somePromise(intermediateStep)
+}));
+
+q.push(files);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) constant() → {AsyncFunction}

+ + + + + +
+
import constant from 'async/constant';

Returns a function that when called, calls-back with the values provided. +Useful as the first function in a waterfall, or for plugging values in to +auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
arguments... + + +* + + + + + +

Any number of arguments to automatically invoke +callback with.

+ + + + +
Returns:
+ + +
+

Returns a function that when invoked, automatically +invokes the callback with the previous given arguments.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    async.constant(42),
+    function (value, next) {
+        // value === 42
+    },
+    //...
+], callback);
+
+async.waterfall([
+    async.constant(filename, "utf8"),
+    fs.readFile,
+    function (fileData, next) {
+        //...
+    }
+    //...
+], callback);
+
+async.auto({
+    hostname: async.constant("https://server.net/"),
+    port: findFreePort,
+    launchServer: ["hostname", "port", function (options, cb) {
+        startServer(options, cb);
+    }],
+    //...
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) dir(function)

+ + + + + +
+
import dir from 'async/dir';

Logs the result of an async function to the +console using console.dir to display the properties of the resulting object. +Only works in Node.js or in browsers that support console.dir and +console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, +console.dir is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, {hello: name});
+    }, 1000);
+};
+
+// in the node repl
+node> async.dir(hello, 'world');
+{hello: 'world'}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) ensureAsync(fn) → {AsyncFunction}

+ + + + + +
+
import ensureAsync from 'async/ensureAsync';

Wrap an async function and ensure it calls its callback on a later tick of +the event loop. If the function already calls its callback on a next tick, +no extra deferral is added. This is useful for preventing stack overflows +(RangeError: Maximum call stack size exceeded) and generally keeping +Zalgo +contained. ES2017 async functions are returned as-is -- they are immune +to Zalgo's corrupting influences, as they always resolve on a later tick.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function, one that expects a node-style +callback as its last argument.

+ + + + +
Returns:
+ + +
+

Returns a wrapped function with the exact same call +signature as the function passed in.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function sometimesAsync(arg, callback) {
+    if (cache[arg]) {
+        return callback(null, cache[arg]); // this would be synchronous!!
+    } else {
+        doSomeIO(arg, callback); // this IO would be asynchronous
+    }
+}
+
+// this has a risk of stack overflows if many results are cached in a row
+async.mapSeries(args, sometimesAsync, done);
+
+// this will defer sometimesAsync's callback if necessary,
+// preventing stack overflows
+async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) log(function)

+ + + + + +
+
import log from 'async/log';

Logs the result of an async function to the console. Only works in +Node.js or in browsers that support console.log and console.error (such +as FF and Chrome). If multiple arguments are returned from the async +function, console.log is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, 'hello ' + name);
+    }, 1000);
+};
+
+// in the node repl
+node> async.log(hello, 'world');
+'hello world'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) memoize(fn, hasher) → {AsyncFunction}

+ + + + + +
+
import memoize from 'async/memoize';

Caches the results of an async function. When creating a hash to store +function results against, the callback is omitted from the hash and an +optional hash function can be used.

+

If no hash function is specified, the first argument is used as a hash key, +which may work reasonably if it is a string or a data type that converts to a +distinct string. Note that objects and arrays will not behave reasonably. +Neither will cases where the other arguments are significant. In such cases, +specify your own hash function.

+

The cache of results is exposed as the memo property of the function +returned by memoize.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function to proxy and cache results from.

hasher + + +function + + + + + +

An optional function for generating a custom hash +for storing results. It has all the arguments applied to it apart from the +callback, and must be synchronous.

+ + + + +
Returns:
+ + +
+

a memoized version of fn

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
var slow_fn = function(name, callback) {
+    // do something
+    callback(null, result);
+};
+var fn = async.memoize(slow_fn);
+
+// fn can now be used as if it were slow_fn
+fn('some name', function() {
+    // callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) nextTick(callback)

+ + + + + +
+
import nextTick from 'async/nextTick';

Calls callback on a later loop around the event loop. In Node.js this just +calls process.nextTick. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reflect(fn) → {function}

+ + + + + +
+
import reflect from 'async/reflect';

Wraps the async function in another function that always completes with a +result object, even when it errors.

+

The result object has either the property error or value.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function you want to wrap

+ + + + +
Returns:
+ + +
+
    +
  • A function that always passes null to it's callback as +the error. The second argument to the callback will be an object with +either an error or a value property.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.parallel([
+    async.reflect(function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff but error ...
+        callback('bad stuff happened');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    })
+],
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = 'bad stuff happened'
+    // results[2].value = 'two'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reflectAll(tasks) → {Array}

+ + + + + +
+
import reflectAll from 'async/reflectAll';

A helper function that wraps an array or an object of functions with reflect.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Object +| + +Iterable + + + + + +

The collection of +async functions to wrap in async.reflect.

+ + + + +
Returns:
+ + +
+

Returns an array of async functions, each wrapped in +async.reflect

+
+ + + +
+
+ Type +
+
+ +Array + + +
+
+ + + + +
Example
+ +
let tasks = [
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        // do some more stuff but error ...
+        callback(new Error('bad stuff happened'));
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+];
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = Error('bad stuff happened')
+    // results[2].value = 'two'
+});
+
+// an example using an object instead of an array
+let tasks = {
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    two: function(callback) {
+        callback('two');
+    },
+    three: function(callback) {
+        setTimeout(function() {
+            callback(null, 'three');
+        }, 100);
+    }
+};
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results.one.value = 'one'
+    // results.two.error = 'two'
+    // results.three.value = 'three'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) setImmediate(callback)

+ + + + + +
+
import setImmediate from 'async/setImmediate';

Calls callback on a later loop around the event loop. In Node.js this just +calls setImmediate. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timeout(asyncFn, milliseconds, infoopt) → {AsyncFunction}

+ + + + + +
+
import timeout from 'async/timeout';

Sets a time limit on an asynchronous function. If the function does not call +its callback within the specified milliseconds, it will be called with a +timeout error. The code property for the error object will be 'ETIMEDOUT'.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
asyncFn + + +AsyncFunction + + + + + +

The async function to limit in time.

milliseconds + + +number + + + + + +

The specified time limit.

info + + +* + + + + + + <optional> + +

Any variable you want attached (string, object, etc) +to timeout Error for more information..

+ + + + +
Returns:
+ + +
+

Returns a wrapped function that can be used with any +of the control flow functions. +Invoke this function with the same parameters as you would asyncFunc.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function myFunction(foo, callback) {
+    doAsyncTask(foo, function(err, data) {
+        // handle errors
+        if (err) return callback(err);
+
+        // do some stuff ...
+
+        // return processed data
+        return callback(null, data);
+    });
+}
+
+var wrapped = async.timeout(myFunction, 1000);
+
+// call `wrapped` as you would `myFunction`
+wrapped({ bar: 'bar' }, function(err, data) {
+    // if `myFunction` takes < 1000 ms to execute, `err`
+    // and `data` will have their expected values
+
+    // else `err` will be an Error with the code 'ETIMEDOUT'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) unmemoize(fn) → {AsyncFunction}

+ + + + + +
+
import unmemoize from 'async/unmemoize';

Undoes a memoized function, reverting it to the original, +unmemoized form. Handy for testing.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

the memoized function

+ + + + +
Returns:
+ + +
+

a function that calls the original unmemoized function

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/module-async.html b/docs/v2/module-async.html new file mode 100644 index 000000000..af0b73cbd --- /dev/null +++ b/docs/v2/module-async.html @@ -0,0 +1,228 @@ + + + + + + + async - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

async

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via +npm install --save async, it can also be used directly in the browser.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/nextTick.js.html b/docs/v2/nextTick.js.html new file mode 100644 index 000000000..e63531806 --- /dev/null +++ b/docs/v2/nextTick.js.html @@ -0,0 +1,154 @@ + + + + + + + nextTick.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

nextTick.js

+ + + + + + + +
+
+
'use strict';
+
+import { hasNextTick, hasSetImmediate, fallback, wrap }  from './internal/setImmediate';
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `process.nextTick`.  In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.setImmediate]{@link module:Utils.setImmediate}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ *     call_order.push('two');
+ *     // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ *     // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer;
+
+if (hasNextTick) {
+    _defer = process.nextTick;
+} else if (hasSetImmediate) {
+    _defer = setImmediate;
+} else {
+    _defer = fallback;
+}
+
+export default wrap(_defer);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/parallel.js.html b/docs/v2/parallel.js.html new file mode 100644 index 000000000..37792837d --- /dev/null +++ b/docs/v2/parallel.js.html @@ -0,0 +1,183 @@ + + + + + + + parallel.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

parallel.js

+ + + + + + + +
+
+
import eachOf from './eachOf';
+import parallel from './internal/parallel';
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code.  If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series.  Any synchronous setup
+ * sections for each task will happen one after the other.  JavaScript remains
+ * single-threaded.
+ *
+ * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
+ * execution of other tasks when a task fails.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ *
+ * @example
+ * async.parallel([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     // the results array will equal ['one','two'] even though
+ *     // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }, function(err, results) {
+ *     // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+export default function parallelLimit(tasks, callback) {
+    parallel(eachOf, tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/parallelLimit.js.html b/docs/v2/parallelLimit.js.html new file mode 100644 index 000000000..d716aa89d --- /dev/null +++ b/docs/v2/parallelLimit.js.html @@ -0,0 +1,133 @@ + + + + + + + parallelLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

parallelLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './internal/eachOfLimit';
+import parallel from './internal/parallel';
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+export default function parallelLimit(tasks, limit, callback) {
+    parallel(eachOfLimit(limit), tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/priorityQueue.js.html b/docs/v2/priorityQueue.js.html new file mode 100644 index 000000000..83c50bcb3 --- /dev/null +++ b/docs/v2/priorityQueue.js.html @@ -0,0 +1,186 @@ + + + + + + + priorityQueue.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

priorityQueue.js

+ + + + + + + +
+
+
import isArray from 'lodash/isArray';
+import noop from 'lodash/noop';
+
+import setImmediate from './setImmediate';
+
+import queue from './queue';
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`.
+ * Invoked with (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel.  If omitted, the concurrency defaults to
+ * `1`.  If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ *   array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */
+export default function(worker, concurrency) {
+    // Start with a normal queue
+    var q = queue(worker, concurrency);
+
+    // Override push to accept second parameter representing priority
+    q.push = function(data, priority, callback) {
+        if (callback == null) callback = noop;
+        if (typeof callback !== 'function') {
+            throw new Error('task callback must be a function');
+        }
+        q.started = true;
+        if (!isArray(data)) {
+            data = [data];
+        }
+        if (data.length === 0) {
+            // call drain immediately if there are no tasks
+            return setImmediate(function() {
+                q.drain();
+            });
+        }
+
+        priority = priority || 0;
+        var nextNode = q._tasks.head;
+        while (nextNode && priority >= nextNode.priority) {
+            nextNode = nextNode.next;
+        }
+
+        for (var i = 0, l = data.length; i < l; i++) {
+            var item = {
+                data: data[i],
+                priority: priority,
+                callback: callback
+            };
+
+            if (nextNode) {
+                q._tasks.insertBefore(nextNode, item);
+            } else {
+                q._tasks.push(item);
+            }
+        }
+        setImmediate(q.process);
+    };
+
+    // Remove unshift function
+    delete q.unshift;
+
+    return q;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/queue.js.html b/docs/v2/queue.js.html new file mode 100644 index 000000000..34bdebc2e --- /dev/null +++ b/docs/v2/queue.js.html @@ -0,0 +1,222 @@ + + + + + + + queue.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

queue.js

+ + + + + + + +
+
+
import queue from './internal/queue';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} remove - remove items from the queue that match a test
+ * function.  The test function will be passed an object with a `data` property,
+ * and a `priority` property, if this is a
+ * [priorityQueue]{@link module:ControlFlow.priorityQueue} object.
+ * Invoked with `queue.remove(testFn)`, where `testFn` is of the form
+ * `function ({data, priority}) {}` and returns a Boolean.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. No more tasks
+ * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`. Invoked with (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel.  If omitted, the concurrency
+ * defaults to `1`.  If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ *     console.log('hello ' + task.name);
+ *     callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ *     console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ *     console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ *     console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ *     console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ *     console.log('finished processing bar');
+ * });
+ */
+export default function (worker, concurrency) {
+    var _worker = wrapAsync(worker);
+    return queue(function (items, cb) {
+        _worker(items[0], cb);
+    }, concurrency, 1);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/race.js.html b/docs/v2/race.js.html new file mode 100644 index 000000000..03bc98f1c --- /dev/null +++ b/docs/v2/race.js.html @@ -0,0 +1,157 @@ + + + + + + + race.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

race.js

+ + + + + + + +
+
+
import isArray from 'lodash/isArray';
+import noop from 'lodash/noop';
+import once from './internal/once';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
+ * to run. Each function can complete with an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ],
+ * // main callback
+ * function(err, result) {
+ *     // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+export default function race(tasks, callback) {
+    callback = once(callback || noop);
+    if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+    if (!tasks.length) return callback();
+    for (var i = 0, l = tasks.length; i < l; i++) {
+        wrapAsync(tasks[i])(callback);
+    }
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/reduce.js.html b/docs/v2/reduce.js.html new file mode 100644 index 000000000..4b97367bf --- /dev/null +++ b/docs/v2/reduce.js.html @@ -0,0 +1,165 @@ + + + + + + + reduce.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reduce.js

+ + + + + + + +
+
+
import eachOfSeries from './eachOfSeries';
+import noop from 'lodash/noop';
+import once from './internal/once';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ *     // pointless async:
+ *     process.nextTick(function() {
+ *         callback(null, memo + item)
+ *     });
+ * }, function(err, result) {
+ *     // result is now equal to the last value of memo, which is 6
+ * });
+ */
+export default function reduce(coll, memo, iteratee, callback) {
+    callback = once(callback || noop);
+    var _iteratee = wrapAsync(iteratee);
+    eachOfSeries(coll, function(x, i, callback) {
+        _iteratee(memo, x, function(err, v) {
+            memo = v;
+            callback(err);
+        });
+    }, function(err) {
+        callback(err, memo);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/reduceRight.js.html b/docs/v2/reduceRight.js.html new file mode 100644 index 000000000..ffcaf4d65 --- /dev/null +++ b/docs/v2/reduceRight.js.html @@ -0,0 +1,137 @@ + + + + + + + reduceRight.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reduceRight.js

+ + + + + + + +
+
+
import reduce from './reduce';
+import slice from './internal/slice';
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+export default function reduceRight (array, memo, iteratee, callback) {
+    var reversed = slice(array).reverse();
+    reduce(reversed, memo, iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/reflect.js.html b/docs/v2/reflect.js.html new file mode 100644 index 000000000..2abd95785 --- /dev/null +++ b/docs/v2/reflect.js.html @@ -0,0 +1,171 @@ + + + + + + + reflect.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reflect.js

+ + + + + + + +
+
+
import initialParams from './internal/initialParams';
+import slice from './internal/slice';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Wraps the async function in another function that always completes with a
+ * result object, even when it errors.
+ *
+ * The result object has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ *     async.reflect(function(callback) {
+ *         // do some stuff ...
+ *         callback(null, 'one');
+ *     }),
+ *     async.reflect(function(callback) {
+ *         // do some more stuff but error ...
+ *         callback('bad stuff happened');
+ *     }),
+ *     async.reflect(function(callback) {
+ *         // do some more stuff ...
+ *         callback(null, 'two');
+ *     })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results[0].value = 'one'
+ *     // results[1].error = 'bad stuff happened'
+ *     // results[2].value = 'two'
+ * });
+ */
+export default function reflect(fn) {
+    var _fn = wrapAsync(fn);
+    return initialParams(function reflectOn(args, reflectCallback) {
+        args.push(function callback(error, cbArg) {
+            if (error) {
+                reflectCallback(null, { error: error });
+            } else {
+                var value;
+                if (arguments.length <= 2) {
+                    value = cbArg
+                } else {
+                    value = slice(arguments, 1);
+                }
+                reflectCallback(null, { value: value });
+            }
+        });
+
+        return _fn.apply(this, args);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/reflectAll.js.html b/docs/v2/reflectAll.js.html new file mode 100644 index 000000000..a4d1be3ef --- /dev/null +++ b/docs/v2/reflectAll.js.html @@ -0,0 +1,192 @@ + + + + + + + reflectAll.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reflectAll.js

+ + + + + + + +
+
+
import reflect from './reflect';
+import isArray from 'lodash/isArray';
+import _arrayMap from 'lodash/_arrayMap';
+import forOwn from 'lodash/_baseForOwn';
+
+/**
+ * A helper function that wraps an array or an object of functions with `reflect`.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array|Object|Iterable} tasks - The collection of
+ * [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of async functions, each wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         // do some more stuff but error ...
+ *         callback(new Error('bad stuff happened'));
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results[0].value = 'one'
+ *     // results[1].error = Error('bad stuff happened')
+ *     // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         callback('two');
+ *     },
+ *     three: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'three');
+ *         }, 100);
+ *     }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results.one.value = 'one'
+ *     // results.two.error = 'two'
+ *     // results.three.value = 'three'
+ * });
+ */
+export default function reflectAll(tasks) {
+    var results;
+    if (isArray(tasks)) {
+        results = _arrayMap(tasks, reflect);
+    } else {
+        results = {};
+        forOwn(tasks, function(task, key) {
+            results[key] = reflect.call(this, task);
+        });
+    }
+    return results;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/reject.js.html b/docs/v2/reject.js.html new file mode 100644 index 000000000..1d57bc235 --- /dev/null +++ b/docs/v2/reject.js.html @@ -0,0 +1,139 @@ + + + + + + + reject.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reject.js

+ + + + + + + +
+
+
import reject from './internal/reject';
+import doParallel from './internal/doParallel';
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ *     fs.access(filePath, function(err) {
+ *         callback(null, !err)
+ *     });
+ * }, function(err, results) {
+ *     // results now equals an array of missing files
+ *     createFiles(results);
+ * });
+ */
+export default doParallel(reject);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/rejectLimit.js.html b/docs/v2/rejectLimit.js.html new file mode 100644 index 000000000..26c8e2ab3 --- /dev/null +++ b/docs/v2/rejectLimit.js.html @@ -0,0 +1,131 @@ + + + + + + + rejectLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

rejectLimit.js

+ + + + + + + +
+
+
import reject from './internal/reject';
+import doParallelLimit from './internal/doParallelLimit';
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+export default doParallelLimit(reject);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/rejectSeries.js.html b/docs/v2/rejectSeries.js.html new file mode 100644 index 000000000..06fd4227a --- /dev/null +++ b/docs/v2/rejectSeries.js.html @@ -0,0 +1,129 @@ + + + + + + + rejectSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

rejectSeries.js

+ + + + + + + +
+
+
import rejectLimit from './rejectLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+export default doLimit(rejectLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/retry.js.html b/docs/v2/retry.js.html new file mode 100644 index 000000000..2a5dd1ab3 --- /dev/null +++ b/docs/v2/retry.js.html @@ -0,0 +1,250 @@ + + + + + + + retry.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

retry.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import constant from 'lodash/constant';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @see [async.retryable]{@link module:ControlFlow.retryable}
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up.  The default
+ *   is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds.  The
+ *   default is `0`. The interval may also be specified as a function of the
+ *   retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ *   erroneous result. If it returns `true` the retry attempts will continue;
+ *   if the function returns `false` the retry flow is aborted with the current
+ *   attempt's error and result being returned to the final callback.
+ *   Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ *   with the default interval of `0`.
+ * @param {AsyncFunction} task - An async function to retry.
+ * Invoked with (callback).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ *
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ *   times: 10,
+ *   interval: function(retryCount) {
+ *     return 50 * Math.pow(2, retryCount);
+ *   }
+ * }, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ *   errorFilter: function(err) {
+ *     return err.message === 'Temporary error'; // only retry on a specific error
+ *   }
+ * }, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // to retry individual methods that are not as reliable within other
+ * // control flow functions, use the `retryable` wrapper:
+ * async.auto({
+ *     users: api.getUsers.bind(api),
+ *     payments: async.retryable(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ *     // do something with the results
+ * });
+ *
+ */
+export default function retry(opts, task, callback) {
+    var DEFAULT_TIMES = 5;
+    var DEFAULT_INTERVAL = 0;
+
+    var options = {
+        times: DEFAULT_TIMES,
+        intervalFunc: constant(DEFAULT_INTERVAL)
+    };
+
+    function parseTimes(acc, t) {
+        if (typeof t === 'object') {
+            acc.times = +t.times || DEFAULT_TIMES;
+
+            acc.intervalFunc = typeof t.interval === 'function' ?
+                t.interval :
+                constant(+t.interval || DEFAULT_INTERVAL);
+
+            acc.errorFilter = t.errorFilter;
+        } else if (typeof t === 'number' || typeof t === 'string') {
+            acc.times = +t || DEFAULT_TIMES;
+        } else {
+            throw new Error("Invalid arguments for async.retry");
+        }
+    }
+
+    if (arguments.length < 3 && typeof opts === 'function') {
+        callback = task || noop;
+        task = opts;
+    } else {
+        parseTimes(options, opts);
+        callback = callback || noop;
+    }
+
+    if (typeof task !== 'function') {
+        throw new Error("Invalid arguments for async.retry");
+    }
+
+    var _task = wrapAsync(task);
+
+    var attempt = 1;
+    function retryAttempt() {
+        _task(function(err) {
+            if (err && attempt++ < options.times &&
+                (typeof options.errorFilter != 'function' ||
+                    options.errorFilter(err))) {
+                setTimeout(retryAttempt, options.intervalFunc(attempt));
+            } else {
+                callback.apply(null, arguments);
+            }
+        });
+    }
+
+    retryAttempt();
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/retryable.js.html b/docs/v2/retryable.js.html new file mode 100644 index 000000000..5bb92150e --- /dev/null +++ b/docs/v2/retryable.js.html @@ -0,0 +1,156 @@ + + + + + + + retryable.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

retryable.js

+ + + + + + + +
+
+
import retry from './retry';
+import initialParams from './internal/initialParams';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}.  This method
+ * wraps a task and makes it retryable, rather than immediately calling it
+ * with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {AsyncFunction} task - the asynchronous function to wrap.
+ * This function will be passed any arguments passed to the returned wrapper.
+ * Invoked with (...args, callback).
+ * @returns {AsyncFunction} The wrapped function, which when invoked, will
+ * retry on an error, based on the parameters specified in `opts`.
+ * This function will accept the same parameters as `task`.
+ * @example
+ *
+ * async.auto({
+ *     dep1: async.retryable(3, getFromFlakyService),
+ *     process: ["dep1", async.retryable(3, function (results, cb) {
+ *         maybeProcessData(results.dep1, cb);
+ *     })]
+ * }, callback);
+ */
+export default function (opts, task) {
+    if (!task) {
+        task = opts;
+        opts = null;
+    }
+    var _task = wrapAsync(task);
+    return initialParams(function (args, callback) {
+        function taskFn(cb) {
+            _task.apply(null, args.concat(cb));
+        }
+
+        if (opts) retry(opts, taskFn, callback);
+        else retry(taskFn, callback);
+
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/scripts/async.js b/docs/v2/scripts/async.js new file mode 100644 index 000000000..5edaf431d --- /dev/null +++ b/docs/v2/scripts/async.js @@ -0,0 +1,5609 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.async = global.async || {}))); +}(this, (function (exports) { 'use strict'; + +function slice(arrayLike, start) { + start = start|0; + var newLen = Math.max(arrayLike.length - start, 0); + var newArr = Array(newLen); + for(var idx = 0; idx < newLen; idx++) { + newArr[idx] = arrayLike[start + idx]; + } + return newArr; +} + +/** + * Creates a continuation function with some arguments already applied. + * + * Useful as a shorthand when combined with other control flow functions. Any + * arguments passed to the returned function are added to the arguments + * originally passed to apply. + * + * @name apply + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {Function} fn - The function you want to eventually apply all + * arguments to. Invokes with (arguments...). + * @param {...*} arguments... - Any number of arguments to automatically apply + * when the continuation is called. + * @returns {Function} the partially-applied function + * @example + * + * // using apply + * async.parallel([ + * async.apply(fs.writeFile, 'testfile1', 'test1'), + * async.apply(fs.writeFile, 'testfile2', 'test2') + * ]); + * + * + * // the same process without using apply + * async.parallel([ + * function(callback) { + * fs.writeFile('testfile1', 'test1', callback); + * }, + * function(callback) { + * fs.writeFile('testfile2', 'test2', callback); + * } + * ]); + * + * // It's possible to pass any number of additional arguments when calling the + * // continuation: + * + * node> var fn = async.apply(sys.puts, 'one'); + * node> fn('two', 'three'); + * one + * two + * three + */ +var apply = function(fn/*, ...args*/) { + var args = slice(arguments, 1); + return function(/*callArgs*/) { + var callArgs = slice(arguments); + return fn.apply(null, args.concat(callArgs)); + }; +}; + +var initialParams = function (fn) { + return function (/*...args, callback*/) { + var args = slice(arguments); + var callback = args.pop(); + fn.call(this, args, callback); + }; +}; + +/** + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false + */ +function isObject(value) { + var type = typeof value; + return value != null && (type == 'object' || type == 'function'); +} + +var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; +var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; + +function fallback(fn) { + setTimeout(fn, 0); +} + +function wrap(defer) { + return function (fn/*, ...args*/) { + var args = slice(arguments, 1); + defer(function () { + fn.apply(null, args); + }); + }; +} + +var _defer; + +if (hasSetImmediate) { + _defer = setImmediate; +} else if (hasNextTick) { + _defer = process.nextTick; +} else { + _defer = fallback; +} + +var setImmediate$1 = wrap(_defer); + +/** + * Take a sync function and make it async, passing its return value to a + * callback. This is useful for plugging sync functions into a waterfall, + * series, or other async functions. Any arguments passed to the generated + * function will be passed to the wrapped function (except for the final + * callback argument). Errors thrown will be passed to the callback. + * + * If the function passed to `asyncify` returns a Promise, that promises's + * resolved/rejected state will be used to call the callback, rather than simply + * the synchronous return value. + * + * This also means you can asyncify ES2017 `async` functions. + * + * @name asyncify + * @static + * @memberOf module:Utils + * @method + * @alias wrapSync + * @category Util + * @param {Function} func - The synchronous function, or Promise-returning + * function to convert to an {@link AsyncFunction}. + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be + * invoked with `(args..., callback)`. + * @example + * + * // passing a regular synchronous function + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(JSON.parse), + * function (data, next) { + * // data is the result of parsing the text. + * // If there was a parsing error, it would have been caught. + * } + * ], callback); + * + * // passing a function returning a promise + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(function (contents) { + * return db.model.create(contents); + * }), + * function (model, next) { + * // `model` is the instantiated model object. + * // If there was an error, this function would be skipped. + * } + * ], callback); + * + * // es2017 example, though `asyncify` is not needed if your JS environment + * // supports async functions out of the box + * var q = async.queue(async.asyncify(async function(file) { + * var intermediateStep = await processFile(file); + * return await somePromise(intermediateStep) + * })); + * + * q.push(files); + */ +function asyncify(func) { + return initialParams(function (args, callback) { + var result; + try { + result = func.apply(this, args); + } catch (e) { + return callback(e); + } + // if result is Promise object + if (isObject(result) && typeof result.then === 'function') { + result.then(function(value) { + invokeCallback(callback, null, value); + }, function(err) { + invokeCallback(callback, err.message ? err : new Error(err)); + }); + } else { + callback(null, result); + } + }); +} + +function invokeCallback(callback, error, value) { + try { + callback(error, value); + } catch (e) { + setImmediate$1(rethrow, e); + } +} + +function rethrow(error) { + throw error; +} + +var supportsSymbol = typeof Symbol === 'function'; + +function isAsync(fn) { + return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction'; +} + +function wrapAsync(asyncFn) { + return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; +} + +function applyEach$1(eachfn) { + return function(fns/*, ...args*/) { + var args = slice(arguments, 1); + var go = initialParams(function(args, callback) { + var that = this; + return eachfn(fns, function (fn, cb) { + wrapAsync(fn).apply(that, args.concat(cb)); + }, callback); + }); + if (args.length) { + return go.apply(this, args); + } + else { + return go; + } + }; +} + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** Built-in value references. */ +var Symbol$1 = root.Symbol; + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString = objectProto.toString; + +/** Built-in value references. */ +var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the raw `toStringTag`. + */ +function getRawTag(value) { + var isOwn = hasOwnProperty.call(value, symToStringTag$1), + tag = value[symToStringTag$1]; + + try { + value[symToStringTag$1] = undefined; + var unmasked = true; + } catch (e) {} + + var result = nativeObjectToString.call(value); + if (unmasked) { + if (isOwn) { + value[symToStringTag$1] = tag; + } else { + delete value[symToStringTag$1]; + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$1 = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var nativeObjectToString$1 = objectProto$1.toString; + +/** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ +function objectToString(value) { + return nativeObjectToString$1.call(value); +} + +/** `Object#toString` result references. */ +var nullTag = '[object Null]'; +var undefinedTag = '[object Undefined]'; + +/** Built-in value references. */ +var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined; + +/** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + if (value == null) { + return value === undefined ? undefinedTag : nullTag; + } + return (symToStringTag && symToStringTag in Object(value)) + ? getRawTag(value) + : objectToString(value); +} + +/** `Object#toString` result references. */ +var asyncTag = '[object AsyncFunction]'; +var funcTag = '[object Function]'; +var genTag = '[object GeneratorFunction]'; +var proxyTag = '[object Proxy]'; + +/** + * Checks if `value` is classified as a `Function` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false + */ +function isFunction(value) { + if (!isObject(value)) { + return false; + } + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; +} + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER = 9007199254740991; + +/** + * Checks if `value` is a valid array-like length. + * + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false + */ +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +} + +/** + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false + */ +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); +} + +// A temporary value used to identify if the loop should be broken. +// See #1064, #1293 +var breakLoop = {}; + +/** + * This method returns `undefined`. + * + * @static + * @memberOf _ + * @since 2.3.0 + * @category Util + * @example + * + * _.times(2, _.noop); + * // => [undefined, undefined] + */ +function noop() { + // No operation performed. +} + +function once(fn) { + return function () { + if (fn === null) return; + var callFn = fn; + fn = null; + callFn.apply(this, arguments); + }; +} + +var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; + +var getIterator = function (coll) { + return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); +}; + +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); + + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return value != null && typeof value == 'object'; +} + +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]'; + +/** + * The base implementation of `_.isArguments`. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + */ +function baseIsArguments(value) { + return isObjectLike(value) && baseGetTag(value) == argsTag; +} + +/** Used for built-in method references. */ +var objectProto$3 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$2 = objectProto$3.hasOwnProperty; + +/** Built-in value references. */ +var propertyIsEnumerable = objectProto$3.propertyIsEnumerable; + +/** + * Checks if `value` is likely an `arguments` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false + */ +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { + return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); +}; + +/** + * Checks if `value` is classified as an `Array` object. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false + */ +var isArray = Array.isArray; + +/** + * This method returns `false`. + * + * @static + * @memberOf _ + * @since 4.13.0 + * @category Util + * @returns {boolean} Returns `false`. + * @example + * + * _.times(2, _.stubFalse); + * // => [false, false] + */ +function stubFalse() { + return false; +} + +/** Detect free variable `exports`. */ +var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; + +/** Built-in value references. */ +var Buffer = moduleExports ? root.Buffer : undefined; + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; + +/** + * Checks if `value` is a buffer. + * + * @static + * @memberOf _ + * @since 4.3.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. + * @example + * + * _.isBuffer(new Buffer(2)); + * // => true + * + * _.isBuffer(new Uint8Array(2)); + * // => false + */ +var isBuffer = nativeIsBuffer || stubFalse; + +/** Used as references for various `Number` constants. */ +var MAX_SAFE_INTEGER$1 = 9007199254740991; + +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; + +/** + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. + */ +function isIndex(value, length) { + var type = typeof value; + length = length == null ? MAX_SAFE_INTEGER$1 : length; + + return !!length && + (type == 'number' || + (type != 'symbol' && reIsUint.test(value))) && + (value > -1 && value % 1 == 0 && value < length); +} + +/** `Object#toString` result references. */ +var argsTag$1 = '[object Arguments]'; +var arrayTag = '[object Array]'; +var boolTag = '[object Boolean]'; +var dateTag = '[object Date]'; +var errorTag = '[object Error]'; +var funcTag$1 = '[object Function]'; +var mapTag = '[object Map]'; +var numberTag = '[object Number]'; +var objectTag = '[object Object]'; +var regexpTag = '[object RegExp]'; +var setTag = '[object Set]'; +var stringTag = '[object String]'; +var weakMapTag = '[object WeakMap]'; + +var arrayBufferTag = '[object ArrayBuffer]'; +var dataViewTag = '[object DataView]'; +var float32Tag = '[object Float32Array]'; +var float64Tag = '[object Float64Array]'; +var int8Tag = '[object Int8Array]'; +var int16Tag = '[object Int16Array]'; +var int32Tag = '[object Int32Array]'; +var uint8Tag = '[object Uint8Array]'; +var uint8ClampedTag = '[object Uint8ClampedArray]'; +var uint16Tag = '[object Uint16Array]'; +var uint32Tag = '[object Uint32Array]'; + +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag$1] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; + +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; +} + +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} + +/** Detect free variable `exports`. */ +var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports; + +/** Detect free variable `module`. */ +var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module; + +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1; + +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports$1 && freeGlobal.process; + +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + // Use `util.types` for Node.js 10+. + var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types; + + if (types) { + return types; + } + + // Legacy `process.binding('util')` for Node.js < 10. + return freeProcess && freeProcess.binding && freeProcess.binding('util'); + } catch (e) {} +}()); + +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; + +/** + * Checks if `value` is classified as a typed array. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false + */ +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; + +/** Used for built-in method references. */ +var objectProto$2 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$1 = objectProto$2.hasOwnProperty; + +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + var isArr = isArray(value), + isArg = !isArr && isArguments(value), + isBuff = !isArr && !isArg && isBuffer(value), + isType = !isArr && !isArg && !isBuff && isTypedArray(value), + skipIndexes = isArr || isArg || isBuff || isType, + result = skipIndexes ? baseTimes(value.length, String) : [], + length = result.length; + + for (var key in value) { + if ((inherited || hasOwnProperty$1.call(value, key)) && + !(skipIndexes && ( + // Safari 9 has enumerable `arguments.length` in strict mode. + key == 'length' || + // Node.js 0.10 has enumerable non-index properties on buffers. + (isBuff && (key == 'offset' || key == 'parent')) || + // PhantomJS 2 has enumerable non-index properties on typed arrays. + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || + // Skip index properties. + isIndex(key, length) + ))) { + result.push(key); + } + } + return result; +} + +/** Used for built-in method references. */ +var objectProto$5 = Object.prototype; + +/** + * Checks if `value` is likely a prototype object. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. + */ +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5; + + return value === proto; +} + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); + +/** Used for built-in method references. */ +var objectProto$4 = Object.prototype; + +/** Used to check objects for own properties. */ +var hasOwnProperty$3 = objectProto$4.hasOwnProperty; + +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty$3.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; +} + +/** + * Creates an array of the own enumerable property names of `object`. + * + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] + */ +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +} + +function createArrayIterator(coll) { + var i = -1; + var len = coll.length; + return function next() { + return ++i < len ? {value: coll[i], key: i} : null; + } +} + +function createES2015Iterator(iterator) { + var i = -1; + return function next() { + var item = iterator.next(); + if (item.done) + return null; + i++; + return {value: item.value, key: i}; + } +} + +function createObjectIterator(obj) { + var okeys = keys(obj); + var i = -1; + var len = okeys.length; + return function next() { + var key = okeys[++i]; + return i < len ? {value: obj[key], key: key} : null; + }; +} + +function iterator(coll) { + if (isArrayLike(coll)) { + return createArrayIterator(coll); + } + + var iterator = getIterator(coll); + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); +} + +function onlyOnce(fn) { + return function() { + if (fn === null) throw new Error("Callback was already called."); + var callFn = fn; + fn = null; + callFn.apply(this, arguments); + }; +} + +function _eachOfLimit(limit) { + return function (obj, iteratee, callback) { + callback = once(callback || noop); + if (limit <= 0 || !obj) { + return callback(null); + } + var nextElem = iterator(obj); + var done = false; + var running = 0; + var looping = false; + + function iterateeCallback(err, value) { + running -= 1; + if (err) { + done = true; + callback(err); + } + else if (value === breakLoop || (done && running <= 0)) { + done = true; + return callback(null); + } + else if (!looping) { + replenish(); + } + } + + function replenish () { + looping = true; + while (running < limit && !done) { + var elem = nextElem(); + if (elem === null) { + done = true; + if (running <= 0) { + callback(null); + } + return; + } + running += 1; + iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); + } + looping = false; + } + + replenish(); + }; +} + +/** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a + * time. + * + * @name eachOfLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. The `key` is the item's key, or index in the case of an + * array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +function eachOfLimit(coll, limit, iteratee, callback) { + _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback); +} + +function doLimit(fn, limit) { + return function (iterable, iteratee, callback) { + return fn(iterable, limit, iteratee, callback); + }; +} + +// eachOf implementation optimized for array-likes +function eachOfArrayLike(coll, iteratee, callback) { + callback = once(callback || noop); + var index = 0, + completed = 0, + length = coll.length; + if (length === 0) { + callback(null); + } + + function iteratorCallback(err, value) { + if (err) { + callback(err); + } else if ((++completed === length) || value === breakLoop) { + callback(null); + } + } + + for (; index < length; index++) { + iteratee(coll[index], index, onlyOnce(iteratorCallback)); + } +} + +// a generic version of eachOf which can handle array, object, and iterator cases. +var eachOfGeneric = doLimit(eachOfLimit, Infinity); + +/** + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument + * to the iteratee. + * + * @name eachOf + * @static + * @memberOf module:Collections + * @method + * @alias forEachOf + * @category Collection + * @see [async.each]{@link module:Collections.each} + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each + * item in `coll`. + * The `key` is the item's key, or index in the case of an array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @example + * + * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; + * var configs = {}; + * + * async.forEachOf(obj, function (value, key, callback) { + * fs.readFile(__dirname + value, "utf8", function (err, data) { + * if (err) return callback(err); + * try { + * configs[key] = JSON.parse(data); + * } catch (e) { + * return callback(e); + * } + * callback(); + * }); + * }, function (err) { + * if (err) console.error(err.message); + * // configs is now a map of JSON data + * doSomethingWith(configs); + * }); + */ +var eachOf = function(coll, iteratee, callback) { + var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; + eachOfImplementation(coll, wrapAsync(iteratee), callback); +}; + +function doParallel(fn) { + return function (obj, iteratee, callback) { + return fn(eachOf, obj, wrapAsync(iteratee), callback); + }; +} + +function _asyncMap(eachfn, arr, iteratee, callback) { + callback = callback || noop; + arr = arr || []; + var results = []; + var counter = 0; + var _iteratee = wrapAsync(iteratee); + + eachfn(arr, function (value, _, callback) { + var index = counter++; + _iteratee(value, function (err, v) { + results[index] = v; + callback(err); + }); + }, function (err) { + callback(err, results); + }); +} + +/** + * Produces a new collection of values by mapping each value in `coll` through + * the `iteratee` function. The `iteratee` is called with an item from `coll` + * and a callback for when it has finished processing. Each of these callback + * takes 2 arguments: an `error`, and the transformed item from `coll`. If + * `iteratee` passes an error to its callback, the main `callback` (for the + * `map` function) is immediately called with the error. + * + * Note, that since this function applies the `iteratee` to each item in + * parallel, there is no guarantee that the `iteratee` functions will complete + * in order. However, the results array will be in the same order as the + * original `coll`. + * + * If `map` is passed an Object, the results will be an Array. The results + * will roughly be in the order of the original Objects' keys (but this can + * vary across JavaScript engines). + * + * @name map + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an Array of the + * transformed items from the `coll`. Invoked with (err, results). + * @example + * + * async.map(['file1','file2','file3'], fs.stat, function(err, results) { + * // results is now an array of stats for each file + * }); + */ +var map = doParallel(_asyncMap); + +/** + * Applies the provided arguments to each function in the array, calling + * `callback` after all functions have completed. If you only provide the first + * argument, `fns`, then it will return a function which lets you pass in the + * arguments as if it were a single function call. If more arguments are + * provided, `callback` is required while `args` is still optional. + * + * @name applyEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s + * to all call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {Function} - If only the first argument, `fns`, is provided, it will + * return a function which lets you pass in the arguments as if it were a single + * function call. The signature is `(..args, callback)`. If invoked with any + * arguments, `callback` is required. + * @example + * + * async.applyEach([enableSearch, updateSchema], 'bucket', callback); + * + * // partial application example: + * async.each( + * buckets, + * async.applyEach([enableSearch, updateSchema]), + * callback + * ); + */ +var applyEach = applyEach$1(map); + +function doParallelLimit(fn) { + return function (obj, limit, iteratee, callback) { + return fn(_eachOfLimit(limit), obj, wrapAsync(iteratee), callback); + }; +} + +/** + * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. + * + * @name mapLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + */ +var mapLimit = doParallelLimit(_asyncMap); + +/** + * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. + * + * @name mapSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + */ +var mapSeries = doLimit(mapLimit, 1); + +/** + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. + * + * @name applyEachSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.applyEach]{@link module:ControlFlow.applyEach} + * @category Control Flow + * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all + * call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {Function} - If only the first argument is provided, it will return + * a function which lets you pass in the arguments as if it were a single + * function call. + */ +var applyEachSeries = applyEach$1(mapSeries); + +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length; + + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} + +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; + + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } + } + return object; + }; +} + +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); + +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); +} + +/** + * The base implementation of `_.findIndex` and `_.findLastIndex` without + * support for iteratee shorthands. + * + * @private + * @param {Array} array The array to inspect. + * @param {Function} predicate The function invoked per iteration. + * @param {number} fromIndex The index to search from. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseFindIndex(array, predicate, fromIndex, fromRight) { + var length = array.length, + index = fromIndex + (fromRight ? 1 : -1); + + while ((fromRight ? index-- : ++index < length)) { + if (predicate(array[index], index, array)) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.isNaN` without support for number objects. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. + */ +function baseIsNaN(value) { + return value !== value; +} + +/** + * A specialized version of `_.indexOf` which performs strict equality + * comparisons of values, i.e. `===`. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function strictIndexOf(array, value, fromIndex) { + var index = fromIndex - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; +} + +/** + * The base implementation of `_.indexOf` without `fromIndex` bounds checks. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} value The value to search for. + * @param {number} fromIndex The index to search from. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function baseIndexOf(array, value, fromIndex) { + return value === value + ? strictIndexOf(array, value, fromIndex) + : baseFindIndex(array, baseIsNaN, fromIndex); +} + +/** + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on + * their requirements. Each function can optionally depend on other functions + * being completed first, and each function is run as soon as its requirements + * are satisfied. + * + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence + * will stop. Further tasks will not execute (so any other functions depending + * on it will not run), and the main `callback` is immediately called with the + * error. + * + * {@link AsyncFunction}s also receive an object containing the results of functions which + * have completed so far as the first argument, if they have dependencies. If a + * task function has no dependencies, it will only be passed a callback. + * + * @name auto + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Object} tasks - An object. Each of its properties is either a + * function or an array of requirements, with the {@link AsyncFunction} itself the last item + * in the array. The object's key of a property serves as the name of the task + * defined by that property, i.e. can be used when specifying requirements for + * other tasks. The function receives one or two arguments: + * * a `results` object, containing the results of the previously executed + * functions, only passed if the task has any dependencies, + * * a `callback(err, result)` function, which must be called when finished, + * passing an `error` (which can be `null`) and the result of the function's + * execution. + * @param {number} [concurrency=Infinity] - An optional `integer` for + * determining the maximum number of tasks that can be run in parallel. By + * default, as many as possible. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback. Results are always returned; however, if an + * error occurs, no further `tasks` will be performed, and the results object + * will only contain partial results. Invoked with (err, results). + * @returns undefined + * @example + * + * async.auto({ + * // this function will just be passed a callback + * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'), + * showData: ['readData', function(results, cb) { + * // results.readData is the file's contents + * // ... + * }] + * }, callback); + * + * async.auto({ + * get_data: function(callback) { + * console.log('in get_data'); + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * console.log('in make_folder'); + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * console.log('in write_file', JSON.stringify(results)); + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * console.log('in email_link', JSON.stringify(results)); + * // once the file is written let's email a link to it... + * // results.write_file contains the filename returned by write_file. + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }, function(err, results) { + * console.log('err = ', err); + * console.log('results = ', results); + * }); + */ +var auto = function (tasks, concurrency, callback) { + if (typeof concurrency === 'function') { + // concurrency is optional, shift the args. + callback = concurrency; + concurrency = null; + } + callback = once(callback || noop); + var keys$$1 = keys(tasks); + var numTasks = keys$$1.length; + if (!numTasks) { + return callback(null); + } + if (!concurrency) { + concurrency = numTasks; + } + + var results = {}; + var runningTasks = 0; + var hasError = false; + + var listeners = Object.create(null); + + var readyTasks = []; + + // for cycle detection: + var readyToCheck = []; // tasks that have been identified as reachable + // without the possibility of returning to an ancestor task + var uncheckedDependencies = {}; + + baseForOwn(tasks, function (task, key) { + if (!isArray(task)) { + // no dependencies + enqueueTask(key, [task]); + readyToCheck.push(key); + return; + } + + var dependencies = task.slice(0, task.length - 1); + var remainingDependencies = dependencies.length; + if (remainingDependencies === 0) { + enqueueTask(key, task); + readyToCheck.push(key); + return; + } + uncheckedDependencies[key] = remainingDependencies; + + arrayEach(dependencies, function (dependencyName) { + if (!tasks[dependencyName]) { + throw new Error('async.auto task `' + key + + '` has a non-existent dependency `' + + dependencyName + '` in ' + + dependencies.join(', ')); + } + addListener(dependencyName, function () { + remainingDependencies--; + if (remainingDependencies === 0) { + enqueueTask(key, task); + } + }); + }); + }); + + checkForDeadlocks(); + processQueue(); + + function enqueueTask(key, task) { + readyTasks.push(function () { + runTask(key, task); + }); + } + + function processQueue() { + if (readyTasks.length === 0 && runningTasks === 0) { + return callback(null, results); + } + while(readyTasks.length && runningTasks < concurrency) { + var run = readyTasks.shift(); + run(); + } + + } + + function addListener(taskName, fn) { + var taskListeners = listeners[taskName]; + if (!taskListeners) { + taskListeners = listeners[taskName] = []; + } + + taskListeners.push(fn); + } + + function taskComplete(taskName) { + var taskListeners = listeners[taskName] || []; + arrayEach(taskListeners, function (fn) { + fn(); + }); + processQueue(); + } + + + function runTask(key, task) { + if (hasError) return; + + var taskCallback = onlyOnce(function(err, result) { + runningTasks--; + if (arguments.length > 2) { + result = slice(arguments, 1); + } + if (err) { + var safeResults = {}; + baseForOwn(results, function(val, rkey) { + safeResults[rkey] = val; + }); + safeResults[key] = result; + hasError = true; + listeners = Object.create(null); + + callback(err, safeResults); + } else { + results[key] = result; + taskComplete(key); + } + }); + + runningTasks++; + var taskFn = wrapAsync(task[task.length - 1]); + if (task.length > 1) { + taskFn(results, taskCallback); + } else { + taskFn(taskCallback); + } + } + + function checkForDeadlocks() { + // Kahn's algorithm + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html + var currentTask; + var counter = 0; + while (readyToCheck.length) { + currentTask = readyToCheck.pop(); + counter++; + arrayEach(getDependents(currentTask), function (dependent) { + if (--uncheckedDependencies[dependent] === 0) { + readyToCheck.push(dependent); + } + }); + } + + if (counter !== numTasks) { + throw new Error( + 'async.auto cannot execute tasks due to a recursive dependency' + ); + } + } + + function getDependents(taskName) { + var result = []; + baseForOwn(tasks, function (task, key) { + if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) { + result.push(key); + } + }); + return result; + } +}; + +/** + * A specialized version of `_.map` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the new mapped array. + */ +function arrayMap(array, iteratee) { + var index = -1, + length = array == null ? 0 : array.length, + result = Array(length); + + while (++index < length) { + result[index] = iteratee(array[index], index, array); + } + return result; +} + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && baseGetTag(value) == symbolTag); +} + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined; +var symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isArray(value)) { + // Recursively convert values (susceptible to call stack limits). + return arrayMap(value, baseToString) + ''; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +/** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; +} + +/** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ +function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); +} + +/** + * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the last unmatched string symbol. + */ +function charsEndIndex(strSymbols, chrSymbols) { + var index = strSymbols.length; + + while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; +} + +/** + * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol + * that is not found in the character symbols. + * + * @private + * @param {Array} strSymbols The string symbols to inspect. + * @param {Array} chrSymbols The character symbols to find. + * @returns {number} Returns the index of the first unmatched string symbol. + */ +function charsStartIndex(strSymbols, chrSymbols) { + var index = -1, + length = strSymbols.length; + + while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} + return index; +} + +/** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function asciiToArray(string) { + return string.split(''); +} + +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff'; +var rsComboMarksRange = '\\u0300-\\u036f'; +var reComboHalfMarksRange = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange = '\\u20d0-\\u20ff'; +var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange; +var rsVarRange = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsZWJ = '\\u200d'; + +/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ +var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + +/** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ +function hasUnicode(string) { + return reHasUnicode.test(string); +} + +/** Used to compose unicode character classes. */ +var rsAstralRange$1 = '\\ud800-\\udfff'; +var rsComboMarksRange$1 = '\\u0300-\\u036f'; +var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f'; +var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff'; +var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; +var rsVarRange$1 = '\\ufe0e\\ufe0f'; + +/** Used to compose unicode capture groups. */ +var rsAstral = '[' + rsAstralRange$1 + ']'; +var rsCombo = '[' + rsComboRange$1 + ']'; +var rsFitz = '\\ud83c[\\udffb-\\udfff]'; +var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')'; +var rsNonAstral = '[^' + rsAstralRange$1 + ']'; +var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}'; +var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]'; +var rsZWJ$1 = '\\u200d'; + +/** Used to compose unicode regexes. */ +var reOptMod = rsModifier + '?'; +var rsOptVar = '[' + rsVarRange$1 + ']?'; +var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*'; +var rsSeq = rsOptVar + reOptMod + rsOptJoin; +var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + +/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ +var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + +/** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function unicodeToArray(string) { + return string.match(reUnicode) || []; +} + +/** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); +} + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +/** Used to match leading and trailing whitespace. */ +var reTrim = /^\s+|\s+$/g; + +/** + * Removes leading and trailing whitespace or specified characters from `string`. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to trim. + * @param {string} [chars=whitespace] The characters to trim. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {string} Returns the trimmed string. + * @example + * + * _.trim(' abc '); + * // => 'abc' + * + * _.trim('-_-abc-_-', '_-'); + * // => 'abc' + * + * _.map([' foo ', ' bar '], _.trim); + * // => ['foo', 'bar'] + */ +function trim(string, chars, guard) { + string = toString(string); + if (string && (guard || chars === undefined)) { + return string.replace(reTrim, ''); + } + if (!string || !(chars = baseToString(chars))) { + return string; + } + var strSymbols = stringToArray(string), + chrSymbols = stringToArray(chars), + start = charsStartIndex(strSymbols, chrSymbols), + end = charsEndIndex(strSymbols, chrSymbols) + 1; + + return castSlice(strSymbols, start, end).join(''); +} + +var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m; +var FN_ARG_SPLIT = /,/; +var FN_ARG = /(=.+)?(\s*)$/; +var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; + +function parseParams(func) { + func = func.toString().replace(STRIP_COMMENTS, ''); + func = func.match(FN_ARGS)[2].replace(' ', ''); + func = func ? func.split(FN_ARG_SPLIT) : []; + func = func.map(function (arg){ + return trim(arg.replace(FN_ARG, '')); + }); + return func; +} + +/** + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent + * tasks are specified as parameters to the function, after the usual callback + * parameter, with the parameter names matching the names of the tasks it + * depends on. This can provide even more readable task graphs which can be + * easier to maintain. + * + * If a final callback is specified, the task results are similarly injected, + * specified as named parameters after the initial error parameter. + * + * The autoInject function is purely syntactic sugar and its semantics are + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}. + * + * @name autoInject + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.auto]{@link module:ControlFlow.auto} + * @category Control Flow + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of + * the form 'func([dependencies...], callback). The object's key of a property + * serves as the name of the task defined by that property, i.e. can be used + * when specifying requirements for other tasks. + * * The `callback` parameter is a `callback(err, result)` which must be called + * when finished, passing an `error` (which can be `null`) and the result of + * the function's execution. The remaining parameters name other tasks on + * which the task is dependent, and the results from those tasks are the + * arguments of those parameters. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback, and a `results` object with any completed + * task results, similar to `auto`. + * @example + * + * // The example from `auto` can be rewritten as follows: + * async.autoInject({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: function(get_data, make_folder, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }, + * email_link: function(write_file, callback) { + * // once the file is written let's email a link to it... + * // write_file contains the filename returned by write_file. + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * } + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + * + * // If you are using a JS minifier that mangles parameter names, `autoInject` + * // will not work with plain functions, since the parameter names will be + * // collapsed to a single letter identifier. To work around this, you can + * // explicitly specify the names of the parameters your task function needs + * // in an array, similar to Angular.js dependency injection. + * + * // This still has an advantage over plain `auto`, since the results a task + * // depends on are still spread into arguments. + * async.autoInject({ + * //... + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(write_file, callback) { + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * }] + * //... + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + */ +function autoInject(tasks, callback) { + var newTasks = {}; + + baseForOwn(tasks, function (taskFn, key) { + var params; + var fnIsAsync = isAsync(taskFn); + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); + + if (isArray(taskFn)) { + params = taskFn.slice(0, -1); + taskFn = taskFn[taskFn.length - 1]; + + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); + } else if (hasNoDeps) { + // no dependencies, use the function as-is + newTasks[key] = taskFn; + } else { + params = parseParams(taskFn); + if (taskFn.length === 0 && !fnIsAsync && params.length === 0) { + throw new Error("autoInject task functions require explicit parameters."); + } + + // remove callback param + if (!fnIsAsync) params.pop(); + + newTasks[key] = params.concat(newTask); + } + + function newTask(results, taskCb) { + var newArgs = arrayMap(params, function (name) { + return results[name]; + }); + newArgs.push(taskCb); + wrapAsync(taskFn).apply(null, newArgs); + } + }); + + auto(newTasks, callback); +} + +// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation +// used for queues. This implementation assumes that the node provided by the user can be modified +// to adjust the next and last properties. We implement only the minimal functionality +// for queue support. +function DLL() { + this.head = this.tail = null; + this.length = 0; +} + +function setInitial(dll, node) { + dll.length = 1; + dll.head = dll.tail = node; +} + +DLL.prototype.removeLink = function(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next; + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; + + node.prev = node.next = null; + this.length -= 1; + return node; +}; + +DLL.prototype.empty = function () { + while(this.head) this.shift(); + return this; +}; + +DLL.prototype.insertAfter = function(node, newNode) { + newNode.prev = node; + newNode.next = node.next; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; + node.next = newNode; + this.length += 1; +}; + +DLL.prototype.insertBefore = function(node, newNode) { + newNode.prev = node.prev; + newNode.next = node; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; + node.prev = newNode; + this.length += 1; +}; + +DLL.prototype.unshift = function(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); +}; + +DLL.prototype.push = function(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); +}; + +DLL.prototype.shift = function() { + return this.head && this.removeLink(this.head); +}; + +DLL.prototype.pop = function() { + return this.tail && this.removeLink(this.tail); +}; + +DLL.prototype.toArray = function () { + var arr = Array(this.length); + var curr = this.head; + for(var idx = 0; idx < this.length; idx++) { + arr[idx] = curr.data; + curr = curr.next; + } + return arr; +}; + +DLL.prototype.remove = function (testFn) { + var curr = this.head; + while(!!curr) { + var next = curr.next; + if (testFn(curr)) { + this.removeLink(curr); + } + curr = next; + } + return this; +}; + +function queue(worker, concurrency, payload) { + if (concurrency == null) { + concurrency = 1; + } + else if(concurrency === 0) { + throw new Error('Concurrency must not be zero'); + } + + var _worker = wrapAsync(worker); + var numRunning = 0; + var workersList = []; + + var processingScheduled = false; + function _insert(data, insertAtFront, callback) { + if (callback != null && typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + if (!isArray(data)) { + data = [data]; + } + if (data.length === 0 && q.idle()) { + // call drain immediately if there are no tasks + return setImmediate$1(function() { + q.drain(); + }); + } + + for (var i = 0, l = data.length; i < l; i++) { + var item = { + data: data[i], + callback: callback || noop + }; + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); + } + } + + if (!processingScheduled) { + processingScheduled = true; + setImmediate$1(function() { + processingScheduled = false; + q.process(); + }); + } + } + + function _next(tasks) { + return function(err){ + numRunning -= 1; + + for (var i = 0, l = tasks.length; i < l; i++) { + var task = tasks[i]; + + var index = baseIndexOf(workersList, task, 0); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); + } + + task.callback.apply(task, arguments); + + if (err != null) { + q.error(err, task.data); + } + } + + if (numRunning <= (q.concurrency - q.buffer) ) { + q.unsaturated(); + } + + if (q.idle()) { + q.drain(); + } + q.process(); + }; + } + + var isProcessing = false; + var q = { + _tasks: new DLL(), + concurrency: concurrency, + payload: payload, + saturated: noop, + unsaturated:noop, + buffer: concurrency / 4, + empty: noop, + drain: noop, + error: noop, + started: false, + paused: false, + push: function (data, callback) { + _insert(data, false, callback); + }, + kill: function () { + q.drain = noop; + q._tasks.empty(); + }, + unshift: function (data, callback) { + _insert(data, true, callback); + }, + remove: function (testFn) { + q._tasks.remove(testFn); + }, + process: function () { + // Avoid trying to start too many processing operations. This can occur + // when callbacks resolve synchronously (#1267). + if (isProcessing) { + return; + } + isProcessing = true; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ + var tasks = [], data = []; + var l = q._tasks.length; + if (q.payload) l = Math.min(l, q.payload); + for (var i = 0; i < l; i++) { + var node = q._tasks.shift(); + tasks.push(node); + workersList.push(node); + data.push(node.data); + } + + numRunning += 1; + + if (q._tasks.length === 0) { + q.empty(); + } + + if (numRunning === q.concurrency) { + q.saturated(); + } + + var cb = onlyOnce(_next(tasks)); + _worker(data, cb); + } + isProcessing = false; + }, + length: function () { + return q._tasks.length; + }, + running: function () { + return numRunning; + }, + workersList: function () { + return workersList; + }, + idle: function() { + return q._tasks.length + numRunning === 0; + }, + pause: function () { + q.paused = true; + }, + resume: function () { + if (q.paused === false) { return; } + q.paused = false; + setImmediate$1(q.process); + } + }; + return q; +} + +/** + * A cargo of tasks for the worker function to complete. Cargo inherits all of + * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. + * @typedef {Object} CargoObject + * @memberOf module:ControlFlow + * @property {Function} length - A function returning the number of items + * waiting to be processed. Invoke like `cargo.length()`. + * @property {number} payload - An `integer` for determining how many tasks + * should be process per round. This property can be changed after a `cargo` is + * created to alter the payload on-the-fly. + * @property {Function} push - Adds `task` to the `queue`. The callback is + * called once the `worker` has finished processing the task. Instead of a + * single task, an array of `tasks` can be submitted. The respective callback is + * used for every task in the list. Invoke like `cargo.push(task, [callback])`. + * @property {Function} saturated - A callback that is called when the + * `queue.length()` hits the concurrency and further tasks will be queued. + * @property {Function} empty - A callback that is called when the last item + * from the `queue` is given to a `worker`. + * @property {Function} drain - A callback that is called when the last item + * from the `queue` has returned from the `worker`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke like `cargo.idle()`. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke like `cargo.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke like `cargo.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. + */ + +/** + * Creates a `cargo` object with the specified payload. Tasks added to the + * cargo will be processed altogether (up to the `payload` limit). If the + * `worker` is in progress, the task is queued until it becomes available. Once + * the `worker` has completed some tasks, each callback of those tasks is + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) + * for how `cargo` and `queue` work. + * + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers + * at a time, cargo passes an array of tasks to a single worker, repeating + * when the worker is finished. + * + * @name cargo + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. + * @param {number} [payload=Infinity] - An optional `integer` for determining + * how many tasks should be processed per round; if omitted, the default is + * unlimited. + * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the cargo and inner queue. + * @example + * + * // create a cargo object with payload 2 + * var cargo = async.cargo(function(tasks, callback) { + * for (var i=0; i true + */ +function identity(value) { + return value; +} + +function _createTester(check, getResult) { + return function(eachfn, arr, iteratee, cb) { + cb = cb || noop; + var testPassed = false; + var testResult; + eachfn(arr, function(value, _, callback) { + iteratee(value, function(err, result) { + if (err) { + callback(err); + } else if (check(result) && !testResult) { + testPassed = true; + testResult = getResult(true, value); + callback(null, breakLoop); + } else { + callback(); + } + }); + }, function(err) { + if (err) { + cb(err); + } else { + cb(null, testPassed ? testResult : getResult(false)); + } + }); + }; +} + +function _findGetResult(v, x) { + return x; +} + +/** + * Returns the first value in `coll` that passes an async truth test. The + * `iteratee` is applied in parallel, meaning the first iteratee to return + * `true` will fire the detect `callback` with that result. That means the + * result might not be the first item in the original `coll` (in terms of order) + * that passes the test. + + * If order within the original `coll` is important, then look at + * [`detectSeries`]{@link module:Collections.detectSeries}. + * + * @name detect + * @static + * @memberOf module:Collections + * @method + * @alias find + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @example + * + * async.detect(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // result now equals the first file in the list that exists + * }); + */ +var detect = doParallel(_createTester(identity, _findGetResult)); + +/** + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a + * time. + * + * @name detectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findLimit + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + */ +var detectLimit = doParallelLimit(_createTester(identity, _findGetResult)); + +/** + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. + * + * @name detectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findSeries + * @category Collections + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + */ +var detectSeries = doLimit(detectLimit, 1); + +function consoleFunc(name) { + return function (fn/*, ...args*/) { + var args = slice(arguments, 1); + args.push(function (err/*, ...args*/) { + var args = slice(arguments, 1); + if (typeof console === 'object') { + if (err) { + if (console.error) { + console.error(err); + } + } else if (console[name]) { + arrayEach(args, function (x) { + console[name](x); + }); + } + } + }); + wrapAsync(fn).apply(null, args); + }; +} + +/** + * Logs the result of an [`async` function]{@link AsyncFunction} to the + * `console` using `console.dir` to display the properties of the resulting object. + * Only works in Node.js or in browsers that support `console.dir` and + * `console.error` (such as FF and Chrome). + * If multiple arguments are returned from the async function, + * `console.dir` is called on each argument in order. + * + * @name dir + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, {hello: name}); + * }, 1000); + * }; + * + * // in the node repl + * node> async.dir(hello, 'world'); + * {hello: 'world'} + */ +var dir = consoleFunc('dir'); + +/** + * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in + * the order of operations, the arguments `test` and `fn` are switched. + * + * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function. + * @name doDuring + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.during]{@link module:ControlFlow.during} + * @category Control Flow + * @param {AsyncFunction} fn - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `fn`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `fn`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `fn` has stopped. `callback` + * will be passed an error if one occurred, otherwise `null`. + */ +function doDuring(fn, test, callback) { + callback = onlyOnce(callback || noop); + var _fn = wrapAsync(fn); + var _test = wrapAsync(test); + + function next(err/*, ...args*/) { + if (err) return callback(err); + var args = slice(arguments, 1); + args.push(check); + _test.apply(this, args); + } + + function check(err, truth) { + if (err) return callback(err); + if (!truth) return callback(null); + _fn(next); + } + + check(null, true); + +} + +/** + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in + * the order of operations, the arguments `test` and `iteratee` are switched. + * + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + * + * @name doWhilst + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - A function which is called each time `test` + * passes. Invoked with (callback). + * @param {Function} test - synchronous truth test to perform after each + * execution of `iteratee`. Invoked with any non-error callback results of + * `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. + * `callback` will be passed an error and any arguments passed to the final + * `iteratee`'s callback. Invoked with (err, [results]); + */ +function doWhilst(iteratee, test, callback) { + callback = onlyOnce(callback || noop); + var _iteratee = wrapAsync(iteratee); + var next = function(err/*, ...args*/) { + if (err) return callback(err); + var args = slice(arguments, 1); + if (test.apply(this, args)) return _iteratee(next); + callback.apply(null, [null].concat(args)); + }; + _iteratee(next); +} + +/** + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the + * argument ordering differs from `until`. + * + * @name doUntil + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} test - synchronous truth test to perform after each + * execution of `iteratee`. Invoked with any non-error callback results of + * `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + */ +function doUntil(iteratee, test, callback) { + doWhilst(iteratee, function() { + return !test.apply(this, arguments); + }, callback); +} + +/** + * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that + * is passed a callback in the form of `function (err, truth)`. If error is + * passed to `test` or `fn`, the main callback is immediately called with the + * value of the error. + * + * @name during + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `fn`. Invoked with (callback). + * @param {AsyncFunction} fn - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `fn` has stopped. `callback` + * will be passed an error, if one occurred, otherwise `null`. + * @example + * + * var count = 0; + * + * async.during( + * function (callback) { + * return callback(null, count < 5); + * }, + * function (callback) { + * count++; + * setTimeout(callback, 1000); + * }, + * function (err) { + * // 5 seconds have passed + * } + * ); + */ +function during(test, fn, callback) { + callback = onlyOnce(callback || noop); + var _fn = wrapAsync(fn); + var _test = wrapAsync(test); + + function next(err) { + if (err) return callback(err); + _test(check); + } + + function check(err, truth) { + if (err) return callback(err); + if (!truth) return callback(null); + _fn(next); + } + + _test(check); +} + +function _withoutIndex(iteratee) { + return function (value, index, callback) { + return iteratee(value, callback); + }; +} + +/** + * Applies the function `iteratee` to each item in `coll`, in parallel. + * The `iteratee` is called with an item from the list, and a callback for when + * it has finished. If the `iteratee` passes an error to its `callback`, the + * main `callback` (for the `each` function) is immediately called with the + * error. + * + * Note, that since this function applies `iteratee` to each item in parallel, + * there is no guarantee that the iteratee functions will complete in order. + * + * @name each + * @static + * @memberOf module:Collections + * @method + * @alias forEach + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to + * each item in `coll`. Invoked with (item, callback). + * The array index is not passed to the iteratee. + * If you need the index, use `eachOf`. + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @example + * + * // assuming openFiles is an array of file names and saveFile is a function + * // to save the modified contents of that file: + * + * async.each(openFiles, saveFile, function(err){ + * // if any of the saves produced an error, err would equal that error + * }); + * + * // assuming openFiles is an array of file names + * async.each(openFiles, function(file, callback) { + * + * // Perform operation on file here. + * console.log('Processing file ' + file); + * + * if( file.length > 32 ) { + * console.log('This file name is too long'); + * callback('File name too long'); + * } else { + * // Do work to process file here + * console.log('File processed'); + * callback(); + * } + * }, function(err) { + * // if any of the file processing produced an error, err would equal that error + * if( err ) { + * // One of the iterations produced an error. + * // All processing will now stop. + * console.log('A file failed to process'); + * } else { + * console.log('All files have been processed successfully'); + * } + * }); + */ +function eachLimit(coll, iteratee, callback) { + eachOf(coll, _withoutIndex(wrapAsync(iteratee)), callback); +} + +/** + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. + * + * @name eachLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfLimit`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +function eachLimit$1(coll, limit, iteratee, callback) { + _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback); +} + +/** + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. + * + * @name eachSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfSeries`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + */ +var eachSeries = doLimit(eachLimit$1, 1); + +/** + * Wrap an async function and ensure it calls its callback on a later tick of + * the event loop. If the function already calls its callback on a next tick, + * no extra deferral is added. This is useful for preventing stack overflows + * (`RangeError: Maximum call stack size exceeded`) and generally keeping + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) + * contained. ES2017 `async` functions are returned as-is -- they are immune + * to Zalgo's corrupting influences, as they always resolve on a later tick. + * + * @name ensureAsync + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - an async function, one that expects a node-style + * callback as its last argument. + * @returns {AsyncFunction} Returns a wrapped function with the exact same call + * signature as the function passed in. + * @example + * + * function sometimesAsync(arg, callback) { + * if (cache[arg]) { + * return callback(null, cache[arg]); // this would be synchronous!! + * } else { + * doSomeIO(arg, callback); // this IO would be asynchronous + * } + * } + * + * // this has a risk of stack overflows if many results are cached in a row + * async.mapSeries(args, sometimesAsync, done); + * + * // this will defer sometimesAsync's callback if necessary, + * // preventing stack overflows + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); + */ +function ensureAsync(fn) { + if (isAsync(fn)) return fn; + return initialParams(function (args, callback) { + var sync = true; + args.push(function () { + var innerArgs = arguments; + if (sync) { + setImmediate$1(function () { + callback.apply(null, innerArgs); + }); + } else { + callback.apply(null, innerArgs); + } + }); + fn.apply(this, args); + sync = false; + }); +} + +function notId(v) { + return !v; +} + +/** + * Returns `true` if every element in `coll` satisfies an async test. If any + * iteratee call returns `false`, the main `callback` is immediately called. + * + * @name every + * @static + * @memberOf module:Collections + * @method + * @alias all + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @example + * + * async.every(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // if result is true then every file exists + * }); + */ +var every = doParallel(_createTester(notId, notId)); + +/** + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. + * + * @name everyLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + */ +var everyLimit = doParallelLimit(_createTester(notId, notId)); + +/** + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. + * + * @name everySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in series. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + */ +var everySeries = doLimit(everyLimit, 1); + +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} + +function filterArray(eachfn, arr, iteratee, callback) { + var truthValues = new Array(arr.length); + eachfn(arr, function (x, index, callback) { + iteratee(x, function (err, v) { + truthValues[index] = !!v; + callback(err); + }); + }, function (err) { + if (err) return callback(err); + var results = []; + for (var i = 0; i < arr.length; i++) { + if (truthValues[i]) results.push(arr[i]); + } + callback(null, results); + }); +} + +function filterGeneric(eachfn, coll, iteratee, callback) { + var results = []; + eachfn(coll, function (x, index, callback) { + iteratee(x, function (err, v) { + if (err) { + callback(err); + } else { + if (v) { + results.push({index: index, value: x}); + } + callback(); + } + }); + }, function (err) { + if (err) { + callback(err); + } else { + callback(null, arrayMap(results.sort(function (a, b) { + return a.index - b.index; + }), baseProperty('value'))); + } + }); +} + +function _filter(eachfn, coll, iteratee, callback) { + var filter = isArrayLike(coll) ? filterArray : filterGeneric; + filter(eachfn, coll, wrapAsync(iteratee), callback || noop); +} + +/** + * Returns a new array of all the values in `coll` which pass an async truth + * test. This operation is performed in parallel, but the results array will be + * in the same order as the original. + * + * @name filter + * @static + * @memberOf module:Collections + * @method + * @alias select + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @example + * + * async.filter(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, results) { + * // results now equals an array of the existing files + * }); + */ +var filter = doParallel(_filter); + +/** + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a + * time. + * + * @name filterLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var filterLimit = doParallelLimit(_filter); + +/** + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. + * + * @name filterSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectSeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results) + */ +var filterSeries = doLimit(filterLimit, 1); + +/** + * Calls the asynchronous function `fn` with a callback parameter that allows it + * to call itself again, in series, indefinitely. + + * If an error is passed to the callback then `errback` is called with the + * error, and execution stops, otherwise it will never be called. + * + * @name forever + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} fn - an async function to call repeatedly. + * Invoked with (next). + * @param {Function} [errback] - when `fn` passes an error to it's callback, + * this function will be called, and execution stops. Invoked with (err). + * @example + * + * async.forever( + * function(next) { + * // next is suitable for passing to things that need a callback(err [, whatever]); + * // it will result in this function being called again. + * }, + * function(err) { + * // if next is called with a value in its first parameter, it will appear + * // in here as 'err', and execution will stop. + * } + * ); + */ +function forever(fn, errback) { + var done = onlyOnce(errback || noop); + var task = wrapAsync(ensureAsync(fn)); + + function next(err) { + if (err) return done(err); + task(next); + } + next(); +} + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. + * + * @name groupByLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + */ +var groupByLimit = function(coll, limit, iteratee, callback) { + callback = callback || noop; + var _iteratee = wrapAsync(iteratee); + mapLimit(coll, limit, function(val, callback) { + _iteratee(val, function(err, key) { + if (err) return callback(err); + return callback(null, {key: key, val: val}); + }); + }, function(err, mapResults) { + var result = {}; + // from MDN, handle object having an `hasOwnProperty` prop + var hasOwnProperty = Object.prototype.hasOwnProperty; + + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + var key = mapResults[i].key; + var val = mapResults[i].val; + + if (hasOwnProperty.call(result, key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } + } + + return callback(err, result); + }); +}; + +/** + * Returns a new object, where each value corresponds to an array of items, from + * `coll`, that returned the corresponding key. That is, the keys of the object + * correspond to the values passed to the `iteratee` callback. + * + * Note: Since this function applies the `iteratee` to each item in parallel, + * there is no guarantee that the `iteratee` functions will complete in order. + * However, the values for each key in the `result` will be in the same order as + * the original `coll`. For Objects, the values will roughly be in the order of + * the original Objects' keys (but this can vary across JavaScript engines). + * + * @name groupBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + * @example + * + * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) { + * db.findById(userId, function(err, user) { + * if (err) return callback(err); + * return callback(null, user.age); + * }); + * }, function(err, result) { + * // result is object containing the userIds grouped by age + * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']}; + * }); + */ +var groupBy = doLimit(groupByLimit, Infinity); + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. + * + * @name groupBySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + */ +var groupBySeries = doLimit(groupByLimit, 1); + +/** + * Logs the result of an `async` function to the `console`. Only works in + * Node.js or in browsers that support `console.log` and `console.error` (such + * as FF and Chrome). If multiple arguments are returned from the async + * function, `console.log` is called on each argument in order. + * + * @name log + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, 'hello ' + name); + * }, 1000); + * }; + * + * // in the node repl + * node> async.log(hello, 'world'); + * 'hello world' + */ +var log = consoleFunc('log'); + +/** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a + * time. + * + * @name mapValuesLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + */ +function mapValuesLimit(obj, limit, iteratee, callback) { + callback = once(callback || noop); + var newObj = {}; + var _iteratee = wrapAsync(iteratee); + eachOfLimit(obj, limit, function(val, key, next) { + _iteratee(val, key, function (err, result) { + if (err) return next(err); + newObj[key] = result; + next(); + }); + }, function (err) { + callback(err, newObj); + }); +} + +/** + * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. + * + * Produces a new Object by mapping each value of `obj` through the `iteratee` + * function. The `iteratee` is called each `value` and `key` from `obj` and a + * callback for when it has finished processing. Each of these callbacks takes + * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` + * passes an error to its callback, the main `callback` (for the `mapValues` + * function) is immediately called with the error. + * + * Note, the order of the keys in the result is not guaranteed. The keys will + * be roughly in the order they complete, (but this is very engine-specific) + * + * @name mapValues + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @example + * + * async.mapValues({ + * f1: 'file1', + * f2: 'file2', + * f3: 'file3' + * }, function (file, key, callback) { + * fs.stat(file, callback); + * }, function(err, result) { + * // result is now a map of stats for each file, e.g. + * // { + * // f1: [stats for file1], + * // f2: [stats for file2], + * // f3: [stats for file3] + * // } + * }); + */ + +var mapValues = doLimit(mapValuesLimit, Infinity); + +/** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. + * + * @name mapValuesSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + */ +var mapValuesSeries = doLimit(mapValuesLimit, 1); + +function has(obj, key) { + return key in obj; +} + +/** + * Caches the results of an async function. When creating a hash to store + * function results against, the callback is omitted from the hash and an + * optional hash function can be used. + * + * If no hash function is specified, the first argument is used as a hash key, + * which may work reasonably if it is a string or a data type that converts to a + * distinct string. Note that objects and arrays will not behave reasonably. + * Neither will cases where the other arguments are significant. In such cases, + * specify your own hash function. + * + * The cache of results is exposed as the `memo` property of the function + * returned by `memoize`. + * + * @name memoize + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function to proxy and cache results from. + * @param {Function} hasher - An optional function for generating a custom hash + * for storing results. It has all the arguments applied to it apart from the + * callback, and must be synchronous. + * @returns {AsyncFunction} a memoized version of `fn` + * @example + * + * var slow_fn = function(name, callback) { + * // do something + * callback(null, result); + * }; + * var fn = async.memoize(slow_fn); + * + * // fn can now be used as if it were slow_fn + * fn('some name', function() { + * // callback + * }); + */ +function memoize(fn, hasher) { + var memo = Object.create(null); + var queues = Object.create(null); + hasher = hasher || identity; + var _fn = wrapAsync(fn); + var memoized = initialParams(function memoized(args, callback) { + var key = hasher.apply(null, args); + if (has(memo, key)) { + setImmediate$1(function() { + callback.apply(null, memo[key]); + }); + } else if (has(queues, key)) { + queues[key].push(callback); + } else { + queues[key] = [callback]; + _fn.apply(null, args.concat(function(/*args*/) { + var args = slice(arguments); + memo[key] = args; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, args); + } + })); + } + }); + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; +} + +/** + * Calls `callback` on a later loop around the event loop. In Node.js this just + * calls `process.nextTick`. In the browser it will use `setImmediate` if + * available, otherwise `setTimeout(callback, 0)`, which means other higher + * priority events may precede the execution of `callback`. + * + * This is used internally for browser-compatibility purposes. + * + * @name nextTick + * @static + * @memberOf module:Utils + * @method + * @see [async.setImmediate]{@link module:Utils.setImmediate} + * @category Util + * @param {Function} callback - The function to call on a later loop around + * the event loop. Invoked with (args...). + * @param {...*} args... - any number of additional arguments to pass to the + * callback on the next tick. + * @example + * + * var call_order = []; + * async.nextTick(function() { + * call_order.push('two'); + * // call_order now equals ['one','two'] + * }); + * call_order.push('one'); + * + * async.setImmediate(function (a, b, c) { + * // a, b, and c equal 1, 2, and 3 + * }, 1, 2, 3); + */ +var _defer$1; + +if (hasNextTick) { + _defer$1 = process.nextTick; +} else if (hasSetImmediate) { + _defer$1 = setImmediate; +} else { + _defer$1 = fallback; +} + +var nextTick = wrap(_defer$1); + +function _parallel(eachfn, tasks, callback) { + callback = callback || noop; + var results = isArrayLike(tasks) ? [] : {}; + + eachfn(tasks, function (task, key, callback) { + wrapAsync(task)(function (err, result) { + if (arguments.length > 2) { + result = slice(arguments, 1); + } + results[key] = result; + callback(err); + }); + }, function (err) { + callback(err, results); + }); +} + +/** + * Run the `tasks` collection of functions in parallel, without waiting until + * the previous function has completed. If any of the functions pass an error to + * its callback, the main `callback` is immediately called with the value of the + * error. Once the `tasks` have completed, the results are passed to the final + * `callback` as an array. + * + * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about + * parallel execution of code. If your tasks do not use any timers or perform + * any I/O, they will actually be executed in series. Any synchronous setup + * sections for each task will happen one after the other. JavaScript remains + * single-threaded. + * + * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the + * execution of other tasks when a task fails. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.parallel}. + * + * @name parallel + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * + * @example + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // optional callback + * function(err, results) { + * // the results array will equal ['one','two'] even though + * // the second function had a shorter timeout. + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * // results is now equals to: {one: 1, two: 2} + * }); + */ +function parallelLimit(tasks, callback) { + _parallel(eachOf, tasks, callback); +} + +/** + * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a + * time. + * + * @name parallelLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.parallel]{@link module:ControlFlow.parallel} + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + */ +function parallelLimit$1(tasks, limit, callback) { + _parallel(_eachOfLimit(limit), tasks, callback); +} + +/** + * A queue of tasks for the worker function to complete. + * @typedef {Object} QueueObject + * @memberOf module:ControlFlow + * @property {Function} length - a function returning the number of items + * waiting to be processed. Invoke with `queue.length()`. + * @property {boolean} started - a boolean indicating whether or not any + * items have been pushed and processed by the queue. + * @property {Function} running - a function returning the number of items + * currently being processed. Invoke with `queue.running()`. + * @property {Function} workersList - a function returning the array of items + * currently being processed. Invoke with `queue.workersList()`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke with `queue.idle()`. + * @property {number} concurrency - an integer for determining how many `worker` + * functions should be run in parallel. This property can be changed after a + * `queue` is created to alter the concurrency on-the-fly. + * @property {Function} push - add a new task to the `queue`. Calls `callback` + * once the `worker` has finished processing the task. Instead of a single task, + * a `tasks` array can be submitted. The respective callback is used for every + * task in the list. Invoke with `queue.push(task, [callback])`, + * @property {Function} unshift - add a new task to the front of the `queue`. + * Invoke with `queue.unshift(task, [callback])`. + * @property {Function} remove - remove items from the queue that match a test + * function. The test function will be passed an object with a `data` property, + * and a `priority` property, if this is a + * [priorityQueue]{@link module:ControlFlow.priorityQueue} object. + * Invoked with `queue.remove(testFn)`, where `testFn` is of the form + * `function ({data, priority}) {}` and returns a Boolean. + * @property {Function} saturated - a callback that is called when the number of + * running workers hits the `concurrency` limit, and further tasks will be + * queued. + * @property {Function} unsaturated - a callback that is called when the number + * of running workers is less than the `concurrency` & `buffer` limits, and + * further tasks will not be queued. + * @property {number} buffer - A minimum threshold buffer in order to say that + * the `queue` is `unsaturated`. + * @property {Function} empty - a callback that is called when the last item + * from the `queue` is given to a `worker`. + * @property {Function} drain - a callback that is called when the last item + * from the `queue` has returned from the `worker`. + * @property {Function} error - a callback that is called when a task errors. + * Has the signature `function(error, task)`. + * @property {boolean} paused - a boolean for determining whether the queue is + * in a paused state. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke with `queue.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke with `queue.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. No more tasks + * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. + */ + +/** + * Creates a `queue` object with the specified `concurrency`. Tasks added to the + * `queue` are processed in parallel (up to the `concurrency` limit). If all + * `worker`s are in progress, the task is queued until one becomes available. + * Once a `worker` completes a `task`, that `task`'s callback is called. + * + * @name queue + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. Invoked with (task, callback). + * @param {number} [concurrency=1] - An `integer` for determining how many + * `worker` functions should be run in parallel. If omitted, the concurrency + * defaults to `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the queue. + * @example + * + * // create a queue object with concurrency 2 + * var q = async.queue(function(task, callback) { + * console.log('hello ' + task.name); + * callback(); + * }, 2); + * + * // assign a callback + * q.drain = function() { + * console.log('all items have been processed'); + * }; + * + * // add some items to the queue + * q.push({name: 'foo'}, function(err) { + * console.log('finished processing foo'); + * }); + * q.push({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + * + * // add some items to the queue (batch-wise) + * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { + * console.log('finished processing item'); + * }); + * + * // add some items to the front of the queue + * q.unshift({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + */ +var queue$1 = function (worker, concurrency) { + var _worker = wrapAsync(worker); + return queue(function (items, cb) { + _worker(items[0], cb); + }, concurrency, 1); +}; + +/** + * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and + * completed in ascending priority order. + * + * @name priorityQueue + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. + * Invoked with (task, callback). + * @param {number} concurrency - An `integer` for determining how many `worker` + * functions should be run in parallel. If omitted, the concurrency defaults to + * `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two + * differences between `queue` and `priorityQueue` objects: + * * `push(task, priority, [callback])` - `priority` should be a number. If an + * array of `tasks` is given, all tasks will be assigned the same priority. + * * The `unshift` method was removed. + */ +var priorityQueue = function(worker, concurrency) { + // Start with a normal queue + var q = queue$1(worker, concurrency); + + // Override push to accept second parameter representing priority + q.push = function(data, priority, callback) { + if (callback == null) callback = noop; + if (typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + if (!isArray(data)) { + data = [data]; + } + if (data.length === 0) { + // call drain immediately if there are no tasks + return setImmediate$1(function() { + q.drain(); + }); + } + + priority = priority || 0; + var nextNode = q._tasks.head; + while (nextNode && priority >= nextNode.priority) { + nextNode = nextNode.next; + } + + for (var i = 0, l = data.length; i < l; i++) { + var item = { + data: data[i], + priority: priority, + callback: callback + }; + + if (nextNode) { + q._tasks.insertBefore(nextNode, item); + } else { + q._tasks.push(item); + } + } + setImmediate$1(q.process); + }; + + // Remove unshift function + delete q.unshift; + + return q; +}; + +/** + * Runs the `tasks` array of functions in parallel, without waiting until the + * previous function has completed. Once any of the `tasks` complete or pass an + * error to its callback, the main `callback` is immediately called. It's + * equivalent to `Promise.race()`. + * + * @name race + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction} + * to run. Each function can complete with an optional `result` value. + * @param {Function} callback - A callback to run once any of the functions have + * completed. This function gets an error or result from the first function that + * completed. Invoked with (err, result). + * @returns undefined + * @example + * + * async.race([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // main callback + * function(err, result) { + * // the result will be equal to 'two' as it finishes earlier + * }); + */ +function race(tasks, callback) { + callback = once(callback || noop); + if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); + if (!tasks.length) return callback(); + for (var i = 0, l = tasks.length; i < l; i++) { + wrapAsync(tasks[i])(callback); + } +} + +/** + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. + * + * @name reduceRight + * @static + * @memberOf module:Collections + * @method + * @see [async.reduce]{@link module:Collections.reduce} + * @alias foldr + * @category Collection + * @param {Array} array - A collection to iterate over. + * @param {*} memo - The initial state of the reduction. + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee complete with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the reduced value. Invoked with + * (err, result). + */ +function reduceRight (array, memo, iteratee, callback) { + var reversed = slice(array).reverse(); + reduce(reversed, memo, iteratee, callback); +} + +/** + * Wraps the async function in another function that always completes with a + * result object, even when it errors. + * + * The result object has either the property `error` or `value`. + * + * @name reflect + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function you want to wrap + * @returns {Function} - A function that always passes null to it's callback as + * the error. The second argument to the callback will be an `object` with + * either an `error` or a `value` property. + * @example + * + * async.parallel([ + * async.reflect(function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }), + * async.reflect(function(callback) { + * // do some more stuff but error ... + * callback('bad stuff happened'); + * }), + * async.reflect(function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * }) + * ], + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = 'bad stuff happened' + * // results[2].value = 'two' + * }); + */ +function reflect(fn) { + var _fn = wrapAsync(fn); + return initialParams(function reflectOn(args, reflectCallback) { + args.push(function callback(error, cbArg) { + if (error) { + reflectCallback(null, { error: error }); + } else { + var value; + if (arguments.length <= 2) { + value = cbArg; + } else { + value = slice(arguments, 1); + } + reflectCallback(null, { value: value }); + } + }); + + return _fn.apply(this, args); + }); +} + +/** + * A helper function that wraps an array or an object of functions with `reflect`. + * + * @name reflectAll + * @static + * @memberOf module:Utils + * @method + * @see [async.reflect]{@link module:Utils.reflect} + * @category Util + * @param {Array|Object|Iterable} tasks - The collection of + * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. + * @returns {Array} Returns an array of async functions, each wrapped in + * `async.reflect` + * @example + * + * let tasks = [ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * // do some more stuff but error ... + * callback(new Error('bad stuff happened')); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = Error('bad stuff happened') + * // results[2].value = 'two' + * }); + * + * // an example using an object instead of an array + * let tasks = { + * one: function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * two: function(callback) { + * callback('two'); + * }, + * three: function(callback) { + * setTimeout(function() { + * callback(null, 'three'); + * }, 100); + * } + * }; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results.one.value = 'one' + * // results.two.error = 'two' + * // results.three.value = 'three' + * }); + */ +function reflectAll(tasks) { + var results; + if (isArray(tasks)) { + results = arrayMap(tasks, reflect); + } else { + results = {}; + baseForOwn(tasks, function(task, key) { + results[key] = reflect.call(this, task); + }); + } + return results; +} + +function reject$1(eachfn, arr, iteratee, callback) { + _filter(eachfn, arr, function(value, cb) { + iteratee(value, function(err, v) { + cb(err, !v); + }); + }, callback); +} + +/** + * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. + * + * @name reject + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @example + * + * async.reject(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, results) { + * // results now equals an array of missing files + * createFiles(results); + * }); + */ +var reject = doParallel(reject$1); + +/** + * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a + * time. + * + * @name rejectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var rejectLimit = doParallelLimit(reject$1); + +/** + * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. + * + * @name rejectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + */ +var rejectSeries = doLimit(rejectLimit, 1); + +/** + * Creates a function that returns `value`. + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {*} value The value to return from the new function. + * @returns {Function} Returns the new constant function. + * @example + * + * var objects = _.times(2, _.constant({ 'a': 1 })); + * + * console.log(objects); + * // => [{ 'a': 1 }, { 'a': 1 }] + * + * console.log(objects[0] === objects[1]); + * // => true + */ +function constant$1(value) { + return function() { + return value; + }; +} + +/** + * Attempts to get a successful response from `task` no more than `times` times + * before returning an error. If the task is successful, the `callback` will be + * passed the result of the successful task. If all attempts fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name retry + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @see [async.retryable]{@link module:ControlFlow.retryable} + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an + * object with `times` and `interval` or a number. + * * `times` - The number of attempts to make before giving up. The default + * is `5`. + * * `interval` - The time to wait between retries, in milliseconds. The + * default is `0`. The interval may also be specified as a function of the + * retry count (see example). + * * `errorFilter` - An optional synchronous function that is invoked on + * erroneous result. If it returns `true` the retry attempts will continue; + * if the function returns `false` the retry flow is aborted with the current + * attempt's error and result being returned to the final callback. + * Invoked with (err). + * * If `opts` is a number, the number specifies the number of times to retry, + * with the default interval of `0`. + * @param {AsyncFunction} task - An async function to retry. + * Invoked with (callback). + * @param {Function} [callback] - An optional callback which is called when the + * task has succeeded, or after the final failed attempt. It receives the `err` + * and `result` arguments of the last attempt at completing the `task`. Invoked + * with (err, results). + * + * @example + * + * // The `retry` function can be used as a stand-alone control flow by passing + * // a callback, as shown below: + * + * // try calling apiMethod 3 times + * async.retry(3, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 3 times, waiting 200 ms between each retry + * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 10 times with exponential backoff + * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) + * async.retry({ + * times: 10, + * interval: function(retryCount) { + * return 50 * Math.pow(2, retryCount); + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod the default 5 times no delay between each retry + * async.retry(apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod only when error condition satisfies, all other + * // errors will abort the retry control flow and return to final callback + * async.retry({ + * errorFilter: function(err) { + * return err.message === 'Temporary error'; // only retry on a specific error + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // to retry individual methods that are not as reliable within other + * // control flow functions, use the `retryable` wrapper: + * async.auto({ + * users: api.getUsers.bind(api), + * payments: async.retryable(3, api.getPayments.bind(api)) + * }, function(err, results) { + * // do something with the results + * }); + * + */ +function retry(opts, task, callback) { + var DEFAULT_TIMES = 5; + var DEFAULT_INTERVAL = 0; + + var options = { + times: DEFAULT_TIMES, + intervalFunc: constant$1(DEFAULT_INTERVAL) + }; + + function parseTimes(acc, t) { + if (typeof t === 'object') { + acc.times = +t.times || DEFAULT_TIMES; + + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant$1(+t.interval || DEFAULT_INTERVAL); + + acc.errorFilter = t.errorFilter; + } else if (typeof t === 'number' || typeof t === 'string') { + acc.times = +t || DEFAULT_TIMES; + } else { + throw new Error("Invalid arguments for async.retry"); + } + } + + if (arguments.length < 3 && typeof opts === 'function') { + callback = task || noop; + task = opts; + } else { + parseTimes(options, opts); + callback = callback || noop; + } + + if (typeof task !== 'function') { + throw new Error("Invalid arguments for async.retry"); + } + + var _task = wrapAsync(task); + + var attempt = 1; + function retryAttempt() { + _task(function(err) { + if (err && attempt++ < options.times && + (typeof options.errorFilter != 'function' || + options.errorFilter(err))) { + setTimeout(retryAttempt, options.intervalFunc(attempt)); + } else { + callback.apply(null, arguments); + } + }); + } + + retryAttempt(); +} + +/** + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method + * wraps a task and makes it retryable, rather than immediately calling it + * with retries. + * + * @name retryable + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.retry]{@link module:ControlFlow.retry} + * @category Control Flow + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional + * options, exactly the same as from `retry` + * @param {AsyncFunction} task - the asynchronous function to wrap. + * This function will be passed any arguments passed to the returned wrapper. + * Invoked with (...args, callback). + * @returns {AsyncFunction} The wrapped function, which when invoked, will + * retry on an error, based on the parameters specified in `opts`. + * This function will accept the same parameters as `task`. + * @example + * + * async.auto({ + * dep1: async.retryable(3, getFromFlakyService), + * process: ["dep1", async.retryable(3, function (results, cb) { + * maybeProcessData(results.dep1, cb); + * })] + * }, callback); + */ +var retryable = function (opts, task) { + if (!task) { + task = opts; + opts = null; + } + var _task = wrapAsync(task); + return initialParams(function (args, callback) { + function taskFn(cb) { + _task.apply(null, args.concat(cb)); + } + + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + + }); +}; + +/** + * Run the functions in the `tasks` collection in series, each one running once + * the previous function has completed. If any functions in the series pass an + * error to its callback, no more functions are run, and `callback` is + * immediately called with the value of the error. Otherwise, `callback` + * receives an array of results when `tasks` have completed. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function, and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.series}. + * + * **Note** that while many implementations preserve the order of object + * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) + * explicitly states that + * + * > The mechanics and order of enumerating the properties is not specified. + * + * So if you rely on the order in which your series of functions are executed, + * and want this to work on all platforms, consider using an array. + * + * @name series + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection containing + * [async functions]{@link AsyncFunction} to run in series. + * Each function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This function gets a results array (or object) + * containing all the result arguments passed to the `task` callbacks. Invoked + * with (err, result). + * @example + * async.series([ + * function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }, + * function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * } + * ], + * // optional callback + * function(err, results) { + * // results is now equal to ['one', 'two'] + * }); + * + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback){ + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * // results is now equal to: {one: 1, two: 2} + * }); + */ +function series(tasks, callback) { + _parallel(eachOfSeries, tasks, callback); +} + +/** + * Returns `true` if at least one element in the `coll` satisfies an async test. + * If any iteratee call returns `true`, the main `callback` is immediately + * called. + * + * @name some + * @static + * @memberOf module:Collections + * @method + * @alias any + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @example + * + * async.some(['file1','file2','file3'], function(filePath, callback) { + * fs.access(filePath, function(err) { + * callback(null, !err) + * }); + * }, function(err, result) { + * // if result is true then at least one of the files exists + * }); + */ +var some = doParallel(_createTester(Boolean, identity)); + +/** + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. + * + * @name someLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anyLimit + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + */ +var someLimit = doParallelLimit(_createTester(Boolean, identity)); + +/** + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. + * + * @name someSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anySeries + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in series. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + */ +var someSeries = doLimit(someLimit, 1); + +/** + * Sorts a list by the results of running each `coll` value through an async + * `iteratee`. + * + * @name sortBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a value to use as the sort criteria as + * its `result`. + * Invoked with (item, callback). + * @param {Function} callback - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is the items + * from the original `coll` sorted by the values returned by the `iteratee` + * calls. Invoked with (err, results). + * @example + * + * async.sortBy(['file1','file2','file3'], function(file, callback) { + * fs.stat(file, function(err, stats) { + * callback(err, stats.mtime); + * }); + * }, function(err, results) { + * // results is now the original array of files sorted by + * // modified date + * }); + * + * // By modifying the callback parameter the + * // sorting order can be influenced: + * + * // ascending order + * async.sortBy([1,9,3,5], function(x, callback) { + * callback(null, x); + * }, function(err,result) { + * // result callback + * }); + * + * // descending order + * async.sortBy([1,9,3,5], function(x, callback) { + * callback(null, x*-1); //<- x*-1 instead of x, turns the order around + * }, function(err,result) { + * // result callback + * }); + */ +function sortBy (coll, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + map(coll, function (x, callback) { + _iteratee(x, function (err, criteria) { + if (err) return callback(err); + callback(null, {value: x, criteria: criteria}); + }); + }, function (err, results) { + if (err) return callback(err); + callback(null, arrayMap(results.sort(comparator), baseProperty('value'))); + }); + + function comparator(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + } +} + +/** + * Sets a time limit on an asynchronous function. If the function does not call + * its callback within the specified milliseconds, it will be called with a + * timeout error. The code property for the error object will be `'ETIMEDOUT'`. + * + * @name timeout + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} asyncFn - The async function to limit in time. + * @param {number} milliseconds - The specified time limit. + * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) + * to timeout Error for more information.. + * @returns {AsyncFunction} Returns a wrapped function that can be used with any + * of the control flow functions. + * Invoke this function with the same parameters as you would `asyncFunc`. + * @example + * + * function myFunction(foo, callback) { + * doAsyncTask(foo, function(err, data) { + * // handle errors + * if (err) return callback(err); + * + * // do some stuff ... + * + * // return processed data + * return callback(null, data); + * }); + * } + * + * var wrapped = async.timeout(myFunction, 1000); + * + * // call `wrapped` as you would `myFunction` + * wrapped({ bar: 'bar' }, function(err, data) { + * // if `myFunction` takes < 1000 ms to execute, `err` + * // and `data` will have their expected values + * + * // else `err` will be an Error with the code 'ETIMEDOUT' + * }); + */ +function timeout(asyncFn, milliseconds, info) { + var fn = wrapAsync(asyncFn); + + return initialParams(function (args, callback) { + var timedOut = false; + var timer; + + function timeoutCallback() { + var name = asyncFn.name || 'anonymous'; + var error = new Error('Callback function "' + name + '" timed out.'); + error.code = 'ETIMEDOUT'; + if (info) { + error.info = info; + } + timedOut = true; + callback(error); + } + + args.push(function () { + if (!timedOut) { + callback.apply(null, arguments); + clearTimeout(timer); + } + }); + + // setup timer and call original function + timer = setTimeout(timeoutCallback, milliseconds); + fn.apply(null, args); + }); +} + +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeCeil = Math.ceil; +var nativeMax = Math.max; + +/** + * The base implementation of `_.range` and `_.rangeRight` which doesn't + * coerce arguments. + * + * @private + * @param {number} start The start of the range. + * @param {number} end The end of the range. + * @param {number} step The value to increment or decrement by. + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Array} Returns the range of numbers. + */ +function baseRange(start, end, step, fromRight) { + var index = -1, + length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), + result = Array(length); + + while (length--) { + result[fromRight ? length : ++index] = start; + start += step; + } + return result; +} + +/** + * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a + * time. + * + * @name timesLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} count - The number of times to run the function. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see [async.map]{@link module:Collections.map}. + */ +function timeLimit(count, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + mapLimit(baseRange(0, count, 1), limit, _iteratee, callback); +} + +/** + * Calls the `iteratee` function `n` times, and accumulates results in the same + * manner you would use with [map]{@link module:Collections.map}. + * + * @name times + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.map]{@link module:Collections.map} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @example + * + * // Pretend this is some complicated async factory + * var createUser = function(id, callback) { + * callback(null, { + * id: 'user' + id + * }); + * }; + * + * // generate 5 users + * async.times(5, function(n, next) { + * createUser(n, function(err, user) { + * next(err, user); + * }); + * }, function(err, users) { + * // we should now have 5 users + * }); + */ +var times = doLimit(timeLimit, Infinity); + +/** + * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. + * + * @name timesSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + */ +var timesSeries = doLimit(timeLimit, 1); + +/** + * A relative of `reduce`. Takes an Object or Array, and iterates over each + * element in series, each step potentially mutating an `accumulator` value. + * The type of the accumulator defaults to the type of collection passed in. + * + * @name transform + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {*} [accumulator] - The initial state of the transform. If omitted, + * it will default to an empty Object or Array, depending on the type of `coll` + * @param {AsyncFunction} iteratee - A function applied to each item in the + * collection that potentially modifies the accumulator. + * Invoked with (accumulator, item, key, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the transformed accumulator. + * Invoked with (err, result). + * @example + * + * async.transform([1,2,3], function(acc, item, index, callback) { + * // pointless async: + * process.nextTick(function() { + * acc.push(item * 2) + * callback(null) + * }); + * }, function(err, result) { + * // result is now equal to [2, 4, 6] + * }); + * + * @example + * + * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { + * setImmediate(function () { + * obj[key] = val * 2; + * callback(); + * }) + * }, function (err, result) { + * // result is equal to {a: 2, b: 4, c: 6} + * }) + */ +function transform (coll, accumulator, iteratee, callback) { + if (arguments.length <= 3) { + callback = iteratee; + iteratee = accumulator; + accumulator = isArray(coll) ? [] : {}; + } + callback = once(callback || noop); + var _iteratee = wrapAsync(iteratee); + + eachOf(coll, function(v, k, cb) { + _iteratee(accumulator, v, k, cb); + }, function(err) { + callback(err, accumulator); + }); +} + +/** + * It runs each task in series but stops whenever any of the functions were + * successful. If one of the tasks were successful, the `callback` will be + * passed the result of the successful task. If all tasks fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name tryEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|Object} tasks - A collection containing functions to + * run, each function is passed a `callback(err, result)` it must call on + * completion with an error `err` (which can be `null`) and an optional `result` + * value. + * @param {Function} [callback] - An optional callback which is called when one + * of the tasks has succeeded, or all have failed. It receives the `err` and + * `result` arguments of the last attempt at completing the `task`. Invoked with + * (err, results). + * @example + * async.tryEach([ + * function getDataFromFirstWebsite(callback) { + * // Try getting the data from the first website + * callback(err, data); + * }, + * function getDataFromSecondWebsite(callback) { + * // First website failed, + * // Try getting the data from the backup website + * callback(err, data); + * } + * ], + * // optional callback + * function(err, results) { + * Now do something with the data. + * }); + * + */ +function tryEach(tasks, callback) { + var error = null; + var result; + callback = callback || noop; + eachSeries(tasks, function(task, callback) { + wrapAsync(task)(function (err, res/*, ...args*/) { + if (arguments.length > 2) { + result = slice(arguments, 1); + } else { + result = res; + } + error = err; + callback(!err); + }); + }, function () { + callback(error, result); + }); +} + +/** + * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, + * unmemoized form. Handy for testing. + * + * @name unmemoize + * @static + * @memberOf module:Utils + * @method + * @see [async.memoize]{@link module:Utils.memoize} + * @category Util + * @param {AsyncFunction} fn - the memoized function + * @returns {AsyncFunction} a function that calls the original unmemoized function + */ +function unmemoize(fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; +} + +/** + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. + * + * @name whilst + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Function} test - synchronous truth test to perform before each + * execution of `iteratee`. Invoked with (). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns undefined + * @example + * + * var count = 0; + * async.whilst( + * function() { return count < 5; }, + * function(callback) { + * count++; + * setTimeout(function() { + * callback(null, count); + * }, 1000); + * }, + * function (err, n) { + * // 5 seconds have passed, n = 5 + * } + * ); + */ +function whilst(test, iteratee, callback) { + callback = onlyOnce(callback || noop); + var _iteratee = wrapAsync(iteratee); + if (!test()) return callback(null); + var next = function(err/*, ...args*/) { + if (err) return callback(err); + if (test()) return _iteratee(next); + var args = slice(arguments, 1); + callback.apply(null, [null].concat(args)); + }; + _iteratee(next); +} + +/** + * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. `callback` will be passed an error and any + * arguments passed to the final `iteratee`'s callback. + * + * The inverse of [whilst]{@link module:ControlFlow.whilst}. + * + * @name until + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {Function} test - synchronous truth test to perform before each + * execution of `iteratee`. Invoked with (). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + */ +function until(test, iteratee, callback) { + whilst(function() { + return !test.apply(this, arguments); + }, iteratee, callback); +} + +/** + * Runs the `tasks` array of functions in series, each passing their results to + * the next in the array. However, if any of the `tasks` pass an error to their + * own callback, the next function is not executed, and the main `callback` is + * immediately called with the error. + * + * @name waterfall + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} + * to run. + * Each function should complete with any number of `result` values. + * The `result` values will be passed as arguments, in order, to the next task. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This will be passed the results of the last task's + * callback. Invoked with (err, [results]). + * @returns undefined + * @example + * + * async.waterfall([ + * function(callback) { + * callback(null, 'one', 'two'); + * }, + * function(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * }, + * function(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + * ], function (err, result) { + * // result now equals 'done' + * }); + * + * // Or, with named functions: + * async.waterfall([ + * myFirstFunction, + * mySecondFunction, + * myLastFunction, + * ], function (err, result) { + * // result now equals 'done' + * }); + * function myFirstFunction(callback) { + * callback(null, 'one', 'two'); + * } + * function mySecondFunction(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * } + * function myLastFunction(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + */ +var waterfall = function(tasks, callback) { + callback = once(callback || noop); + if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); + if (!tasks.length) return callback(); + var taskIndex = 0; + + function nextTask(args) { + var task = wrapAsync(tasks[taskIndex++]); + args.push(onlyOnce(next)); + task.apply(null, args); + } + + function next(err/*, ...args*/) { + if (err || taskIndex === tasks.length) { + return callback.apply(null, arguments); + } + nextTask(slice(arguments, 1)); + } + + nextTask([]); +}; + +/** + * 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 + */ + +var index = { + apply: apply, + applyEach: applyEach, + applyEachSeries: applyEachSeries, + asyncify: asyncify, + auto: auto, + autoInject: autoInject, + cargo: cargo, + compose: compose, + concat: concat, + concatLimit: concatLimit, + concatSeries: concatSeries, + constant: constant, + detect: detect, + detectLimit: detectLimit, + detectSeries: detectSeries, + dir: dir, + doDuring: doDuring, + doUntil: doUntil, + doWhilst: doWhilst, + during: during, + each: eachLimit, + eachLimit: eachLimit$1, + eachOf: eachOf, + eachOfLimit: eachOfLimit, + eachOfSeries: eachOfSeries, + eachSeries: eachSeries, + ensureAsync: ensureAsync, + every: every, + everyLimit: everyLimit, + everySeries: everySeries, + filter: filter, + filterLimit: filterLimit, + filterSeries: filterSeries, + forever: forever, + groupBy: groupBy, + groupByLimit: groupByLimit, + groupBySeries: groupBySeries, + log: log, + map: map, + mapLimit: mapLimit, + mapSeries: mapSeries, + mapValues: mapValues, + mapValuesLimit: mapValuesLimit, + mapValuesSeries: mapValuesSeries, + memoize: memoize, + nextTick: nextTick, + parallel: parallelLimit, + parallelLimit: parallelLimit$1, + priorityQueue: priorityQueue, + queue: queue$1, + race: race, + reduce: reduce, + reduceRight: reduceRight, + reflect: reflect, + reflectAll: reflectAll, + reject: reject, + rejectLimit: rejectLimit, + rejectSeries: rejectSeries, + retry: retry, + retryable: retryable, + seq: seq, + series: series, + setImmediate: setImmediate$1, + some: some, + someLimit: someLimit, + someSeries: someSeries, + sortBy: sortBy, + timeout: timeout, + times: times, + timesLimit: timeLimit, + timesSeries: timesSeries, + transform: transform, + tryEach: tryEach, + unmemoize: unmemoize, + until: until, + waterfall: waterfall, + whilst: whilst, + + // aliases + all: every, + allLimit: everyLimit, + allSeries: everySeries, + any: some, + anyLimit: someLimit, + anySeries: someSeries, + find: detect, + findLimit: detectLimit, + findSeries: detectSeries, + forEach: eachLimit, + forEachSeries: eachSeries, + forEachLimit: eachLimit$1, + forEachOf: eachOf, + forEachOfSeries: eachOfSeries, + forEachOfLimit: eachOfLimit, + inject: reduce, + foldl: reduce, + foldr: reduceRight, + select: filter, + selectLimit: filterLimit, + selectSeries: filterSeries, + wrapSync: asyncify +}; + +exports['default'] = index; +exports.apply = apply; +exports.applyEach = applyEach; +exports.applyEachSeries = applyEachSeries; +exports.asyncify = asyncify; +exports.auto = auto; +exports.autoInject = autoInject; +exports.cargo = cargo; +exports.compose = compose; +exports.concat = concat; +exports.concatLimit = concatLimit; +exports.concatSeries = concatSeries; +exports.constant = constant; +exports.detect = detect; +exports.detectLimit = detectLimit; +exports.detectSeries = detectSeries; +exports.dir = dir; +exports.doDuring = doDuring; +exports.doUntil = doUntil; +exports.doWhilst = doWhilst; +exports.during = during; +exports.each = eachLimit; +exports.eachLimit = eachLimit$1; +exports.eachOf = eachOf; +exports.eachOfLimit = eachOfLimit; +exports.eachOfSeries = eachOfSeries; +exports.eachSeries = eachSeries; +exports.ensureAsync = ensureAsync; +exports.every = every; +exports.everyLimit = everyLimit; +exports.everySeries = everySeries; +exports.filter = filter; +exports.filterLimit = filterLimit; +exports.filterSeries = filterSeries; +exports.forever = forever; +exports.groupBy = groupBy; +exports.groupByLimit = groupByLimit; +exports.groupBySeries = groupBySeries; +exports.log = log; +exports.map = map; +exports.mapLimit = mapLimit; +exports.mapSeries = mapSeries; +exports.mapValues = mapValues; +exports.mapValuesLimit = mapValuesLimit; +exports.mapValuesSeries = mapValuesSeries; +exports.memoize = memoize; +exports.nextTick = nextTick; +exports.parallel = parallelLimit; +exports.parallelLimit = parallelLimit$1; +exports.priorityQueue = priorityQueue; +exports.queue = queue$1; +exports.race = race; +exports.reduce = reduce; +exports.reduceRight = reduceRight; +exports.reflect = reflect; +exports.reflectAll = reflectAll; +exports.reject = reject; +exports.rejectLimit = rejectLimit; +exports.rejectSeries = rejectSeries; +exports.retry = retry; +exports.retryable = retryable; +exports.seq = seq; +exports.series = series; +exports.setImmediate = setImmediate$1; +exports.some = some; +exports.someLimit = someLimit; +exports.someSeries = someSeries; +exports.sortBy = sortBy; +exports.timeout = timeout; +exports.times = times; +exports.timesLimit = timeLimit; +exports.timesSeries = timesSeries; +exports.transform = transform; +exports.tryEach = tryEach; +exports.unmemoize = unmemoize; +exports.until = until; +exports.waterfall = waterfall; +exports.whilst = whilst; +exports.all = every; +exports.allLimit = everyLimit; +exports.allSeries = everySeries; +exports.any = some; +exports.anyLimit = someLimit; +exports.anySeries = someSeries; +exports.find = detect; +exports.findLimit = detectLimit; +exports.findSeries = detectSeries; +exports.forEach = eachLimit; +exports.forEachSeries = eachSeries; +exports.forEachLimit = eachLimit$1; +exports.forEachOf = eachOf; +exports.forEachOfSeries = eachOfSeries; +exports.forEachOfLimit = eachOfLimit; +exports.inject = reduce; +exports.foldl = reduce; +exports.foldr = reduceRight; +exports.select = filter; +exports.selectLimit = filterLimit; +exports.selectSeries = filterSeries; +exports.wrapSync = asyncify; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/docs/v2/scripts/jsdoc-custom.js b/docs/v2/scripts/jsdoc-custom.js new file mode 100644 index 000000000..b101444a8 --- /dev/null +++ b/docs/v2/scripts/jsdoc-custom.js @@ -0,0 +1,129 @@ +/* eslint no-undef: "off" */ +if (typeof setImmediate !== 'function' && typeof async === 'object') { + setImmediate = async.setImmediate; +} + +$(function initSearchBar() { + function matchSubstrs(methodName) { + var tokens = []; + var len = methodName.length; + for (var size = 1; size <= len; size++){ + for (var i = 0; i+size<= len; i++){ + tokens.push(methodName.substr(i, size)); + } + } + return tokens; + } + + var methodNames = new Bloodhound({ + datumTokenizer: matchSubstrs, + queryTokenizer: Bloodhound.tokenizers.whitespace, + prefetch: { + url: './data/methodNames.json', + cache: false + } + }); + + var sourceFiles = new Bloodhound({ + datumTokenizer: matchSubstrs, + queryTokenizer: Bloodhound.tokenizers.whitespace, + prefetch: { + url: './data/sourceFiles.json', + cache: false + } + }); + + var githubIssues = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.whitespace, + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: 'https://api.github.com/search/issues?q=%QUERY+repo:caolan/async', + cache: true, + wildcard: '%QUERY', + transform: function(response) { + return $.map(response.items, function(issue) { + // if (issue.state !== 'open') { + // return null; + // } + return { + url: issue.html_url, + name: issue.number + ': ' + issue.title, + number: issue.number + }; + }).sort(function(a, b) { + return b.number - a.number; + }); + } + } + }); + + $('.typeahead').typeahead({ + hint: true, + highlight: true, + minLength: 1 + }, { + name: 'Methods', + source: methodNames, + templates: { + header: '

Methods

' + } + }, { + name: 'Files', + source: sourceFiles, + templates: { + header: '

Source Files

' + } + }, { + name: 'Issues', + source: githubIssues, + display: 'name', + templates: { + header: '

Issues

' + } + }).on('typeahead:select', function(ev, suggestion) { + var host; + if (location.origin != "null") { + host = location.origin; + } else { + host = location.protocol + '//' + location.host; + } + + var _path = location.pathname.split("/"); + var currentPage = _path[_path.length - 1]; + host += "/" + _path.slice(1, -1).join("/") + "/"; + + // handle issues + if (typeof suggestion !== 'string') { + location.href = suggestion.url; + // handle source files + } else if (suggestion.indexOf('.html') !== -1) { + location.href = host + suggestion; + } else { + var parenIndex = suggestion.indexOf('('); + if (parenIndex !== -1) { + suggestion = suggestion.substring(0, parenIndex-1); + } + + // handle searching from one of the source files or the home page + if (currentPage !== 'docs.html') { + location.href = host + 'docs.html#' + suggestion; + } else { + var $el = document.getElementById(suggestion); + $('#main-container').animate({ scrollTop: $el.offsetTop - 60 }, 500); + location.hash = '#'+suggestion; + } + } + }); + + function fixOldHash() { + var hash = window.location.hash; + if (hash) { + var hashMatches = hash.match(/^#\.(\w+)$/); + if (hashMatches) { + window.location.hash = '#'+hashMatches[1]; + } + } + } + + fixOldHash(); +}); diff --git a/docs/v2/scripts/linenumber.js b/docs/v2/scripts/linenumber.js new file mode 100644 index 000000000..8d52f7eaf --- /dev/null +++ b/docs/v2/scripts/linenumber.js @@ -0,0 +1,25 @@ +/*global document */ +(function() { + var source = document.getElementsByClassName('prettyprint source linenums'); + var i = 0; + var lineNumber = 0; + var lineId; + var lines; + var totalLines; + var anchorHash; + + if (source && source[0]) { + anchorHash = document.location.hash.substring(1); + lines = source[0].getElementsByTagName('li'); + totalLines = lines.length; + + for (; i < totalLines; i++) { + lineNumber++; + lineId = 'line' + lineNumber; + lines[i].id = lineId; + if (lineId === anchorHash) { + lines[i].className += ' selected'; + } + } + } +})(); diff --git a/docs/v2/scripts/prettify/Apache-License-2.0.txt b/docs/v2/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/docs/v2/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/v2/scripts/prettify/lang-css.js b/docs/v2/scripts/prettify/lang-css.js new file mode 100644 index 000000000..041e1f590 --- /dev/null +++ b/docs/v2/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/v2/scripts/prettify/prettify.js b/docs/v2/scripts/prettify/prettify.js new file mode 100644 index 000000000..eef5ad7e6 --- /dev/null +++ b/docs/v2/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p + + + + + + seq.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

seq.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import slice from './internal/slice';
+import reduce from './reduce';
+import wrapAsync from './internal/wrapAsync';
+import arrayMap from 'lodash/_arrayMap';
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...AsyncFunction} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ *     var User = request.models.User;
+ *     async.seq(
+ *         _.bind(User.get, User),  // 'User.get' has signature (id, callback(err, data))
+ *         function(user, fn) {
+ *             user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+ *         }
+ *     )(req.session.user_id, function (err, cats) {
+ *         if (err) {
+ *             console.error(err);
+ *             response.json({ status: 'error', message: err.message });
+ *         } else {
+ *             response.json({ status: 'ok', message: 'Cats found', data: cats });
+ *         }
+ *     });
+ * });
+ */
+export default function seq(/*...functions*/) {
+    var _functions = arrayMap(arguments, wrapAsync);
+    return function(/*...args*/) {
+        var args = slice(arguments);
+        var that = this;
+
+        var cb = args[args.length - 1];
+        if (typeof cb == 'function') {
+            args.pop();
+        } else {
+            cb = noop;
+        }
+
+        reduce(_functions, args, function(newargs, fn, cb) {
+            fn.apply(that, newargs.concat(function(err/*, ...nextargs*/) {
+                var nextargs = slice(arguments, 1);
+                cb(err, nextargs);
+            }));
+        },
+        function(err, results) {
+            cb.apply(that, [err].concat(results));
+        });
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/series.js.html b/docs/v2/series.js.html new file mode 100644 index 000000000..c57cced50 --- /dev/null +++ b/docs/v2/series.js.html @@ -0,0 +1,178 @@ + + + + + + + series.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

series.js

+ + + + + + + +
+
+
import parallel from './internal/parallel';
+import eachOfSeries from './eachOfSeries';
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ *  results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing
+ * [async functions]{@link AsyncFunction} to run in series.
+ * Each function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ *     function(callback) {
+ *         // do some stuff ...
+ *         callback(null, 'one');
+ *     },
+ *     function(callback) {
+ *         // do some more stuff ...
+ *         callback(null, 'two');
+ *     }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback){
+ *         setTimeout(function() {
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }, function(err, results) {
+ *     // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+export default function series(tasks, callback) {
+    parallel(eachOfSeries, tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/setImmediate.js.html b/docs/v2/setImmediate.js.html new file mode 100644 index 000000000..3e0b5e034 --- /dev/null +++ b/docs/v2/setImmediate.js.html @@ -0,0 +1,142 @@ + + + + + + + setImmediate.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

setImmediate.js

+ + + + + + + +
+
+
import setImmediate from './internal/setImmediate';
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`.  In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name setImmediate
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.nextTick]{@link module:Utils.nextTick}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ *     call_order.push('two');
+ *     // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ *     // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+export default setImmediate;
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/some.js.html b/docs/v2/some.js.html new file mode 100644 index 000000000..325eafd9c --- /dev/null +++ b/docs/v2/some.js.html @@ -0,0 +1,143 @@ + + + + + + + some.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

some.js

+ + + + + + + +
+
+
import createTester from './internal/createTester';
+import doParallel from './internal/doParallel';
+import identity from 'lodash/identity';
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ *     fs.access(filePath, function(err) {
+ *         callback(null, !err)
+ *     });
+ * }, function(err, result) {
+ *     // if result is true then at least one of the files exists
+ * });
+ */
+export default doParallel(createTester(Boolean, identity));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/someLimit.js.html b/docs/v2/someLimit.js.html new file mode 100644 index 000000000..68de8d5a5 --- /dev/null +++ b/docs/v2/someLimit.js.html @@ -0,0 +1,134 @@ + + + + + + + someLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

someLimit.js

+ + + + + + + +
+
+
import createTester from './internal/createTester';
+import doParallelLimit from './internal/doParallelLimit';
+import identity from 'lodash/identity';
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+export default doParallelLimit(createTester(Boolean, identity));
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/someSeries.js.html b/docs/v2/someSeries.js.html new file mode 100644 index 000000000..7e4b176fc --- /dev/null +++ b/docs/v2/someSeries.js.html @@ -0,0 +1,132 @@ + + + + + + + someSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

someSeries.js

+ + + + + + + +
+
+
import someLimit from './someLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in series.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+export default doLimit(someLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/sortBy.js.html b/docs/v2/sortBy.js.html new file mode 100644 index 000000000..00972a6d5 --- /dev/null +++ b/docs/v2/sortBy.js.html @@ -0,0 +1,178 @@ + + + + + + + sortBy.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

sortBy.js

+ + + + + + + +
+
+
import arrayMap from 'lodash/_arrayMap';
+import property from 'lodash/_baseProperty';
+
+import map from './map';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a value to use as the sort criteria as
+ * its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ *     fs.stat(file, function(err, stats) {
+ *         callback(err, stats.mtime);
+ *     });
+ * }, function(err, results) {
+ *     // results is now the original array of files sorted by
+ *     // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ *     callback(null, x);
+ * }, function(err,result) {
+ *     // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ *     callback(null, x*-1);    //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ *     // result callback
+ * });
+ */
+export default function sortBy (coll, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    map(coll, function (x, callback) {
+        _iteratee(x, function (err, criteria) {
+            if (err) return callback(err);
+            callback(null, {value: x, criteria: criteria});
+        });
+    }, function (err, results) {
+        if (err) return callback(err);
+        callback(null, arrayMap(results.sort(comparator), property('value')));
+    });
+
+    function comparator(left, right) {
+        var a = left.criteria, b = right.criteria;
+        return a < b ? -1 : a > b ? 1 : 0;
+    }
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/styles/jsdoc-default.css b/docs/v2/styles/jsdoc-default.css new file mode 100644 index 000000000..fee48f167 --- /dev/null +++ b/docs/v2/styles/jsdoc-default.css @@ -0,0 +1,824 @@ +* { + box-sizing: border-box +} + +html, body { + height: 100%; + width: 100%; +} + +body { + color: #4d4e53; + background-color: white; + margin: 0 auto; + padding: 0; + + font-family: 'Helvetica Neue', Helvetica, sans-serif; + font-size: 16px; + line-height: 160%; +} + +a, +a:active { + color: #0095dd; + text-decoration: none; +} + +a:hover { + text-decoration: underline +} + +p, ul, ol, blockquote { + margin-bottom: 1em; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Montserrat', sans-serif; +} + +h1, h2, h3, h4, h5, h6 { + color: #565656; + font-weight: 400; + margin: 0; + padding-top: 1em; +} + +h1 { + font-weight: 300; + font-size: 48px; + margin: 1em 0 .5em; +} + +h1.page-title { + font-size: 48px; + margin: 1em 30px; +} + +h2 { + font-size: 30px; + margin: 1.5em 0 .3em; +} + +h3 { + font-size: 24px; + margin: 1.2em 0 .3em; +} + +h4 { + font-size: 20px; + margin: 1em 0 .2em; + padding-top: 6em; + color: #4d4e53; +} + +h5, .container-overview .subsection-title { + font-size: 120%; + letter-spacing: -0.01em; + margin: 8px 0 3px 0; +} + +h6 { + font-size: 100%; + letter-spacing: -0.01em; + margin: 6px 0 3px 0; + font-style: italic; +} + +tt, code, kbd, samp { + font-family: Consolas, Monaco, 'Andale Mono', monospace; + background: #f4f4f4; + padding: 1px 5px; + border-radius: 5px; +} + +.class-description { + font-size: 130%; + line-height: 140%; + margin-bottom: 1em; + margin-top: 1em; +} + +.class-description:empty { + margin: 0 +} + +#main { + position: fixed; + top: 50px; + left: 250px; + right: 0; + bottom: 0; + float: none; + min-width: 360px; + overflow-y: hidden; +} + +#main-container { + position: relative; + width: 100%; + height: 100%; + overflow-y: scroll; + padding-left: 16px; + padding-right: 16px; +} + +#main-container h1 { + margin-top: 100px !important; + padding-top: 0px; + border-left: 2px solid #3391FE; +} + +#main-container h4 { + margin-top: 120px !important; + padding-top: 0px; + padding-left: 16px; + margin-left: -16px; + border-left: 2px solid #3391FE; +} + +header { + display: block +} + +section, h1 { + display: block; + background-color: #fff; + padding: 2em 30px 0; +} + +#toc > h3 { + margin-bottom: 0px; +} + +#toc > .methods > li { + padding: 0px 10px; +} + +#toc > .methods > li > a { + font-size: 12px; + padding: 0px; +} + +#toc > .methods > .toc-header { + margin-top: 10px; +} + +#toc > .methods > .toc-method { + padding: 0px; + margin: 0px 10px; +} + +#toc > .methods > .toc-method > a, +#toc > .methods > .toc-method > a.active { + padding: 0px 0px 0px 20px; + border-left: 1px solid #D8DCDF; + color: #98999A; +} + +#toc > .methods > .toc-method.active { + background-color: #E8E8E8; +} + +.nav.navbar-right .navbar-form { + padding: 0; + margin: 6px 0px; +} + +.navbar-collapse.collapse { + display: block!important; +} + +.navbar-nav>li, .navbar-nav { + float: left !important; +} + +.navbar-nav.navbar-right:last-child { + margin-right: -15px !important; +} + +.navbar-right { + float: right!important; +} + +.twitter-typeahead input { + border-radius: 8px; + height: 38px; +} + +.twitter-typeahead input.tt-hint { + color: #AAA; +} + +.tt-menu { + background-color: white; + width: 100%; + box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1); + z-index: 11; + overflow-y: auto; +} + +.tt-suggestion, .tt-menu h3 { + font-size: 14px; + padding: 0.6em; + margin: 0; + cursor: pointer; +} + +.tt-menu h3 { + cursor: default; + font-weight: bold; + color: #888; +} + +.tt-suggestion:hover { + background-color: rgba(128, 128, 128, 0.2); +} + +.tt-cursor { + background-color: #D3D3D3; +} + +.search-bar-header-first { + margin: 5px 0px; + border-bottom: 1px solid #D3D3D3; +} + +.search-bar-header { + margin: 5px 0px; + border-top: 1px solid #D3D3D3; + border-bottom: 1px solid #D3D3D3; +} + +.variation { + display: none +} + +.signature-attributes { + font-size: 60%; + color: #aaa; + font-style: italic; + font-weight: lighter; +} + +nav { + float: left; + display: block; + width: 250px; + background: #FAFAFA; + overflow: auto; + position: fixed; + height: 100%; + top: 50px; + padding-left: 12px; + overflow-y: auto; + height: calc(100% - 50px); + box-shadow: 1px 0 rgba(0, 0, 0, 0.1); +} + +nav h3 { + margin-top: 12px; + font-size: 13px; + text-transform: uppercase; + letter-spacing: 1px; + font-weight: 700; + line-height: 24px; + margin: 15px 0 10px; + padding: 0; + color: #000; +} + +nav ul { + font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; + font-size: 100%; + line-height: 17px; + padding: 0; + margin: 0; + list-style-type: none; +} + +nav ul a, +nav ul a:active { + font-family: 'Montserrat', sans-serif; + line-height: 18px; + padding: 0; + display: block; + font-size: 12px; +} + +nav ul a:hover, +nav ul a:active { + color: hsl(200, 100%, 43%); + text-decoration: none; +} + +nav > ul { + padding: 0 10px; +} + +nav > ul > li > a { + color: #000; +} + +nav ul ul { + margin-bottom: 10px +} + +nav ul ul a { + color: hsl(207, 1%, 60%); + border-left: 1px solid hsl(207, 10%, 86%); +} + +nav ul ul a, +nav ul ul a:active { + padding-left: 20px +} + +nav h2 { + font-size: 12px; + margin: 0; + padding: 0; +} + +nav > h2 > a { + display: block; + margin: 10px 0 -10px; + color: hsl(202, 71%, 50%) !important; +} + + +.navbar-brand { + padding: 8px; +} + +.navbar-brand img { + height: 32px; +} + +.navbar-fixed-top { + z-index: 1; + background-color: #F0F0F0; + padding: 0px 10px; + border-left: 6px solid #3391FE; +} + +.navbar-fixed-top .navbar-right { + padding-right: 16px; +} + +.navbar .ion-social-github { + font-size: 1.5em; + float: left; + color: #3391FE; +} + +.navbar .ion-social-github:hover { + color: #3D7FC1; +} + +footer { + max-width: 800px; + margin: 0 auto; + color: hsl(0, 0%, 56%); + display: block; + padding: 30px 30px 0; + font-size: 12px; + line-height: 1.4; +} + +#main section, #main h1 { + margin: 0 auto; + max-width: 800px; +} + +article img { + max-width: 100%; +} + +/* fix bootstrap's styling */ +pre { + background: #fff; + padding: 0px; +} + +code { + color: hsl(0, 0%, 35%); +} + +.ancestors { + color: #999 +} + +.ancestors a { + color: #999 !important; + text-decoration: none; +} + +.clear { + clear: both +} + +.important { + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px +} + +.type-signature { + color: #aaa; + display: none; +} + +.name, .signature { + font-family: Consolas, Monaco, 'Andale Mono', monospace +} + +.details { + margin-top: 14px; + border-left: 2px solid #DDD; + line-height: 30px; +} + +.alias-details { + margin-top: -10px; + border-left: none; +} + +.details dt { + width: 120px; + float: left; + padding-left: 10px; +} + +.alias-details dt { + padding-left: 0px; +} + +.details dd { + margin-left: 70px +} + +.details ul { + margin: 0 +} + +.details ul { + list-style-type: none +} + +.details li { + margin-left: 30px +} + +.details pre.prettyprint { + margin: 0 +} + +.details .object-value { + padding-top: 0 +} + +.description { + margin-bottom: 1em; + margin-top: 1em; +} + +.code-caption { + font-style: italic; + font-size: 107%; + margin: 0; +} + +.prettyprint { + font-size: 13px; + border: 1px solid #ddd; + border-radius: 3px; + box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.05); + overflow: auto; +} + +.prettyprint.source { + width: inherit +} + +.prettyprint code { + font-size: 100%; + line-height: 18px; + display: block; + background-color: #fff; + color: #4D4E53; +} + +.prettyprint > code { + padding: 15px +} + +.prettyprint .linenums code { + padding: 0 1em; + min-height: 18px; +} + +.prettyprint .linenums li:first-of-type code { + padding-top: 15px +} + +.prettyprint code span.line { + display: inline-block +} + +.prettyprint.linenums { + padding-left: 70px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.prettyprint.linenums ol { + padding-left: 0 +} + +.prettyprint.linenums li { + border-left: 3px #ddd solid +} + +.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { + background-color: lightyellow +} + +.prettyprint.linenums li * { + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +table.params { + margin-top: 1em; + box-shadow: none; + border: none; +} + +table.params td, table.params th { + border: none; + padding: 0 15px 8px 0; +} + +table.params td.type { + white-space: nowrap; +} + +.params .optional { + font-size: 80%; + color: hsl(0, 0%, 56%); +} + +.params, .props { + border-spacing: 0; + border: 1px solid #ddd; + border-collapse: collapse; + border-radius: 3px; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); + width: 100%; + font-size: 14px; +} + +.params .name, .props .name, .name code { + color: #4D4E53; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 100%; +} + +.params td, .params th, .props td, .props th { + margin: 0px; + text-align: left; + vertical-align: top; + padding: 10px; + display: table-cell; +} + +.params td { + border-top: 1px solid #eee +} + +.params thead tr, .props thead tr { + background-color: #fff; + font-weight: bold; + color: hsl(0, 0%, 56%); +} + +.params .params thead tr, .props .props thead tr { + background-color: #fff; + font-weight: bold; +} + +.params td.description > p:first-child, .props td.description > p:first-child { + margin-top: 0; + padding-top: 0; +} + +.params td.description > p:last-child, .props td.description > p:last-child { + margin-bottom: 0; + padding-bottom: 0; +} + +dl.param-type { + border-bottom: 1px solid hsl(0, 0%, 87%); + margin-bottom: 30px; + padding-bottom: 30px; +} + +.param-type dt, .param-type dd { + display: inline-block +} + +.param-type dd { + font-family: Consolas, Monaco, 'Andale Mono', monospace +} + +.disabled { + color: #454545 +} + +/* navicon button */ +.navicon-button { + display: none; + position: relative; + padding: 2.0625rem 1.5rem; + transition: 0.25s; + cursor: pointer; + user-select: none; + opacity: .8; + color: #3391FE; +} +.navicon-button .navicon:before, .navicon-button .navicon:after { + transition: 0.25s; +} +.navicon-button:hover { + transition: 0.5s; + opacity: 1; +} +.navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after { + transition: 0.25s; +} +.navicon-button:hover .navicon:before { + top: .825rem; +} +.navicon-button:hover .navicon:after { + top: -.825rem; +} + +/* navicon */ +.navicon { + position: relative; + width: 32px; + height: 4px; + background: #3391FE; + transition: 0.3s; + border-radius: 2px; +} +.navicon:before, .navicon:after { + display: block; + content: ""; + height: 4px; + width: 32px; + background: #3391FE; + position: absolute; + z-index: -1; + transition: 0.3s 0.25s; + border-radius: 2px; +} +.navicon:before { + top: 10px; +} +.navicon:after { + top: -10px; +} + +/* open */ +.nav-trigger:checked + label:not(.steps) .navicon:before, +.nav-trigger:checked + label:not(.steps) .navicon:after { + top: 0 !important; +} + +.nav-trigger:checked + label .navicon:before, +.nav-trigger:checked + label .navicon:after { + transition: 0.5s; +} + +/* Minus */ +.nav-trigger:checked + label { + transform: scale(0.75); +} + +/* ร— and + */ +.nav-trigger:checked + label.plus .navicon, +.nav-trigger:checked + label.x .navicon { + background: transparent; +} + +.nav-trigger:checked + label.plus .navicon:before, +.nav-trigger:checked + label.x .navicon:before { + transform: rotate(-45deg); + background: #FFF; +} + +.nav-trigger:checked + label.plus .navicon:after, +.nav-trigger:checked + label.x .navicon:after { + transform: rotate(45deg); + background: #FFF; +} + +.nav-trigger:checked + label.plus { + transform: scale(0.75) rotate(45deg); +} + +.nav-trigger:checked ~ nav { + left: 0 !important; +} + +.nav-trigger:checked ~ .overlay { + display: block; +} + +.nav-trigger { + position: fixed; + top: 0; + clip: rect(0, 0, 0, 0); +} + +.overlay { + display: none; + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 100%; + height: 100%; + background: hsla(0, 0%, 0%, 0.5); + z-index: 1; +} + +@media only screen and (min-width: 320px) and (max-width: 680px) { + body { + overflow-x: hidden; + } + + nav { + background: #FFF; + width: 250px; + height: 100%; + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: -250px; + z-index: 3; + padding: 0 10px; + transition: left 0.2s; + } + + .navicon-button { + display: inline-block; + position: fixed; + right: 0; + z-index: 2; + } + + #main { + padding: 16px; + left: 0px; + min-width: 360px; + } + + #main h1.page-title { + margin: 1em 0; + } + + #main h4 { + margin-left: -8px; + padding-left: 8px; + } + + #main section { + padding: 0; + } + + footer { + margin-left: 0; + } +} + +@media only print { + nav { + display: none; + } + + #main { + float: none; + width: 100%; + } +} diff --git a/docs/v2/styles/prettify-jsdoc.css b/docs/v2/styles/prettify-jsdoc.css new file mode 100644 index 000000000..834a866d4 --- /dev/null +++ b/docs/v2/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: hsl(104, 100%, 24%); + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/docs/v2/styles/prettify-tomorrow.css b/docs/v2/styles/prettify-tomorrow.css new file mode 100644 index 000000000..81e74d135 --- /dev/null +++ b/docs/v2/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: hsl(104, 100%, 24%); } + + /* a keyword */ + .kwd { + color: hsl(240, 100%, 50%); } + + /* a comment */ + .com { + color: hsl(0, 0%, 60%); } + + /* a type name */ + .typ { + color: hsl(240, 100%, 32%); } + + /* a literal value */ + .lit { + color: hsl(240, 100%, 40%); } + + /* punctuation */ + .pun { + color: #000000; } + + /* lisp open bracket */ + .opn { + color: #000000; } + + /* lisp close bracket */ + .clo { + color: #000000; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/docs/v2/timeout.js.html b/docs/v2/timeout.js.html new file mode 100644 index 000000000..3f73900df --- /dev/null +++ b/docs/v2/timeout.js.html @@ -0,0 +1,182 @@ + + + + + + + timeout.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timeout.js

+ + + + + + + +
+
+
import initialParams from './internal/initialParams';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} asyncFn - The async function to limit in time.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {AsyncFunction} Returns a wrapped function that can be used with any
+ * of the control flow functions.
+ * Invoke this function with the same parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ *     doAsyncTask(foo, function(err, data) {
+ *         // handle errors
+ *         if (err) return callback(err);
+ *
+ *         // do some stuff ...
+ *
+ *         // return processed data
+ *         return callback(null, data);
+ *     });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ *     // if `myFunction` takes < 1000 ms to execute, `err`
+ *     // and `data` will have their expected values
+ *
+ *     // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+export default function timeout(asyncFn, milliseconds, info) {
+    var fn = wrapAsync(asyncFn);
+
+    return initialParams(function (args, callback) {
+        var timedOut = false;
+        var timer;
+
+        function timeoutCallback() {
+            var name = asyncFn.name || 'anonymous';
+            var error  = new Error('Callback function "' + name + '" timed out.');
+            error.code = 'ETIMEDOUT';
+            if (info) {
+                error.info = info;
+            }
+            timedOut = true;
+            callback(error);
+        }
+
+        args.push(function () {
+            if (!timedOut) {
+                callback.apply(null, arguments);
+                clearTimeout(timer);
+            }
+        });
+
+        // setup timer and call original function
+        timer = setTimeout(timeoutCallback, milliseconds);
+        fn.apply(null, args);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/times.js.html b/docs/v2/times.js.html new file mode 100644 index 000000000..9b50bb3cf --- /dev/null +++ b/docs/v2/times.js.html @@ -0,0 +1,144 @@ + + + + + + + times.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

times.js

+ + + + + + + +
+
+
import timesLimit from './timesLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ *     callback(null, {
+ *         id: 'user' + id
+ *     });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ *     createUser(n, function(err, user) {
+ *         next(err, user);
+ *     });
+ * }, function(err, users) {
+ *     // we should now have 5 users
+ * });
+ */
+export default doLimit(timesLimit, Infinity);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/timesLimit.js.html b/docs/v2/timesLimit.js.html new file mode 100644 index 000000000..f17b4e511 --- /dev/null +++ b/docs/v2/timesLimit.js.html @@ -0,0 +1,132 @@ + + + + + + + timesLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timesLimit.js

+ + + + + + + +
+
+
import mapLimit from './mapLimit';
+import range from 'lodash/_baseRange';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+export default function timeLimit(count, limit, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    mapLimit(range(0, count, 1), limit, _iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/timesSeries.js.html b/docs/v2/timesSeries.js.html new file mode 100644 index 000000000..dac011cf8 --- /dev/null +++ b/docs/v2/timesSeries.js.html @@ -0,0 +1,126 @@ + + + + + + + timesSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timesSeries.js

+ + + + + + + +
+
+
import timesLimit from './timesLimit';
+import doLimit from './internal/doLimit';
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+export default doLimit(timesLimit, 1);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/transform.js.html b/docs/v2/transform.js.html new file mode 100644 index 000000000..8462390af --- /dev/null +++ b/docs/v2/transform.js.html @@ -0,0 +1,172 @@ + + + + + + + transform.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

transform.js

+ + + + + + + +
+
+
import isArray from 'lodash/isArray';
+import noop from 'lodash/noop';
+
+import eachOf from './eachOf';
+import once from './internal/once';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * A relative of `reduce`.  Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform.  If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ *     // pointless async:
+ *     process.nextTick(function() {
+ *         acc.push(item * 2)
+ *         callback(null)
+ *     });
+ * }, function(err, result) {
+ *     // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ *     setImmediate(function () {
+ *         obj[key] = val * 2;
+ *         callback();
+ *     })
+ * }, function (err, result) {
+ *     // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+export default function transform (coll, accumulator, iteratee, callback) {
+    if (arguments.length <= 3) {
+        callback = iteratee;
+        iteratee = accumulator;
+        accumulator = isArray(coll) ? [] : {};
+    }
+    callback = once(callback || noop);
+    var _iteratee = wrapAsync(iteratee);
+
+    eachOf(coll, function(v, k, cb) {
+        _iteratee(accumulator, v, k, cb);
+    }, function(err) {
+        callback(err, accumulator);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/tryEach.js.html b/docs/v2/tryEach.js.html new file mode 100644 index 000000000..436180782 --- /dev/null +++ b/docs/v2/tryEach.js.html @@ -0,0 +1,168 @@ + + + + + + + tryEach.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

tryEach.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import eachSeries from './eachSeries';
+import wrapAsync from './internal/wrapAsync';
+import slice from './internal/slice';
+
+/**
+ * It runs each task in series but stops whenever any of the functions were
+ * successful. If one of the tasks were successful, the `callback` will be
+ * passed the result of the successful task. If all tasks fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name tryEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to
+ * run, each function is passed a `callback(err, result)` it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback which is called when one
+ * of the tasks has succeeded, or all have failed. It receives the `err` and
+ * `result` arguments of the last attempt at completing the `task`. Invoked with
+ * (err, results).
+ * @example
+ * async.tryEach([
+ *     function getDataFromFirstWebsite(callback) {
+ *         // Try getting the data from the first website
+ *         callback(err, data);
+ *     },
+ *     function getDataFromSecondWebsite(callback) {
+ *         // First website failed,
+ *         // Try getting the data from the backup website
+ *         callback(err, data);
+ *     }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     Now do something with the data.
+ * });
+ *
+ */
+export default function tryEach(tasks, callback) {
+    var error = null;
+    var result;
+    callback = callback || noop;
+    eachSeries(tasks, function(task, callback) {
+        wrapAsync(task)(function (err, res/*, ...args*/) {
+            if (arguments.length > 2) {
+                result = slice(arguments, 1);
+            } else {
+                result = res;
+            }
+            error = err;
+            callback(!err);
+        });
+    }, function () {
+        callback(error, result);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/unmemoize.js.html b/docs/v2/unmemoize.js.html new file mode 100644 index 000000000..3009ec1d8 --- /dev/null +++ b/docs/v2/unmemoize.js.html @@ -0,0 +1,126 @@ + + + + + + + unmemoize.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

unmemoize.js

+ + + + + + + +
+
+
/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {AsyncFunction} fn - the memoized function
+ * @returns {AsyncFunction} a function that calls the original unmemoized function
+ */
+export default  function unmemoize(fn) {
+    return function () {
+        return (fn.unmemoized || fn).apply(null, arguments);
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/until.js.html b/docs/v2/until.js.html new file mode 100644 index 000000000..0ebf4bc38 --- /dev/null +++ b/docs/v2/until.js.html @@ -0,0 +1,137 @@ + + + + + + + until.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

until.js

+ + + + + + + +
+
+
import whilst from './whilst';
+
+/**
+ * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `iteratee`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ */
+export default function until(test, iteratee, callback) {
+    whilst(function() {
+        return !test.apply(this, arguments);
+    }, iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/waterfall.js.html b/docs/v2/waterfall.js.html new file mode 100644 index 000000000..02d559f68 --- /dev/null +++ b/docs/v2/waterfall.js.html @@ -0,0 +1,194 @@ + + + + + + + waterfall.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

waterfall.js

+ + + + + + + +
+
+
import isArray from 'lodash/isArray';
+import noop from 'lodash/noop';
+import once from './internal/once';
+import slice from './internal/slice';
+
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
+ * to run.
+ * Each function should complete with any number of `result` values.
+ * The `result` values will be passed as arguments, in order, to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ *     function(callback) {
+ *         callback(null, 'one', 'two');
+ *     },
+ *     function(arg1, arg2, callback) {
+ *         // arg1 now equals 'one' and arg2 now equals 'two'
+ *         callback(null, 'three');
+ *     },
+ *     function(arg1, callback) {
+ *         // arg1 now equals 'three'
+ *         callback(null, 'done');
+ *     }
+ * ], function (err, result) {
+ *     // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ *     myFirstFunction,
+ *     mySecondFunction,
+ *     myLastFunction,
+ * ], function (err, result) {
+ *     // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ *     callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ *     // arg1 now equals 'one' and arg2 now equals 'two'
+ *     callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ *     // arg1 now equals 'three'
+ *     callback(null, 'done');
+ * }
+ */
+export default  function(tasks, callback) {
+    callback = once(callback || noop);
+    if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+    if (!tasks.length) return callback();
+    var taskIndex = 0;
+
+    function nextTask(args) {
+        var task = wrapAsync(tasks[taskIndex++]);
+        args.push(onlyOnce(next));
+        task.apply(null, args);
+    }
+
+    function next(err/*, ...args*/) {
+        if (err || taskIndex === tasks.length) {
+            return callback.apply(null, arguments);
+        }
+        nextTask(slice(arguments, 1));
+    }
+
+    nextTask([]);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v2/whilst.js.html b/docs/v2/whilst.js.html new file mode 100644 index 000000000..bbfb09773 --- /dev/null +++ b/docs/v2/whilst.js.html @@ -0,0 +1,160 @@ + + + + + + + whilst.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

whilst.js

+ + + + + + + +
+
+
import noop from 'lodash/noop';
+import slice from './internal/slice';
+
+import onlyOnce from './internal/onlyOnce';
+import wrapAsync from './internal/wrapAsync';
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ *     function() { return count < 5; },
+ *     function(callback) {
+ *         count++;
+ *         setTimeout(function() {
+ *             callback(null, count);
+ *         }, 1000);
+ *     },
+ *     function (err, n) {
+ *         // 5 seconds have passed, n = 5
+ *     }
+ * );
+ */
+export default function whilst(test, iteratee, callback) {
+    callback = onlyOnce(callback || noop);
+    var _iteratee = wrapAsync(iteratee);
+    if (!test()) return callback(null);
+    var next = function(err/*, ...args*/) {
+        if (err) return callback(err);
+        if (test()) return _iteratee(next);
+        var args = slice(arguments, 1);
+        callback.apply(null, [null].concat(args));
+    };
+    _iteratee(next);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 3.5.5 on Sun May 26 2019 15:21:49 GMT-0700 (Pacific Daylight Time) using the Minami theme. + Documentation has been modified from the original. For more information, please see the async repository.
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/apply.js.html b/docs/v3/apply.js.html new file mode 100644 index 000000000..add2b7da1 --- /dev/null +++ b/docs/v3/apply.js.html @@ -0,0 +1,157 @@ + + + + + + + apply.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

apply.js

+ + + + + + + +
+
+
/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @returns {Function} the partially-applied function
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ *     async.apply(fs.writeFile, 'testfile1', 'test1'),
+ *     async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ *     function(callback) {
+ *         fs.writeFile('testfile1', 'test1', callback);
+ *     },
+ *     function(callback) {
+ *         fs.writeFile('testfile2', 'test2', callback);
+ *     }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+export default function(fn, ...args) {
+    return (...callArgs) => fn(...args,...callArgs);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/applyEach.js.html b/docs/v3/applyEach.js.html new file mode 100644 index 000000000..c14661bec --- /dev/null +++ b/docs/v3/applyEach.js.html @@ -0,0 +1,152 @@ + + + + + + + applyEach.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

applyEach.js

+ + + + + + + +
+
+
import applyEach from './internal/applyEach.js'
+import map from './map.js'
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional. The results
+ * for each of the applied async functions are passed to the final callback
+ * as an array.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {AsyncFunction} - Returns a function that takes no args other than
+ * an optional callback, that is the result of applying the `args` to each
+ * of the functions.
+ * @example
+ *
+ * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
+ *
+ * appliedFn((err, results) => {
+ *     // results[0] is the results for `enableSearch`
+ *     // results[1] is the results for `updateSchema`
+ * });
+ *
+ * // partial application example:
+ * async.each(
+ *     buckets,
+ *     async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
+ *     callback
+ * );
+ */
+export default applyEach(map);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/applyEachSeries.js.html b/docs/v3/applyEachSeries.js.html new file mode 100644 index 000000000..60c2f2cd4 --- /dev/null +++ b/docs/v3/applyEachSeries.js.html @@ -0,0 +1,132 @@ + + + + + + + applyEachSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

applyEachSeries.js

+ + + + + + + +
+
+
import applyEach from './internal/applyEach.js'
+import mapSeries from './mapSeries.js'
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {AsyncFunction} - A function, that when called, is the result of
+ * appling the `args` to the list of functions.  It takes no args, other than
+ * a callback.
+ */
+export default applyEach(mapSeries);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/asyncify.js.html b/docs/v3/asyncify.js.html new file mode 100644 index 000000000..26201e7aa --- /dev/null +++ b/docs/v3/asyncify.js.html @@ -0,0 +1,209 @@ + + + + + + + asyncify.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

asyncify.js

+ + + + + + + +
+
+
import initialParams from './internal/initialParams.js'
+import setImmediate from './internal/setImmediate.js'
+import { isAsync } from './internal/wrapAsync.js'
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2017 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function, or Promise-returning
+ * function to convert to an {@link AsyncFunction}.
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
+ * invoked with `(args..., callback)`.
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ *     async.apply(fs.readFile, filename, "utf8"),
+ *     async.asyncify(JSON.parse),
+ *     function (data, next) {
+ *         // data is the result of parsing the text.
+ *         // If there was a parsing error, it would have been caught.
+ *     }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ *     async.apply(fs.readFile, filename, "utf8"),
+ *     async.asyncify(function (contents) {
+ *         return db.model.create(contents);
+ *     }),
+ *     function (model, next) {
+ *         // `model` is the instantiated model object.
+ *         // If there was an error, this function would be skipped.
+ *     }
+ * ], callback);
+ *
+ * // es2017 example, though `asyncify` is not needed if your JS environment
+ * // supports async functions out of the box
+ * var q = async.queue(async.asyncify(async function(file) {
+ *     var intermediateStep = await processFile(file);
+ *     return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+export default function asyncify(func) {
+    if (isAsync(func)) {
+        return function (...args/*, callback*/) {
+            const callback = args.pop()
+            const promise = func.apply(this, args)
+            return handlePromise(promise, callback)
+        }
+    }
+
+    return initialParams(function (args, callback) {
+        var result;
+        try {
+            result = func.apply(this, args);
+        } catch (e) {
+            return callback(e);
+        }
+        // if result is Promise object
+        if (result && typeof result.then === 'function') {
+            return handlePromise(result, callback)
+        } else {
+            callback(null, result);
+        }
+    });
+}
+
+function handlePromise(promise, callback) {
+    return promise.then(value => {
+        invokeCallback(callback, null, value);
+    }, err => {
+        invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err));
+    });
+}
+
+function invokeCallback(callback, error, value) {
+    try {
+        callback(error, value);
+    } catch (err) {
+        setImmediate(e => { throw e }, err);
+    }
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/auto.js.html b/docs/v3/auto.js.html new file mode 100644 index 000000000..5b665a053 --- /dev/null +++ b/docs/v3/auto.js.html @@ -0,0 +1,430 @@ + + + + + + + auto.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

auto.js

+ + + + + + + +
+
+
import once from './internal/once.js'
+import onlyOnce from './internal/onlyOnce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js'
+
+/**
+ * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * {@link AsyncFunction}s also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the {@link AsyncFunction} itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ *   functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ *   passing an `error` (which can be `null`) and the result of the function's
+ *   execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns {Promise} a promise, if a callback is not passed
+ * @example
+ *
+ * //Using Callbacks
+ * async.auto({
+ *     get_data: function(callback) {
+ *         // async code to get some data
+ *         callback(null, 'data', 'converted to array');
+ *     },
+ *     make_folder: function(callback) {
+ *         // async code to create a directory to store a file in
+ *         // this is run at the same time as getting the data
+ *         callback(null, 'folder');
+ *     },
+ *     write_file: ['get_data', 'make_folder', function(results, callback) {
+ *         // once there is some data and the directory exists,
+ *         // write the data to a file in the directory
+ *         callback(null, 'filename');
+ *     }],
+ *     email_link: ['write_file', function(results, callback) {
+ *         // once the file is written let's email a link to it...
+ *         callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ *     }]
+ * }, function(err, results) {
+ *     if (err) {
+ *         console.log('err = ', err);
+ *     }
+ *     console.log('results = ', results);
+ *     // results = {
+ *     //     get_data: ['data', 'converted to array']
+ *     //     make_folder; 'folder',
+ *     //     write_file: 'filename'
+ *     //     email_link: { file: 'filename', email: 'user@example.com' }
+ *     // }
+ * });
+ *
+ * //Using Promises
+ * async.auto({
+ *     get_data: function(callback) {
+ *         console.log('in get_data');
+ *         // async code to get some data
+ *         callback(null, 'data', 'converted to array');
+ *     },
+ *     make_folder: function(callback) {
+ *         console.log('in make_folder');
+ *         // async code to create a directory to store a file in
+ *         // this is run at the same time as getting the data
+ *         callback(null, 'folder');
+ *     },
+ *     write_file: ['get_data', 'make_folder', function(results, callback) {
+ *         // once there is some data and the directory exists,
+ *         // write the data to a file in the directory
+ *         callback(null, 'filename');
+ *     }],
+ *     email_link: ['write_file', function(results, callback) {
+ *         // once the file is written let's email a link to it...
+ *         callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ *     }]
+ * }).then(results => {
+ *     console.log('results = ', results);
+ *     // results = {
+ *     //     get_data: ['data', 'converted to array']
+ *     //     make_folder; 'folder',
+ *     //     write_file: 'filename'
+ *     //     email_link: { file: 'filename', email: 'user@example.com' }
+ *     // }
+ * }).catch(err => {
+ *     console.log('err = ', err);
+ * });
+ *
+ * //Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.auto({
+ *             get_data: function(callback) {
+ *                 // async code to get some data
+ *                 callback(null, 'data', 'converted to array');
+ *             },
+ *             make_folder: function(callback) {
+ *                 // async code to create a directory to store a file in
+ *                 // this is run at the same time as getting the data
+ *                 callback(null, 'folder');
+ *             },
+ *             write_file: ['get_data', 'make_folder', function(results, callback) {
+ *                 // once there is some data and the directory exists,
+ *                 // write the data to a file in the directory
+ *                 callback(null, 'filename');
+ *             }],
+ *             email_link: ['write_file', function(results, callback) {
+ *                 // once the file is written let's email a link to it...
+ *                 callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ *             }]
+ *         });
+ *         console.log('results = ', results);
+ *         // results = {
+ *         //     get_data: ['data', 'converted to array']
+ *         //     make_folder; 'folder',
+ *         //     write_file: 'filename'
+ *         //     email_link: { file: 'filename', email: 'user@example.com' }
+ *         // }
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+export default function auto(tasks, concurrency, callback) {
+    if (typeof concurrency !== 'number') {
+        // concurrency is optional, shift the args.
+        callback = concurrency;
+        concurrency = null;
+    }
+    callback = once(callback || promiseCallback());
+    var numTasks = Object.keys(tasks).length;
+    if (!numTasks) {
+        return callback(null);
+    }
+    if (!concurrency) {
+        concurrency = numTasks;
+    }
+
+    var results = {};
+    var runningTasks = 0;
+    var canceled = false;
+    var hasError = false;
+
+    var listeners = Object.create(null);
+
+    var readyTasks = [];
+
+    // for cycle detection:
+    var readyToCheck = []; // tasks that have been identified as reachable
+    // without the possibility of returning to an ancestor task
+    var uncheckedDependencies = {};
+
+    Object.keys(tasks).forEach(key => {
+        var task = tasks[key]
+        if (!Array.isArray(task)) {
+            // no dependencies
+            enqueueTask(key, [task]);
+            readyToCheck.push(key);
+            return;
+        }
+
+        var dependencies = task.slice(0, task.length - 1);
+        var remainingDependencies = dependencies.length;
+        if (remainingDependencies === 0) {
+            enqueueTask(key, task);
+            readyToCheck.push(key);
+            return;
+        }
+        uncheckedDependencies[key] = remainingDependencies;
+
+        dependencies.forEach(dependencyName => {
+            if (!tasks[dependencyName]) {
+                throw new Error('async.auto task `' + key +
+                    '` has a non-existent dependency `' +
+                    dependencyName + '` in ' +
+                    dependencies.join(', '));
+            }
+            addListener(dependencyName, () => {
+                remainingDependencies--;
+                if (remainingDependencies === 0) {
+                    enqueueTask(key, task);
+                }
+            });
+        });
+    });
+
+    checkForDeadlocks();
+    processQueue();
+
+    function enqueueTask(key, task) {
+        readyTasks.push(() => runTask(key, task));
+    }
+
+    function processQueue() {
+        if (canceled) return
+        if (readyTasks.length === 0 && runningTasks === 0) {
+            return callback(null, results);
+        }
+        while(readyTasks.length && runningTasks < concurrency) {
+            var run = readyTasks.shift();
+            run();
+        }
+
+    }
+
+    function addListener(taskName, fn) {
+        var taskListeners = listeners[taskName];
+        if (!taskListeners) {
+            taskListeners = listeners[taskName] = [];
+        }
+
+        taskListeners.push(fn);
+    }
+
+    function taskComplete(taskName) {
+        var taskListeners = listeners[taskName] || [];
+        taskListeners.forEach(fn => fn());
+        processQueue();
+    }
+
+
+    function runTask(key, task) {
+        if (hasError) return;
+
+        var taskCallback = onlyOnce((err, ...result) => {
+            runningTasks--;
+            if (err === false) {
+                canceled = true
+                return
+            }
+            if (result.length < 2) {
+                [result] = result;
+            }
+            if (err) {
+                var safeResults = {};
+                Object.keys(results).forEach(rkey => {
+                    safeResults[rkey] = results[rkey];
+                });
+                safeResults[key] = result;
+                hasError = true;
+                listeners = Object.create(null);
+                if (canceled) return
+                callback(err, safeResults);
+            } else {
+                results[key] = result;
+                taskComplete(key);
+            }
+        });
+
+        runningTasks++;
+        var taskFn = wrapAsync(task[task.length - 1]);
+        if (task.length > 1) {
+            taskFn(results, taskCallback);
+        } else {
+            taskFn(taskCallback);
+        }
+    }
+
+    function checkForDeadlocks() {
+        // Kahn's algorithm
+        // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+        // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+        var currentTask;
+        var counter = 0;
+        while (readyToCheck.length) {
+            currentTask = readyToCheck.pop();
+            counter++;
+            getDependents(currentTask).forEach(dependent => {
+                if (--uncheckedDependencies[dependent] === 0) {
+                    readyToCheck.push(dependent);
+                }
+            });
+        }
+
+        if (counter !== numTasks) {
+            throw new Error(
+                'async.auto cannot execute tasks due to a recursive dependency'
+            );
+        }
+    }
+
+    function getDependents(taskName) {
+        var result = [];
+        Object.keys(tasks).forEach(key => {
+            const task = tasks[key]
+            if (Array.isArray(task) && task.indexOf(taskName) >= 0) {
+                result.push(key);
+            }
+        });
+        return result;
+    }
+
+    return callback[PROMISE_SYMBOL]
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/autoInject.js.html b/docs/v3/autoInject.js.html new file mode 100644 index 000000000..3ad1ecb23 --- /dev/null +++ b/docs/v3/autoInject.js.html @@ -0,0 +1,282 @@ + + + + + + + autoInject.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

autoInject.js

+ + + + + + + +
+
+
import auto from './auto.js'
+import wrapAsync from './internal/wrapAsync.js'
+import { isAsync } from './internal/wrapAsync.js'
+
+var FN_ARGS = /^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/;
+var ARROW_FN_ARGS = /^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+
+function stripComments(string) {
+    let stripped = '';
+    let index = 0;
+    let endBlockComment = string.indexOf('*/');
+    while (index < string.length) {
+        if (string[index] === '/' && string[index+1] === '/') {
+            // inline comment
+            let endIndex = string.indexOf('\n', index);
+            index = (endIndex === -1) ? string.length : endIndex;
+        } else if ((endBlockComment !== -1) && (string[index] === '/') && (string[index+1] === '*')) {
+            // block comment
+            let endIndex = string.indexOf('*/', index);
+            if (endIndex !== -1) {
+                index = endIndex + 2;
+                endBlockComment = string.indexOf('*/', index);
+            } else {
+                stripped += string[index];
+                index++;
+            }
+        } else {
+            stripped += string[index];
+            index++;
+        }
+    }
+    return stripped;
+}
+
+function parseParams(func) {
+    const src = stripComments(func.toString());
+    let match = src.match(FN_ARGS);
+    if (!match) {
+        match = src.match(ARROW_FN_ARGS);
+    }
+    if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src)
+    let [, args] = match
+    return args
+        .replace(/\s/g, '')
+        .split(FN_ARG_SPLIT)
+        .map((arg) => arg.replace(FN_ARG, '').trim());
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ *   when finished, passing an `error` (which can be `null`) and the result of
+ *   the function's execution. The remaining parameters name other tasks on
+ *   which the task is dependent, and the results from those tasks are the
+ *   arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * //  The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ *     get_data: function(callback) {
+ *         // async code to get some data
+ *         callback(null, 'data', 'converted to array');
+ *     },
+ *     make_folder: function(callback) {
+ *         // async code to create a directory to store a file in
+ *         // this is run at the same time as getting the data
+ *         callback(null, 'folder');
+ *     },
+ *     write_file: function(get_data, make_folder, callback) {
+ *         // once there is some data and the directory exists,
+ *         // write the data to a file in the directory
+ *         callback(null, 'filename');
+ *     },
+ *     email_link: function(write_file, callback) {
+ *         // once the file is written let's email a link to it...
+ *         // write_file contains the filename returned by write_file.
+ *         callback(null, {'file':write_file, 'email':'user@example.com'});
+ *     }
+ * }, function(err, results) {
+ *     console.log('err = ', err);
+ *     console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier.  To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ *     //...
+ *     write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ *         callback(null, 'filename');
+ *     }],
+ *     email_link: ['write_file', function(write_file, callback) {
+ *         callback(null, {'file':write_file, 'email':'user@example.com'});
+ *     }]
+ *     //...
+ * }, function(err, results) {
+ *     console.log('err = ', err);
+ *     console.log('email_link = ', results.email_link);
+ * });
+ */
+export default function autoInject(tasks, callback) {
+    var newTasks = {};
+
+    Object.keys(tasks).forEach(key => {
+        var taskFn = tasks[key]
+        var params;
+        var fnIsAsync = isAsync(taskFn);
+        var hasNoDeps =
+            (!fnIsAsync && taskFn.length === 1) ||
+            (fnIsAsync && taskFn.length === 0);
+
+        if (Array.isArray(taskFn)) {
+            params = [...taskFn];
+            taskFn = params.pop();
+
+            newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+        } else if (hasNoDeps) {
+            // no dependencies, use the function as-is
+            newTasks[key] = taskFn;
+        } else {
+            params = parseParams(taskFn);
+            if ((taskFn.length === 0 && !fnIsAsync) && params.length === 0) {
+                throw new Error("autoInject task functions require explicit parameters.");
+            }
+
+            // remove callback param
+            if (!fnIsAsync) params.pop();
+
+            newTasks[key] = params.concat(newTask);
+        }
+
+        function newTask(results, taskCb) {
+            var newArgs = params.map(name => results[name])
+            newArgs.push(taskCb);
+            wrapAsync(taskFn)(...newArgs);
+        }
+    });
+
+    return auto(newTasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/cargo.js.html b/docs/v3/cargo.js.html new file mode 100644 index 000000000..7a00c874b --- /dev/null +++ b/docs/v3/cargo.js.html @@ -0,0 +1,160 @@ + + + + + + + cargo.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

cargo.js

+ + + + + + + +
+
+
import queue from './internal/queue.js'
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An asynchronous function for processing an array
+ * of queued tasks. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ *     for (var i=0; i<tasks.length; i++) {
+ *         console.log('hello ' + tasks[i].name);
+ *     }
+ *     callback();
+ * }, 2);
+ *
+ * // add some items
+ * cargo.push({name: 'foo'}, function(err) {
+ *     console.log('finished processing foo');
+ * });
+ * cargo.push({name: 'bar'}, function(err) {
+ *     console.log('finished processing bar');
+ * });
+ * await cargo.push({name: 'baz'});
+ * console.log('finished processing baz');
+ */
+export default function cargo(worker, payload) {
+    return queue(worker, 1, payload);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/cargoQueue.js.html b/docs/v3/cargoQueue.js.html new file mode 100644 index 000000000..c3d897797 --- /dev/null +++ b/docs/v3/cargoQueue.js.html @@ -0,0 +1,168 @@ + + + + + + + cargoQueue.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

cargoQueue.js

+ + + + + + + +
+
+
import queue from './internal/queue.js'
+
+/**
+ * Creates a `cargoQueue` object with the specified payload. Tasks added to the
+ * cargoQueue will be processed together (up to the `payload` limit) in `concurrency` parallel workers.
+ * If the all `workers` are in progress, the task is queued until one becomes available. Once
+ * a `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, and [`cargo`]{@link module:ControlFlow.cargo} passes an array of tasks to a single worker,
+ * the cargoQueue passes an array of tasks to multiple parallel workers.
+ *
+ * @name cargoQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @see [async.cargo]{@link module:ControlFLow.cargo}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An asynchronous function for processing an array
+ * of queued tasks. Invoked with `(tasks, callback)`.
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel.  If omitted, the concurrency
+ * defaults to `1`.  If the concurrency is `0`, an error is thrown.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.QueueObject} A cargoQueue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargoQueue and inner queue.
+ * @example
+ *
+ * // create a cargoQueue object with payload 2 and concurrency 2
+ * var cargoQueue = async.cargoQueue(function(tasks, callback) {
+ *     for (var i=0; i<tasks.length; i++) {
+ *         console.log('hello ' + tasks[i].name);
+ *     }
+ *     callback();
+ * }, 2, 2);
+ *
+ * // add some items
+ * cargoQueue.push({name: 'foo'}, function(err) {
+ *     console.log('finished processing foo');
+ * });
+ * cargoQueue.push({name: 'bar'}, function(err) {
+ *     console.log('finished processing bar');
+ * });
+ * cargoQueue.push({name: 'baz'}, function(err) {
+ *     console.log('finished processing baz');
+ * });
+ * cargoQueue.push({name: 'boo'}, function(err) {
+ *     console.log('finished processing boo');
+ * });
+ */
+export default function cargo(worker, concurrency, payload) {
+    return queue(worker, concurrency, payload);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/compose.js.html b/docs/v3/compose.js.html new file mode 100644 index 000000000..bb1d4a350 --- /dev/null +++ b/docs/v3/compose.js.html @@ -0,0 +1,152 @@ + + + + + + + compose.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

compose.js

+ + + + + + + +
+
+
import seq from './seq.js'
+
+/**
+ * Creates a function which is a composition of the passed asynchronous
+ * functions. Each function consumes the return value of the function that
+ * follows. Composing functions `f()`, `g()`, and `h()` would produce the result
+ * of `f(g(h()))`, only this version uses callbacks to obtain the return values.
+ *
+ * If the last argument to the composed function is not a function, a promise
+ * is returned when you call it.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name compose
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {...AsyncFunction} functions - the asynchronous functions to compose
+ * @returns {Function} an asynchronous function that is the composed
+ * asynchronous `functions`
+ * @example
+ *
+ * function add1(n, callback) {
+ *     setTimeout(function () {
+ *         callback(null, n + 1);
+ *     }, 10);
+ * }
+ *
+ * function mul3(n, callback) {
+ *     setTimeout(function () {
+ *         callback(null, n * 3);
+ *     }, 10);
+ * }
+ *
+ * var add1mul3 = async.compose(mul3, add1);
+ * add1mul3(4, function (err, result) {
+ *     // result now equals 15
+ * });
+ */
+export default function compose(...args) {
+    return seq(...args.reverse());
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/concat.js.html b/docs/v3/concat.js.html new file mode 100644 index 000000000..3ff324dfc --- /dev/null +++ b/docs/v3/concat.js.html @@ -0,0 +1,210 @@ + + + + + + + concat.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concat.js

+ + + + + + + +
+
+
import concatLimit from './concatLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
+ * the concatenated list. The `iteratee`s are called in parallel, and the
+ * results are concatenated as they return. The results array will be returned in
+ * the original order of `coll` passed to the `iteratee` function.
+ *
+ * @name concat
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @alias flatMap
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
+ * which should use an array as its result. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @returns A Promise, if no callback is passed
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ * // dir4 does not exist
+ *
+ * let directoryList = ['dir1','dir2','dir3'];
+ * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
+ *
+ * // Using callbacks
+ * async.concat(directoryList, fs.readdir, function(err, results) {
+ *    if (err) {
+ *        console.log(err);
+ *    } else {
+ *        console.log(results);
+ *        // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+ *    }
+ * });
+ *
+ * // Error Handling
+ * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
+ *    if (err) {
+ *        console.log(err);
+ *        // [ Error: ENOENT: no such file or directory ]
+ *        // since dir4 does not exist
+ *    } else {
+ *        console.log(results);
+ *    }
+ * });
+ *
+ * // Using Promises
+ * async.concat(directoryList, fs.readdir)
+ * .then(results => {
+ *     console.log(results);
+ *     // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+ * }).catch(err => {
+ *      console.log(err);
+ * });
+ *
+ * // Error Handling
+ * async.concat(withMissingDirectoryList, fs.readdir)
+ * .then(results => {
+ *     console.log(results);
+ * }).catch(err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ *     // since dir4 does not exist
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.concat(directoryList, fs.readdir);
+ *         console.log(results);
+ *         // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+ *     } catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // Error Handling
+ * async () => {
+ *     try {
+ *         let results = await async.concat(withMissingDirectoryList, fs.readdir);
+ *         console.log(results);
+ *     } catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *         // since dir4 does not exist
+ *     }
+ * }
+ *
+ */
+function concat(coll, iteratee, callback) {
+    return concatLimit(coll, Infinity, iteratee, callback)
+}
+export default awaitify(concat, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/concatLimit.js.html b/docs/v3/concatLimit.js.html new file mode 100644 index 000000000..a1f611df5 --- /dev/null +++ b/docs/v3/concatLimit.js.html @@ -0,0 +1,152 @@ + + + + + + + concatLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concatLimit.js

+ + + + + + + +
+
+
import wrapAsync from './internal/wrapAsync.js'
+import mapLimit from './mapLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name concatLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @alias flatMapLimit
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
+ * which should use an array as its result. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @returns A Promise, if no callback is passed
+ */
+function concatLimit(coll, limit, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    return mapLimit(coll, limit, (val, iterCb) => {
+        _iteratee(val, (err, ...args) => {
+            if (err) return iterCb(err);
+            return iterCb(err, args);
+        });
+    }, (err, mapResults) => {
+        var result = [];
+        for (var i = 0; i < mapResults.length; i++) {
+            if (mapResults[i]) {
+                result = result.concat(...mapResults[i]);
+            }
+        }
+
+        return callback(err, result);
+    });
+}
+export default awaitify(concatLimit, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/concatSeries.js.html b/docs/v3/concatSeries.js.html new file mode 100644 index 000000000..2cd4874c0 --- /dev/null +++ b/docs/v3/concatSeries.js.html @@ -0,0 +1,136 @@ + + + + + + + concatSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

concatSeries.js

+ + + + + + + +
+
+
import concatLimit from './concatLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
+ *
+ * @name concatSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.concat]{@link module:Collections.concat}
+ * @category Collection
+ * @alias flatMapSeries
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`.
+ * The iteratee should complete with an array an array of results.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is an array
+ * containing the concatenated results of the `iteratee` function. Invoked with
+ * (err, results).
+ * @returns A Promise, if no callback is passed
+ */
+function concatSeries(coll, iteratee, callback) {
+    return concatLimit(coll, 1, iteratee, callback)
+}
+export default awaitify(concatSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/constant.js.html b/docs/v3/constant.js.html new file mode 100644 index 000000000..5bf34d3f5 --- /dev/null +++ b/docs/v3/constant.js.html @@ -0,0 +1,157 @@ + + + + + + + constant.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

constant.js

+ + + + + + + +
+
+
/**
+ * Returns a function that when called, calls-back with the values provided.
+ * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to
+ * [`auto`]{@link module:ControlFlow.auto}.
+ *
+ * @name constant
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {...*} arguments... - Any number of arguments to automatically invoke
+ * callback with.
+ * @returns {AsyncFunction} Returns a function that when invoked, automatically
+ * invokes the callback with the previous given arguments.
+ * @example
+ *
+ * async.waterfall([
+ *     async.constant(42),
+ *     function (value, next) {
+ *         // value === 42
+ *     },
+ *     //...
+ * ], callback);
+ *
+ * async.waterfall([
+ *     async.constant(filename, "utf8"),
+ *     fs.readFile,
+ *     function (fileData, next) {
+ *         //...
+ *     }
+ *     //...
+ * ], callback);
+ *
+ * async.auto({
+ *     hostname: async.constant("https://server.net/"),
+ *     port: findFreePort,
+ *     launchServer: ["hostname", "port", function (options, cb) {
+ *         startServer(options, cb);
+ *     }],
+ *     //...
+ * }, callback);
+ */
+export default function(...args) {
+    return function (...ignoredArgs/*, callback*/) {
+        var callback = ignoredArgs.pop();
+        return callback(null, ...args);
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/data/methodNames.json b/docs/v3/data/methodNames.json new file mode 100644 index 000000000..bfed40ce8 --- /dev/null +++ b/docs/v3/data/methodNames.json @@ -0,0 +1 @@ +["apply","applyEach","applyEachSeries","asyncify (wrapSync)","auto","autoInject","cargo","cargoQueue","compose","concat (flatMap)","concatLimit (flatMapLimit)","concatSeries (flatMapSeries)","constant","detect (find)","detectLimit (findLimit)","detectSeries (findSeries)","dir","doUntil","doWhilst","each (forEach)","eachLimit (forEachLimit)","eachOf (forEachOf)","eachOfLimit (forEachOfLimit)","eachOfSeries (forEachOfSeries)","eachSeries (forEachSeries)","ensureAsync","every (all)","everyLimit (allLimit)","everySeries (allSeries)","filter (select)","filterLimit (selectLimit)","filterSeries (selectSeries)","forever","groupBy","groupByLimit","groupBySeries","log","map","mapLimit","mapSeries","mapValues","mapValuesLimit","mapValuesSeries","memoize","nextTick","parallel","parallelLimit","priorityQueue","queue","race","reduce (foldl)","reduceRight (foldr)","reflect","reflectAll","reject","rejectLimit","rejectSeries","retry","retryable","seq","series","setImmediate","some (any)","someLimit (anyLimit)","someSeries (anySeries)","sortBy","timeout","times","timesLimit","timesSeries","transform","tryEach","unmemoize","until","waterfall","whilst"] diff --git a/docs/v3/data/sourceFiles.json b/docs/v3/data/sourceFiles.json new file mode 100644 index 000000000..ababfe6af --- /dev/null +++ b/docs/v3/data/sourceFiles.json @@ -0,0 +1 @@ +["apply.js.html","applyEach.js.html","applyEachSeries.js.html","asyncify.js.html","auto.js.html","autoInject.js.html","cargo.js.html","cargoQueue.js.html","compose.js.html","concat.js.html","concatLimit.js.html","concatSeries.js.html","constant.js.html","detect.js.html","detectLimit.js.html","detectSeries.js.html","dir.js.html","doUntil.js.html","doWhilst.js.html","each.js.html","eachLimit.js.html","eachOf.js.html","eachOfLimit.js.html","eachOfSeries.js.html","eachSeries.js.html","ensureAsync.js.html","every.js.html","everyLimit.js.html","everySeries.js.html","filter.js.html","filterLimit.js.html","filterSeries.js.html","forever.js.html","groupBy.js.html","groupByLimit.js.html","groupBySeries.js.html","index.js.html","log.js.html","map.js.html","mapLimit.js.html","mapSeries.js.html","mapValues.js.html","mapValuesLimit.js.html","mapValuesSeries.js.html","memoize.js.html","nextTick.js.html","parallel.js.html","parallelLimit.js.html","priorityQueue.js.html","queue.js.html","race.js.html","reduce.js.html","reduceRight.js.html","reflect.js.html","reflectAll.js.html","reject.js.html","rejectLimit.js.html","rejectSeries.js.html","retry.js.html","retryable.js.html","seq.js.html","series.js.html","setImmediate.js.html","some.js.html","someLimit.js.html","someSeries.js.html","sortBy.js.html","timeout.js.html","times.js.html","timesLimit.js.html","timesSeries.js.html","transform.js.html","tryEach.js.html","unmemoize.js.html","until.js.html","waterfall.js.html","whilst.js.html"] diff --git a/docs/v3/detect.js.html b/docs/v3/detect.js.html new file mode 100644 index 000000000..38bb5a505 --- /dev/null +++ b/docs/v3/detect.js.html @@ -0,0 +1,188 @@ + + + + + + + detect.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detect.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @returns {Promise} a promise, if a callback is omitted
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ *    fs.access(file, fs.constants.F_OK, (err) => {
+ *        callback(null, !err);
+ *    });
+ * }
+ *
+ * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
+ *    function(err, result) {
+ *        console.log(result);
+ *        // dir1/file1.txt
+ *        // result now equals the first file in the list that exists
+ *    }
+ *);
+ *
+ * // Using Promises
+ * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
+ * .then(result => {
+ *     console.log(result);
+ *     // dir1/file1.txt
+ *     // result now equals the first file in the list that exists
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
+ *         console.log(result);
+ *         // dir1/file1.txt
+ *         // result now equals the file in the list that exists
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+function detect(coll, iteratee, callback) {
+    return createTester(bool => bool, (res, item) => item)(eachOf, coll, iteratee, callback)
+}
+export default awaitify(detect, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/detectLimit.js.html b/docs/v3/detectLimit.js.html new file mode 100644 index 000000000..a85b717f1 --- /dev/null +++ b/docs/v3/detectLimit.js.html @@ -0,0 +1,140 @@ + + + + + + + detectLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detectLimit.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function detectLimit(coll, limit, iteratee, callback) {
+    return createTester(bool => bool, (res, item) => item)(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(detectLimit, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/detectSeries.js.html b/docs/v3/detectSeries.js.html new file mode 100644 index 000000000..f2c147a6c --- /dev/null +++ b/docs/v3/detectSeries.js.html @@ -0,0 +1,139 @@ + + + + + + + detectSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

detectSeries.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function detectSeries(coll, iteratee, callback) {
+    return createTester(bool => bool, (res, item) => item)(eachOfLimit(1), coll, iteratee, callback)
+}
+
+export default awaitify(detectSeries, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/dir.js.html b/docs/v3/dir.js.html new file mode 100644 index 000000000..a6ccffc35 --- /dev/null +++ b/docs/v3/dir.js.html @@ -0,0 +1,141 @@ + + + + + + + dir.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

dir.js

+ + + + + + + +
+
+
import consoleFunc from './internal/consoleFunc.js'
+
+/**
+ * Logs the result of an [`async` function]{@link AsyncFunction} to the
+ * `console` using `console.dir` to display the properties of the resulting object.
+ * Only works in Node.js or in browsers that support `console.dir` and
+ * `console.error` (such as FF and Chrome).
+ * If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ *     setTimeout(function() {
+ *         callback(null, {hello: name});
+ *     }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+export default consoleFunc('dir');
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/doUntil.js.html b/docs/v3/doUntil.js.html new file mode 100644 index 000000000..cd370a9a4 --- /dev/null +++ b/docs/v3/doUntil.js.html @@ -0,0 +1,140 @@ + + + + + + + doUntil.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

doUntil.js

+ + + + + + + +
+
+
import doWhilst from './doWhilst.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {AsyncFunction} test - asynchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `iteratee`
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns {Promise} a promise, if no callback is passed
+ */
+export default function doUntil(iteratee, test, callback) {
+    const _test = wrapAsync(test)
+    return doWhilst(iteratee, (...args) => {
+        const cb = args.pop()
+        _test(...args, (err, truth) => cb (err, !truth))
+    }, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/doWhilst.js.html b/docs/v3/doWhilst.js.html new file mode 100644 index 000000000..dee793288 --- /dev/null +++ b/docs/v3/doWhilst.js.html @@ -0,0 +1,160 @@ + + + + + + + doWhilst.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

doWhilst.js

+ + + + + + + +
+
+
import onlyOnce from './internal/onlyOnce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - A function which is called each time `test`
+ * passes. Invoked with (callback).
+ * @param {AsyncFunction} test - asynchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function doWhilst(iteratee, test, callback) {
+    callback = onlyOnce(callback);
+    var _fn = wrapAsync(iteratee);
+    var _test = wrapAsync(test);
+    var results
+
+    function next(err, ...args) {
+        if (err) return callback(err);
+        if (err === false) return;
+        results = args
+        _test(...args, check);
+    }
+
+    function check(err, truth) {
+        if (err) return callback(err);
+        if (err === false) return;
+        if (!truth) return callback(null, ...results);
+        _fn(next);
+    }
+
+    return check(null, true);
+}
+
+export default awaitify(doWhilst, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/docs.html b/docs/v3/docs.html new file mode 100644 index 000000000..5f1484569 --- /dev/null +++ b/docs/v3/docs.html @@ -0,0 +1,19881 @@ + + + + + + + + async - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

async

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via +npm install --save async, it can also be used directly in the browser.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +

Collections

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for manipulating collections, such as +arrays and objects.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) concat(coll, iteratee, callbackopt)

+ + + + + +
+
import concat from 'async/concat';
+
+

Applies iteratee to each item in coll, concatenating the results. Returns +the concatenated list. The iteratees are called in parallel, and the +results are concatenated as they return. The results array will be returned in +the original order of coll passed to the iteratee function.

+
+ + + +
+
Alias:
+
  • flatMap
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+let directoryList = ['dir1','dir2','dir3'];
+let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
+
+// Using callbacks
+async.concat(directoryList, fs.readdir, function(err, results) {
+   if (err) {
+       console.log(err);
+   } else {
+       console.log(results);
+       // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+   }
+});
+
+// Error Handling
+async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
+   if (err) {
+       console.log(err);
+       // [ Error: ENOENT: no such file or directory ]
+       // since dir4 does not exist
+   } else {
+       console.log(results);
+   }
+});
+
+// Using Promises
+async.concat(directoryList, fs.readdir)
+.then(results => {
+    console.log(results);
+    // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+}).catch(err => {
+     console.log(err);
+});
+
+// Error Handling
+async.concat(withMissingDirectoryList, fs.readdir)
+.then(results => {
+    console.log(results);
+}).catch(err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4 does not exist
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.concat(directoryList, fs.readdir);
+        console.log(results);
+        // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+    } catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let results = await async.concat(withMissingDirectoryList, fs.readdir);
+        console.log(results);
+    } catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+        // since dir4 does not exist
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) concatLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import concatLimit from 'async/concatLimit';
+
+

The same as concat but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • flatMapLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) concatSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import concatSeries from 'async/concatSeries';
+
+

The same as concat but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • flatMapSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll. +The iteratee should complete with an array an array of results. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detect(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detect from 'async/detect';
+
+

Returns the first value in coll that passes an async truth test. The +iteratee is applied in parallel, meaning the first iteratee to return +true will fire the detect callback with that result. That means the +result might not be the first item in the original coll (in terms of order) +that passes the test. +If order within the original coll is important, then look at +detectSeries.

+
+ + + +
+
Alias:
+
  • find
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // dir1/file1.txt
+       // result now equals the first file in the list that exists
+   }
+);
+
+// Using Promises
+async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
+.then(result => {
+    console.log(result);
+    // dir1/file1.txt
+    // result now equals the first file in the list that exists
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
+        console.log(result);
+        // dir1/file1.txt
+        // result now equals the file in the list that exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) detectLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detectLimit from 'async/detectLimit';
+
+

The same as detect but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • findLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detectSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detectSeries from 'async/detectSeries';
+
+

The same as detect but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • findSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) each(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import each from 'async/each';
+
+

Applies the function iteratee to each item in coll, in parallel. +The iteratee is called with an item from the list, and a callback for when +it has finished. If the iteratee passes an error to its callback, the +main callback (for the each function) is immediately called with the +error.

+

Note, that since this function applies iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEach
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to +each item in coll. Invoked with (item, callback). +The array index is not passed to the iteratee. +If you need the index, use eachOf.

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
+const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
+
+// asynchronous function that deletes a file
+const deleteFile = function(file, callback) {
+    fs.unlink(file, callback);
+};
+
+// Using callbacks
+async.each(fileList, deleteFile, function(err) {
+    if( err ) {
+        console.log(err);
+    } else {
+        console.log('All files have been deleted successfully');
+    }
+});
+
+// Error Handling
+async.each(withMissingFileList, deleteFile, function(err){
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4/file2.txt does not exist
+    // dir1/file1.txt could have been deleted
+});
+
+// Using Promises
+async.each(fileList, deleteFile)
+.then( () => {
+    console.log('All files have been deleted successfully');
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.each(fileList, deleteFile)
+.then( () => {
+    console.log('All files have been deleted successfully');
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4/file2.txt does not exist
+    // dir1/file1.txt could have been deleted
+});
+
+// Using async/await
+async () => {
+    try {
+        await async.each(files, deleteFile);
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        await async.each(withMissingFileList, deleteFile);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+        // since dir4/file2.txt does not exist
+        // dir1/file1.txt could have been deleted
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) eachLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachLimit from 'async/eachLimit';
+
+

The same as each but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • forEachLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfLimit. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOf(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOf from 'async/eachOf';
+
+

Like each, except that it passes the key (or index) as the second argument +to the iteratee.

+
+ + + +
+
Alias:
+
  • forEachOf
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each +item in coll. +The key is the item's key, or index in the case of an array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dev.json is a file containing a valid json object config for dev environment
+// dev.json is a file containing a valid json object config for test environment
+// prod.json is a file containing a valid json object config for prod environment
+// invalid.json is a file with a malformed json object
+
+let configs = {}; //global variable
+let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'};
+let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'};
+
+// asynchronous function that reads a json file and parses the contents as json object
+function parseFile(file, key, callback) {
+    fs.readFile(file, "utf8", function(err, data) {
+        if (err) return calback(err);
+        try {
+            configs[key] = JSON.parse(data);
+        } catch (e) {
+            return callback(e);
+        }
+        callback();
+    });
+}
+
+// Using callbacks
+async.forEachOf(validConfigFileMap, parseFile, function (err) {
+    if (err) {
+        console.error(err);
+    } else {
+        console.log(configs);
+        // configs is now a map of JSON data, e.g.
+        // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+    }
+});
+
+//Error handing
+async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
+    if (err) {
+        console.error(err);
+        // JSON parse error exception
+    } else {
+        console.log(configs);
+    }
+});
+
+// Using Promises
+async.forEachOf(validConfigFileMap, parseFile)
+.then( () => {
+    console.log(configs);
+    // configs is now a map of JSON data, e.g.
+    // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+}).catch( err => {
+    console.error(err);
+});
+
+//Error handing
+async.forEachOf(invalidConfigFileMap, parseFile)
+.then( () => {
+    console.log(configs);
+}).catch( err => {
+    console.error(err);
+    // JSON parse error exception
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.forEachOf(validConfigFileMap, parseFile);
+        console.log(configs);
+        // configs is now a map of JSON data, e.g.
+        // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+//Error handing
+async () => {
+    try {
+        let result = await async.forEachOf(invalidConfigFileMap, parseFile);
+        console.log(configs);
+    }
+    catch (err) {
+        console.log(err);
+        // JSON parse error exception
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOfLimit from 'async/eachOfLimit';
+
+

The same as eachOf but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • forEachOfLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. The key is the item's key, or index in the case of an +array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOfSeries from 'async/eachOfSeries';
+
+

The same as eachOf but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachOfSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachSeries from 'async/eachSeries';
+
+

The same as each but runs only a single async operation at a time.

+

Note, that unlike each, this function applies iteratee to each item +in series and therefore the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEachSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfSeries. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) every(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import every from 'async/every';
+
+

Returns true if every element in coll satisfies an async test. If any +iteratee call returns false, the main callback is immediately called.

+
+ + + +
+
Alias:
+
  • all
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.every(fileList, fileExists, function(err, result) {
+    console.log(result);
+    // true
+    // result is true since every file exists
+});
+
+async.every(withMissingFileList, fileExists, function(err, result) {
+    console.log(result);
+    // false
+    // result is false since NOT every file exists
+});
+
+// Using Promises
+async.every(fileList, fileExists)
+.then( result => {
+    console.log(result);
+    // true
+    // result is true since every file exists
+}).catch( err => {
+    console.log(err);
+});
+
+async.every(withMissingFileList, fileExists)
+.then( result => {
+    console.log(result);
+    // false
+    // result is false since NOT every file exists
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.every(fileList, fileExists);
+        console.log(result);
+        // true
+        // result is true since every file exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+async () => {
+    try {
+        let result = await async.every(withMissingFileList, fileExists);
+        console.log(result);
+        // false
+        // result is false since NOT every file exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) everyLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import everyLimit from 'async/everyLimit';
+
+

The same as every but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • allLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) everySeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import everySeries from 'async/everySeries';
+
+

The same as every but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • allSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in series. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filter(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filter from 'async/filter';
+
+

Returns a new array of all the values in coll which pass an async truth +test. This operation is performed in parallel, but the results array will be +in the same order as the original.

+
+ + + +
+
Alias:
+
  • select
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.filter(files, fileExists, function(err, results) {
+   if(err) {
+       console.log(err);
+   } else {
+       console.log(results);
+       // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+       // results is now an array of the existing files
+   }
+});
+
+// Using Promises
+async.filter(files, fileExists)
+.then(results => {
+    console.log(results);
+    // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+    // results is now an array of the existing files
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.filter(files, fileExists);
+        console.log(results);
+        // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+        // results is now an array of the existing files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) filterLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filterLimit from 'async/filterLimit';
+
+

The same as filter but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • selectLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filterSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filterSeries from 'async/filterSeries';
+
+

The same as filter but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • selectSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results)

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBy(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupBy from 'async/groupBy';
+
+

Returns a new object, where each value corresponds to an array of items, from +coll, that returned the corresponding key. That is, the keys of the object +correspond to the values passed to the iteratee callback.

+

Note: Since this function applies the iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order. +However, the values for each key in the result will be in the same order as +the original coll. For Objects, the values will roughly be in the order of +the original Objects' keys (but this can vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const files = ['dir1/file1.txt','dir2','dir4']
+
+// asynchronous function that detects file type as none, file, or directory
+function detectFile(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(null, 'none');
+        }
+        callback(null, stat.isDirectory() ? 'directory' : 'file');
+    });
+}
+
+//Using callbacks
+async.groupBy(files, detectFile, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+	       console.log(result);
+        // {
+        //     file: [ 'dir1/file1.txt' ],
+        //     none: [ 'dir4' ],
+        //     directory: [ 'dir2']
+        // }
+        // result is object containing the files grouped by type
+    }
+});
+
+// Using Promises
+async.groupBy(files, detectFile)
+.then( result => {
+    console.log(result);
+    // {
+    //     file: [ 'dir1/file1.txt' ],
+    //     none: [ 'dir4' ],
+    //     directory: [ 'dir2']
+    // }
+    // result is object containing the files grouped by type
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.groupBy(files, detectFile);
+        console.log(result);
+        // {
+        //     file: [ 'dir1/file1.txt' ],
+        //     none: [ 'dir4' ],
+        //     directory: [ 'dir2']
+        // }
+        // result is object containing the files grouped by type
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) groupByLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupByLimit from 'async/groupByLimit';
+
+

The same as groupBy but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBySeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupBySeries from 'async/groupBySeries';
+
+

The same as groupBy but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whose +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) map(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import map from 'async/map';
+
+

Produces a new collection of values by mapping each value in coll through +the iteratee function. The iteratee is called with an item from coll +and a callback for when it has finished processing. Each of these callbacks +takes 2 arguments: an error, and the transformed item from coll. If +iteratee passes an error to its callback, the main callback (for the +map function) is immediately called with the error.

+

Note, that since this function applies the iteratee to each item in +parallel, there is no guarantee that the iteratee functions will complete +in order. However, the results array will be in the same order as the +original coll.

+

If map is passed an Object, the results will be an Array. The results +will roughly be in the order of the original Objects' keys (but this can +vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an Array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.map(fileList, getFileSizeInBytes, function(err, results) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(results);
+        // results is now an array of the file size in bytes for each file, e.g.
+        // [ 1000, 2000, 3000]
+    }
+});
+
+// Error Handling
+async.map(withMissingFileList, getFileSizeInBytes, function(err, results) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(results);
+    }
+});
+
+// Using Promises
+async.map(fileList, getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+    // results is now an array of the file size in bytes for each file, e.g.
+    // [ 1000, 2000, 3000]
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.map(withMissingFileList, getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.map(fileList, getFileSizeInBytes);
+        console.log(results);
+        // results is now an array of the file size in bytes for each file, e.g.
+        // [ 1000, 2000, 3000]
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let results = await async.map(withMissingFileList, getFileSizeInBytes);
+        console.log(results);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapLimit from 'async/mapLimit';
+
+

The same as map but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapSeries from 'async/mapSeries';
+
+

The same as map but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValues(obj, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValues from 'async/mapValues';
+
+

A relative of map, designed for use with objects.

+

Produces a new Object by mapping each value of obj through the iteratee +function. The iteratee is called each value and key from obj and a +callback for when it has finished processing. Each of these callbacks takes +two arguments: an error, and the transformed item from obj. If iteratee +passes an error to its callback, the main callback (for the mapValues +function) is immediately called with the error.

+

Note, the order of the keys in the result is not guaranteed. The keys will +be roughly in the order they complete, (but this is very engine-specific)

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileMap = {
+    f1: 'file1.txt',
+    f2: 'file2.txt',
+    f3: 'file3.txt'
+};
+
+const withMissingFileMap = {
+    f1: 'file1.txt',
+    f2: 'file2.txt',
+    f3: 'file4.txt'
+};
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, key, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.mapValues(fileMap, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // result is now a map of file size in bytes for each file, e.g.
+        // {
+        //     f1: 1000,
+        //     f2: 2000,
+        //     f3: 3000
+        // }
+    }
+});
+
+// Error handling
+async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(result);
+    }
+});
+
+// Using Promises
+async.mapValues(fileMap, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+    // result is now a map of file size in bytes for each file, e.g.
+    // {
+    //     f1: 1000,
+    //     f2: 2000,
+    //     f3: 3000
+    // }
+}).catch (err => {
+    console.log(err);
+});
+
+// Error Handling
+async.mapValues(withMissingFileMap, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+}).catch (err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.mapValues(fileMap, getFileSizeInBytes);
+        console.log(result);
+        // result is now a map of file size in bytes for each file, e.g.
+        // {
+        //     f1: 1000,
+        //     f2: 2000,
+        //     f3: 3000
+        // }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes);
+        console.log(result);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesLimit(obj, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValuesLimit from 'async/mapValuesLimit';
+
+

The same as mapValues but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesSeries(obj, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValuesSeries from 'async/mapValuesSeries';
+
+

The same as mapValues but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reduce(coll, memo, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reduce from 'async/reduce';
+
+

Reduces coll into a single value using an async iteratee to return each +successive step. memo is the initial state of the reduction. This function +only operates in series.

+

For performance reasons, it may make sense to split a call to this function +into a parallel map, and then use the normal Array.prototype.reduce on the +results. This function is for situations where each step in the reduction +needs to be async; if you can get the data before reducing it, then it's +probably a good idea to do so.

+
+ + + +
+
Alias:
+
  • foldl
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee completes with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
+
+// asynchronous function that computes the file size in bytes
+// file size is added to the memoized value, then returned
+function getFileSizeInBytes(memo, file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, memo + stat.size);
+    });
+}
+
+// Using callbacks
+async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // 6000
+        // which is the sum of the file sizes of the three files
+    }
+});
+
+// Error Handling
+async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(result);
+    }
+});
+
+// Using Promises
+async.reduce(fileList, 0, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+    // 6000
+    // which is the sum of the file sizes of the three files
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.reduce(withMissingFileList, 0, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.reduce(fileList, 0, getFileSizeInBytes);
+        console.log(result);
+        // 6000
+        // which is the sum of the file sizes of the three files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
+        console.log(result);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reduceRight(array, memo, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reduceRight from 'async/reduceRight';
+
+

Same as reduce, only operates on array in reverse order.

+
+ + + +
+
Alias:
+
  • foldr
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
array + + +Array + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee completes with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reject(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reject from 'async/reject';
+
+

The opposite of filter. Removes values that pass an async truth test.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.reject(fileList, fileExists, function(err, results) {
+   // [ 'dir3/file6.txt' ]
+   // results now equals an array of the non-existing files
+});
+
+// Using Promises
+async.reject(fileList, fileExists)
+.then( results => {
+    console.log(results);
+    // [ 'dir3/file6.txt' ]
+    // results now equals an array of the non-existing files
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.reject(fileList, fileExists);
+        console.log(results);
+        // [ 'dir3/file6.txt' ]
+        // results now equals an array of the non-existing files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import rejectLimit from 'async/rejectLimit';
+
+

The same as reject but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import rejectSeries from 'async/rejectSeries';
+
+

The same as reject but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) some(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import some from 'async/some';
+
+

Returns true if at least one element in the coll satisfies an async test. +If any iteratee call returns true, the main callback is immediately +called.

+
+ + + +
+
Alias:
+
  • any
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // true
+       // result is true since some file in the list exists
+   }
+);
+
+async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // false
+       // result is false since none of the files exists
+   }
+);
+
+// Using Promises
+async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
+.then( result => {
+    console.log(result);
+    // true
+    // result is true since some file in the list exists
+}).catch( err => {
+    console.log(err);
+});
+
+async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
+.then( result => {
+    console.log(result);
+    // false
+    // result is false since none of the files exists
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
+        console.log(result);
+        // true
+        // result is true since some file in the list exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+async () => {
+    try {
+        let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
+        console.log(result);
+        // false
+        // result is false since none of the files exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) someLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import someLimit from 'async/someLimit';
+
+

The same as some but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • anyLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) someSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import someSeries from 'async/someSeries';
+
+

The same as some but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • anySeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in series. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) sortBy(coll, iteratee, callback) → {Promise}

+ + + + + +
+
import sortBy from 'async/sortBy';
+
+

Sorts a list by the results of running each coll value through an async +iteratee.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a value to use as the sort criteria as +its result. +Invoked with (item, callback).

callback + + +function + + + + + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is the items +from the original coll sorted by the values returned by the iteratee +calls. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// bigfile.txt is a file that is 251100 bytes in size
+// mediumfile.txt is a file that is 11000 bytes in size
+// smallfile.txt is a file that is 121 bytes in size
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes,
+    function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+        }
+    }
+);
+
+// By modifying the callback parameter the
+// sorting order can be influenced:
+
+// ascending order
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
+    getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+        if (getFileSizeErr) return callback(getFileSizeErr);
+        callback(null, fileSize);
+    });
+}, function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+        }
+    }
+);
+
+// descending order
+async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
+    getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+        if (getFileSizeErr) {
+            return callback(getFileSizeErr);
+        }
+        callback(null, fileSize * -1);
+    });
+}, function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt']
+        }
+    }
+);
+
+// Error handling
+async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes,
+    function(err, results) {
+        if (err) {
+            console.log(err);
+            // [ Error: ENOENT: no such file or directory ]
+        } else {
+            console.log(results);
+        }
+    }
+);
+
+// Using Promises
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+    // results is now the original array of files sorted by
+    // file size (ascending by default), e.g.
+    // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+}).catch( err => {
+    console.log(err);
+});
+
+// Error handling
+async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+(async () => {
+    try {
+        let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+        console.log(results);
+        // results is now the original array of files sorted by
+        // file size (ascending by default), e.g.
+        // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+    }
+    catch (err) {
+        console.log(err);
+    }
+})();
+
+// Error handling
+async () => {
+    try {
+        let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+        console.log(results);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) transform(coll, accumulatoropt, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import transform from 'async/transform';
+
+

A relative of reduce. Takes an Object or Array, and iterates over each +element in parallel, each step potentially mutating an accumulator value. +The type of the accumulator defaults to the type of collection passed in.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

accumulator + + +* + + + + + + <optional> + +

The initial state of the transform. If omitted, +it will default to an empty Object or Array, depending on the type of coll

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +collection that potentially modifies the accumulator. +Invoked with (accumulator, item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the transformed accumulator. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Examples
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+
+// helper function that returns human-readable size format from bytes
+function formatBytes(bytes, decimals = 2) {
+  // implementation not included for brevity
+  return humanReadbleFilesize;
+}
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+
+// asynchronous function that returns the file size, transformed to human-readable format
+// e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+function transformFileSize(acc, value, key, callback) {
+    fs.stat(value, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        acc[key] = formatBytes(stat.size);
+        callback(null);
+    });
+}
+
+// Using callbacks
+async.transform(fileList, transformFileSize, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+    }
+});
+
+// Using Promises
+async.transform(fileList, transformFileSize)
+.then(result => {
+    console.log(result);
+    // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+(async () => {
+    try {
+        let result = await async.transform(fileList, transformFileSize);
+        console.log(result);
+        // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+    }
+    catch (err) {
+        console.log(err);
+    }
+})();
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+
+// helper function that returns human-readable size format from bytes
+function formatBytes(bytes, decimals = 2) {
+  // implementation not included for brevity
+  return humanReadbleFilesize;
+}
+
+const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' };
+
+// asynchronous function that returns the file size, transformed to human-readable format
+// e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+function transformFileSize(acc, value, key, callback) {
+    fs.stat(value, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        acc[key] = formatBytes(stat.size);
+        callback(null);
+    });
+}
+
+// Using callbacks
+async.transform(fileMap, transformFileSize, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+    }
+});
+
+// Using Promises
+async.transform(fileMap, transformFileSize)
+.then(result => {
+    console.log(result);
+    // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.transform(fileMap, transformFileSize);
+        console.log(result);
+        // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +

Control Flow

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for controlling the flow through a script.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) applyEach(fns, …argsopt, callbackopt) → {AsyncFunction}

+ + + + + +
+
import applyEach from 'async/applyEach';
+
+

Applies the provided arguments to each function in the array, calling +callback after all functions have completed. If you only provide the first +argument, fns, then it will return a function which lets you pass in the +arguments as if it were a single function call. If more arguments are +provided, callback is required while args is still optional. The results +for each of the applied async functions are passed to the final callback +as an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of AsyncFunctions +to all call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • Returns a function that takes no args other than +an optional callback, that is the result of applying the args to each +of the functions.
  • +
+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
+
+appliedFn((err, results) => {
+    // results[0] is the results for `enableSearch`
+    // results[1] is the results for `updateSchema`
+});
+
+// partial application example:
+async.each(
+    buckets,
+    async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
+    callback
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) applyEachSeries(fns, …argsopt, callbackopt) → {AsyncFunction}

+ + + + + +
+
import applyEachSeries from 'async/applyEachSeries';
+
+

The same as applyEach but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of AsyncFunctions to all +call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • A function, that when called, is the result of +appling the args to the list of functions. It takes no args, other than +a callback.
  • +
+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) auto(tasks, concurrencyopt, callbackopt) → {Promise}

+ + + + + +
+
import auto from 'async/auto';
+
+

Determines the best order for running the AsyncFunctions in tasks, based on +their requirements. Each function can optionally depend on other functions +being completed first, and each function is run as soon as its requirements +are satisfied.

+

If any of the AsyncFunctions pass an error to their callback, the auto sequence +will stop. Further tasks will not execute (so any other functions depending +on it will not run), and the main callback is immediately called with the +error.

+

AsyncFunctions also receive an object containing the results of functions which +have completed so far as the first argument, if they have dependencies. If a +task function has no dependencies, it will only be passed a callback.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
tasks + + +Object + + + + + + + +

An object. Each of its properties is either a +function or an array of requirements, with the AsyncFunction itself the last item +in the array. The object's key of a property serves as the name of the task +defined by that property, i.e. can be used when specifying requirements for +other tasks. The function receives one or two arguments:

+
    +
  • a results object, containing the results of the previously executed +functions, only passed if the task has any dependencies,
  • +
  • a callback(err, result) function, which must be called when finished, +passing an error (which can be null) and the result of the function's +execution.
  • +
concurrency + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for +determining the maximum number of tasks that can be run in parallel. By +default, as many as possible.

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback. Results are always returned; however, if an +error occurs, no further tasks will be performed, and the results object +will only contain partial results. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.auto({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        // once the file is written let's email a link to it...
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}, function(err, results) {
+    if (err) {
+        console.log('err = ', err);
+    }
+    console.log('results = ', results);
+    // results = {
+    //     get_data: ['data', 'converted to array']
+    //     make_folder; 'folder',
+    //     write_file: 'filename'
+    //     email_link: { file: 'filename', email: 'user@example.com' }
+    // }
+});
+
+//Using Promises
+async.auto({
+    get_data: function(callback) {
+        console.log('in get_data');
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        console.log('in make_folder');
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        // once the file is written let's email a link to it...
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}).then(results => {
+    console.log('results = ', results);
+    // results = {
+    //     get_data: ['data', 'converted to array']
+    //     make_folder; 'folder',
+    //     write_file: 'filename'
+    //     email_link: { file: 'filename', email: 'user@example.com' }
+    // }
+}).catch(err => {
+    console.log('err = ', err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.auto({
+            get_data: function(callback) {
+                // async code to get some data
+                callback(null, 'data', 'converted to array');
+            },
+            make_folder: function(callback) {
+                // async code to create a directory to store a file in
+                // this is run at the same time as getting the data
+                callback(null, 'folder');
+            },
+            write_file: ['get_data', 'make_folder', function(results, callback) {
+                // once there is some data and the directory exists,
+                // write the data to a file in the directory
+                callback(null, 'filename');
+            }],
+            email_link: ['write_file', function(results, callback) {
+                // once the file is written let's email a link to it...
+                callback(null, {'file':results.write_file, 'email':'user@example.com'});
+            }]
+        });
+        console.log('results = ', results);
+        // results = {
+        //     get_data: ['data', 'converted to array']
+        //     make_folder; 'folder',
+        //     write_file: 'filename'
+        //     email_link: { file: 'filename', email: 'user@example.com' }
+        // }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) autoInject(tasks, callbackopt) → {Promise}

+ + + + + +
+
import autoInject from 'async/autoInject';
+
+

A dependency-injected version of the async.auto function. Dependent +tasks are specified as parameters to the function, after the usual callback +parameter, with the parameter names matching the names of the tasks it +depends on. This can provide even more readable task graphs which can be +easier to maintain.

+

If a final callback is specified, the task results are similarly injected, +specified as named parameters after the initial error parameter.

+

The autoInject function is purely syntactic sugar and its semantics are +otherwise equivalent to async.auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Object + + + + + +

An object, each of whose properties is an AsyncFunction of +the form 'func([dependencies...], callback). The object's key of a property +serves as the name of the task defined by that property, i.e. can be used +when specifying requirements for other tasks.

+
    +
  • The callback parameter is a callback(err, result) which must be called +when finished, passing an error (which can be null) and the result of +the function's execution. The remaining parameters name other tasks on +which the task is dependent, and the results from those tasks are the +arguments of those parameters.
  • +
callback + + +function + + + + + + <optional> + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback, and a results object with any completed +task results, similar to auto.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//  The example from `auto` can be rewritten as follows:
+async.autoInject({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: function(get_data, make_folder, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    },
+    email_link: function(write_file, callback) {
+        // once the file is written let's email a link to it...
+        // write_file contains the filename returned by write_file.
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+
+// If you are using a JS minifier that mangles parameter names, `autoInject`
+// will not work with plain functions, since the parameter names will be
+// collapsed to a single letter identifier.  To work around this, you can
+// explicitly specify the names of the parameters your task function needs
+// in an array, similar to Angular.js dependency injection.
+
+// This still has an advantage over plain `auto`, since the results a task
+// depends on are still spread into arguments.
+async.autoInject({
+    //...
+    write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(write_file, callback) {
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }]
+    //...
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargo(worker, payloadopt) → {QueueObject}

+ + + + + +
+
import cargo from 'async/cargo';
+
+

Creates a cargo object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the payload limit). If the +worker is in progress, the task is queued until it becomes available. Once +the worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargo object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargo and inner queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a cargo object with payload 2
+var cargo = async.cargo(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2);
+
+// add some items
+cargo.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargo.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+await cargo.push({name: 'baz'});
+console.log('finished processing baz');
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargoQueue(worker, concurrencyopt, payloadopt) → {QueueObject}

+ + + + + +
+
import cargoQueue from 'async/cargoQueue';
+
+

Creates a cargoQueue object with the specified payload. Tasks added to the +cargoQueue will be processed together (up to the payload limit) in concurrency parallel workers. +If the all workers are in progress, the task is queued until one becomes available. Once +a worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, and cargo passes an array of tasks to a single worker, +the cargoQueue passes an array of tasks to multiple parallel workers.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargoQueue object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargoQueue and inner queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a cargoQueue object with payload 2 and concurrency 2
+var cargoQueue = async.cargoQueue(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2, 2);
+
+// add some items
+cargoQueue.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargoQueue.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+cargoQueue.push({name: 'baz'}, function(err) {
+    console.log('finished processing baz');
+});
+cargoQueue.push({name: 'boo'}, function(err) {
+    console.log('finished processing boo');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) compose(…functions) → {function}

+ + + + + +
+
import compose from 'async/compose';
+
+

Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions f(), g(), and h() would produce the result +of f(g(h())), only this version uses callbacks to obtain the return values.

+

If the last argument to the composed function is not a function, a promise +is returned when you call it.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

an asynchronous function that is the composed +asynchronous functions

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
function add1(n, callback) {
+    setTimeout(function () {
+        callback(null, n + 1);
+    }, 10);
+}
+
+function mul3(n, callback) {
+    setTimeout(function () {
+        callback(null, n * 3);
+    }, 10);
+}
+
+var add1mul3 = async.compose(mul3, add1);
+add1mul3(4, function (err, result) {
+    // result now equals 15
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) doUntil(iteratee, test, callbackopt) → {Promise}

+ + + + + +
+
import doUntil from 'async/doUntil';
+
+

Like 'doWhilst', except the test is inverted. Note the +argument ordering differs from until.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform after each +execution of iteratee. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of iteratee

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doWhilst(iteratee, test, callbackopt) → {Promise}

+ + + + + +
+
import doWhilst from 'async/doWhilst';
+
+

The post-check version of whilst. To reflect the difference in +the order of operations, the arguments test and iteratee are switched.

+

doWhilst is to whilst as do while is to while in plain JavaScript.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

A function which is called each time test +passes. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform after each +execution of iteratee. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. +callback will be passed an error and any arguments passed to the final +iteratee's callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) forever(fn, errbackopt) → {Promise}

+ + + + + +
+
import forever from 'async/forever';
+
+

Calls the asynchronous function fn with a callback parameter that allows it +to call itself again, in series, indefinitely. +If an error is passed to the callback then errback is called with the +error, and execution stops, otherwise it will never be called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function to call repeatedly. +Invoked with (next).

errback + + +function + + + + + + <optional> + +

when fn passes an error to it's callback, +this function will be called, and execution stops. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise that rejects if an error occurs and an errback +is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.forever(
+    function(next) {
+        // next is suitable for passing to things that need a callback(err [, whatever]);
+        // it will result in this function being called again.
+    },
+    function(err) {
+        // if next is called with a value in its first parameter, it will appear
+        // in here as 'err', and execution will stop.
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallel(tasks, callbackopt) → {Promise}

+ + + + + +
+
import parallel from 'async/parallel';
+
+

Run the tasks collection of functions in parallel, without waiting until +the previous function has completed. If any of the functions pass an error to +its callback, the main callback is immediately called with the value of the +error. Once the tasks have completed, the results are passed to the final +callback as an array.

+

Note: parallel is about kicking-off I/O tasks in parallel, not about +parallel execution of code. If your tasks do not use any timers or perform +any I/O, they will actually be executed in series. Any synchronous setup +sections for each task will happen one after the other. JavaScript remains +single-threaded.

+

Hint: Use reflect to continue the +execution of other tasks when a task fails.

+

It is also possible to use an object instead of an array. Each property will +be run as a function and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.parallel.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+], function(err, results) {
+    console.log(results);
+    // results is equal to ['one','two'] even though
+    // the second function had a shorter timeout.
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+});
+
+//Using Promises
+async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+]).then(results => {
+    console.log(results);
+    // results is equal to ['one','two'] even though
+    // the second function had a shorter timeout.
+}).catch(err => {
+    console.log(err);
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}).then(results => {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+}).catch(err => {
+    console.log(err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.parallel([
+            function(callback) {
+                setTimeout(function() {
+                    callback(null, 'one');
+                }, 200);
+            },
+            function(callback) {
+                setTimeout(function() {
+                    callback(null, 'two');
+                }, 100);
+            }
+        ]);
+        console.log(results);
+        // results is equal to ['one','two'] even though
+        // the second function had a shorter timeout.
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// an example using an object instead of an array
+async () => {
+    try {
+        let results = await async.parallel({
+            one: function(callback) {
+                setTimeout(function() {
+                    callback(null, 1);
+                }, 200);
+            },
+           two: function(callback) {
+                setTimeout(function() {
+                    callback(null, 2);
+                }, 100);
+           }
+        });
+        console.log(results);
+        // results is equal to: { one: 1, two: 2 }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallelLimit(tasks, limit, callbackopt) → {Promise}

+ + + + + +
+
import parallelLimit from 'async/parallelLimit';
+
+

The same as parallel but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

limit + + +number + + + + + +

The maximum number of async operations at a time.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) priorityQueue(worker, concurrency) → {QueueObject}

+ + + + + +
+
import priorityQueue from 'async/priorityQueue';
+
+

The same as async.queue only tasks are assigned a priority and +completed in ascending priority order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
worker + + +AsyncFunction + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). +Invoked with (task, callback).

concurrency + + +number + + + + + +

An integer for determining how many worker +functions should be run in parallel. If omitted, the concurrency defaults to +1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A priorityQueue object to manage the tasks. There are three +differences between queue and priorityQueue objects:

+
    +
  • push(task, priority, [callback]) - priority should be a number. If an +array of tasks is given, all tasks will be assigned the same priority.
  • +
  • pushAsync(task, priority, [callback]) - the same as priorityQueue.push, +except this returns a promise that rejects if an error occurs.
  • +
  • The unshift and unshiftAsync methods were removed.
  • +
+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) queue(worker, concurrencyopt) → {QueueObject}

+ + + + + +
+
import queue from 'async/queue';
+
+

Creates a queue object with the specified concurrency. Tasks added to the +queue are processed in parallel (up to the concurrency limit). If all +workers are in progress, the task is queued until one becomes available. +Once a worker completes a task, that task's callback is called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). Invoked with (task, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A queue object to manage the tasks. Callbacks can be +attached as certain properties to listen for specific events during the +lifecycle of the queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a queue object with concurrency 2
+var q = async.queue(function(task, callback) {
+    console.log('hello ' + task.name);
+    callback();
+}, 2);
+
+// assign a callback
+q.drain(function() {
+    console.log('all items have been processed');
+});
+// or await the end
+await q.drain()
+
+// assign an error callback
+q.error(function(err, task) {
+    console.error('task experienced an error');
+});
+
+// add some items to the queue
+q.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+// callback is optional
+q.push({name: 'bar'});
+
+// add some items to the queue (batch-wise)
+q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+    console.log('finished processing item');
+});
+
+// add some items to the front of the queue
+q.unshift({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) race(tasks, callback) → {Promise}

+ + + + + +
+
import race from 'async/race';
+
+

Runs the tasks array of functions in parallel, without waiting until the +previous function has completed. Once any of the tasks complete or pass an +error to its callback, the main callback is immediately called. It's +equivalent to Promise.race().

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array containing async functions +to run. Each function can complete with an optional result value.

callback + + +function + + + + + +

A callback to run once any of the functions have +completed. This function gets an error or result from the first function that +completed. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.race([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// main callback
+function(err, result) {
+    // the result will be equal to 'two' as it finishes earlier
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) retry(optsopt, task, callbackopt) → {Promise}

+ + + + + +
+
import retry from 'async/retry';
+
+

Attempts to get a successful response from task no more than times times +before returning an error. If the task is successful, the callback will be +passed the result of the successful task. If all attempts fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

Can be either an +object with times and interval or a number.

+
    +
  • times - The number of attempts to make before giving up. The default +is 5.
  • +
  • interval - The time to wait between retries, in milliseconds. The +default is 0. The interval may also be specified as a function of the +retry count (see example).
  • +
  • errorFilter - An optional synchronous function that is invoked on +erroneous result. If it returns true the retry attempts will continue; +if the function returns false the retry flow is aborted with the current +attempt's error and result being returned to the final callback. +Invoked with (err).
  • +
  • If opts is a number, the number specifies the number of times to retry, +with the default interval of 0.
  • +
task + + +AsyncFunction + + + + + + + +

An async function to retry. +Invoked with (callback).

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when the +task has succeeded, or after the final failed attempt. It receives the err +and result arguments of the last attempt at completing the task. Invoked +with (err, results).

+ + + + +
Returns:
+ + +
+

a promise if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// The `retry` function can be used as a stand-alone control flow by passing
+// a callback, as shown below:
+
+// try calling apiMethod 3 times
+async.retry(3, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 3 times, waiting 200 ms between each retry
+async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 10 times with exponential backoff
+// (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+async.retry({
+  times: 10,
+  interval: function(retryCount) {
+    return 50 * Math.pow(2, retryCount);
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod the default 5 times no delay between each retry
+async.retry(apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod only when error condition satisfies, all other
+// errors will abort the retry control flow and return to final callback
+async.retry({
+  errorFilter: function(err) {
+    return err.message === 'Temporary error'; // only retry on a specific error
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// to retry individual methods that are not as reliable within other
+// control flow functions, use the `retryable` wrapper:
+async.auto({
+    users: api.getUsers.bind(api),
+    payments: async.retryable(3, api.getPayments.bind(api))
+}, function(err, results) {
+    // do something with the results
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) retryable(optsopt, task) → {AsyncFunction}

+ + + + + +
+
import retryable from 'async/retryable';
+
+

A close relative of retry. This method +wraps a task and makes it retryable, rather than immediately calling it +with retries.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

optional +options, exactly the same as from retry, except for a opts.arity that +is the arity of the task function, defaulting to task.length

task + + +AsyncFunction + + + + + + + +

the asynchronous function to wrap. +This function will be passed any arguments passed to the returned wrapper. +Invoked with (...args, callback).

+ + + + +
Returns:
+ + +
+

The wrapped function, which when invoked, will +retry on an error, based on the parameters specified in opts. +This function will accept the same parameters as task.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.auto({
+    dep1: async.retryable(3, getFromFlakyService),
+    process: ["dep1", async.retryable(3, function (results, cb) {
+        maybeProcessData(results.dep1, cb);
+    })]
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) seq(…functions) → {function}

+ + + + + +
+
import seq from 'async/seq';
+
+

Version of the compose function that is more natural to read. Each function +consumes the return value of the previous function. It is the equivalent of +compose with the arguments reversed.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

a function that composes the functions in order

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// Requires lodash (or underscore), express3 and dresende's orm2.
+// Part of an app, that fetches cats of the logged user.
+// This example uses `seq` function to avoid overnesting and error
+// handling clutter.
+app.get('/cats', function(request, response) {
+    var User = request.models.User;
+    async.seq(
+        User.get.bind(User),  // 'User.get' has signature (id, callback(err, data))
+        function(user, fn) {
+            user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+        }
+    )(req.session.user_id, function (err, cats) {
+        if (err) {
+            console.error(err);
+            response.json({ status: 'error', message: err.message });
+        } else {
+            response.json({ status: 'ok', message: 'Cats found', data: cats });
+        }
+    });
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) series(tasks, callbackopt) → {Promise}

+ + + + + +
+
import series from 'async/series';
+
+

Run the functions in the tasks collection in series, each one running once +the previous function has completed. If any functions in the series pass an +error to its callback, no more functions are run, and callback is +immediately called with the value of the error. Otherwise, callback +receives an array of results when tasks have completed.

+

It is also possible to use an object instead of an array. Each property will +be run as a function, and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.series.

+

Note that while many implementations preserve the order of object +properties, the ECMAScript Language Specification +explicitly states that

+
+

The mechanics and order of enumerating the properties is not specified.

+
+

So if you rely on the order in which your series of functions are executed, +and want this to work on all platforms, consider using an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection containing +async functions to run in series. +Each function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This function gets a results array (or object) +containing all the result arguments passed to the task callbacks. Invoked +with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.series([
+    function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 'two');
+        }, 100);
+    }
+], function(err, results) {
+    console.log(results);
+    // results is equal to ['one','two']
+});
+
+// an example using objects instead of arrays
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+});
+
+//Using Promises
+async.series([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+]).then(results => {
+    console.log(results);
+    // results is equal to ['one','two']
+}).catch(err => {
+    console.log(err);
+});
+
+// an example using an object instead of an array
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 2);
+        }, 100);
+    }
+}).then(results => {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+}).catch(err => {
+    console.log(err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.series([
+            function(callback) {
+                setTimeout(function() {
+                    // do some async task
+                    callback(null, 'one');
+                }, 200);
+            },
+            function(callback) {
+                setTimeout(function() {
+                    // then do another async task
+                    callback(null, 'two');
+                }, 100);
+            }
+        ]);
+        console.log(results);
+        // results is equal to ['one','two']
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// an example using an object instead of an array
+async () => {
+    try {
+        let results = await async.parallel({
+            one: function(callback) {
+                setTimeout(function() {
+                    // do some async task
+                    callback(null, 1);
+                }, 200);
+            },
+           two: function(callback) {
+                setTimeout(function() {
+                    // then do another async task
+                    callback(null, 2);
+                }, 100);
+           }
+        });
+        console.log(results);
+        // results is equal to: { one: 1, two: 2 }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) times(n, iteratee, callback) → {Promise}

+ + + + + +
+
import times from 'async/times';
+
+

Calls the iteratee function n times, and accumulates results in the same +manner you would use with map.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// Pretend this is some complicated async factory
+var createUser = function(id, callback) {
+    callback(null, {
+        id: 'user' + id
+    });
+};
+
+// generate 5 users
+async.times(5, function(n, next) {
+    createUser(n, function(err, user) {
+        next(err, user);
+    });
+}, function(err, users) {
+    // we should now have 5 users
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesLimit(count, limit, iteratee, callback) → {Promise}

+ + + + + +
+
import timesLimit from 'async/timesLimit';
+
+

The same as times but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
count + + +number + + + + + +

The number of times to run the function.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see async.map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesSeries(n, iteratee, callback) → {Promise}

+ + + + + +
+
import timesSeries from 'async/timesSeries';
+
+

The same as times but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) tryEach(tasks, callbackopt) → {Promise}

+ + + + + +
+
import tryEach from 'async/tryEach';
+
+

It runs each task in series but stops whenever any of the functions were +successful. If one of the tasks were successful, the callback will be +passed the result of the successful task. If all tasks fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection containing functions to +run, each function is passed a callback(err, result) it must call on +completion with an error err (which can be null) and an optional result +value.

callback + + +function + + + + + + <optional> + +

An optional callback which is called when one +of the tasks has succeeded, or all have failed. It receives the err and +result arguments of the last attempt at completing the task. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.tryEach([
+    function getDataFromFirstWebsite(callback) {
+        // Try getting the data from the first website
+        callback(err, data);
+    },
+    function getDataFromSecondWebsite(callback) {
+        // First website failed,
+        // Try getting the data from the backup website
+        callback(err, data);
+    }
+],
+// optional callback
+function(err, results) {
+    Now do something with the data.
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) until(test, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import until from 'async/until';
+
+

Repeatedly call iteratee until test returns true. Calls callback when +stopped, or an error occurs. callback will be passed an error and any +arguments passed to the final iteratee's callback.

+

The inverse of whilst.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of iteratee. Invoked with (callback).

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
const results = []
+let finished = false
+async.until(function test(cb) {
+    cb(null, finished)
+}, function iter(next) {
+    fetchPage(url, (err, body) => {
+        if (err) return next(err)
+        results = results.concat(body.objects)
+        finished = !!body.next
+        next(err)
+    })
+}, function done (err) {
+    // all pages have been fetched
+})
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) waterfall(tasks, callbackopt) → {Promise}

+ + + + + +
+
import waterfall from 'async/waterfall';
+
+

Runs the tasks array of functions in series, each passing their results to +the next in the array. However, if any of the tasks pass an error to their +own callback, the next function is not executed, and the main callback is +immediately called with the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array of async functions +to run. +Each function should complete with any number of result values. +The result values will be passed as arguments, in order, to the next task.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This will be passed the results of the last task's +callback. Invoked with (err, [results]).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    function(callback) {
+        callback(null, 'one', 'two');
+    },
+    function(arg1, arg2, callback) {
+        // arg1 now equals 'one' and arg2 now equals 'two'
+        callback(null, 'three');
+    },
+    function(arg1, callback) {
+        // arg1 now equals 'three'
+        callback(null, 'done');
+    }
+], function (err, result) {
+    // result now equals 'done'
+});
+
+// Or, with named functions:
+async.waterfall([
+    myFirstFunction,
+    mySecondFunction,
+    myLastFunction,
+], function (err, result) {
+    // result now equals 'done'
+});
+function myFirstFunction(callback) {
+    callback(null, 'one', 'two');
+}
+function mySecondFunction(arg1, arg2, callback) {
+    // arg1 now equals 'one' and arg2 now equals 'two'
+    callback(null, 'three');
+}
+function myLastFunction(arg1, callback) {
+    // arg1 now equals 'three'
+    callback(null, 'done');
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) whilst(test, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import whilst from 'async/whilst';
+
+

Repeatedly call iteratee, while test returns true. Calls callback when +stopped, or an error occurs.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of iteratee. Invoked with (callback).

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
var count = 0;
+async.whilst(
+    function test(cb) { cb(null, count < 5); },
+    function iter(callback) {
+        count++;
+        setTimeout(function() {
+            callback(null, count);
+        }, 1000);
+    },
+    function (err, n) {
+        // 5 seconds have passed, n = 5
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + +

QueueObject

+ + + + +
+
import queue from 'async/queue';
+
+

A queue of tasks for the worker function to complete.

+
+ + + +
Type:
+
    +
  • + +Iterable + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

a function returning the number of items +waiting to be processed. Invoke with queue.length().

started + + +boolean + + + +

a boolean indicating whether or not any +items have been pushed and processed by the queue.

running + + +function + + + +

a function returning the number of items +currently being processed. Invoke with queue.running().

workersList + + +function + + + +

a function returning the array of items +currently being processed. Invoke with queue.workersList().

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke with queue.idle().

concurrency + + +number + + + +

an integer for determining how many worker +functions should be run in parallel. This property can be changed after a +queue is created to alter the concurrency on-the-fly.

payload + + +number + + + +

an integer that specifies how many items are +passed to the worker function at a time. only applies if this is a +cargo object

push + + +AsyncFunction + + + +

add a new task to the queue. Calls callback +once the worker has finished processing the task. Instead of a single task, +a tasks array can be submitted. The respective callback is used for every +task in the list. Invoke with queue.push(task, [callback]),

unshift + + +AsyncFunction + + + +

add a new task to the front of the queue. +Invoke with queue.unshift(task, [callback]).

pushAsync + + +AsyncFunction + + + +

the same as q.push, except this returns +a promise that rejects if an error occurs.

unshiftAsync + + +AsyncFunction + + + +

the same as q.unshift, except this returns +a promise that rejects if an error occurs.

remove + + +function + + + +

remove items from the queue that match a test +function. The test function will be passed an object with a data property, +and a priority property, if this is a +priorityQueue object. +Invoked with queue.remove(testFn), where testFn is of the form +function ({data, priority}) {} and returns a Boolean.

saturated + + +function + + + +

a function that sets a callback that is +called when the number of running workers hits the concurrency limit, and +further tasks will be queued. If the callback is omitted, q.saturated() +returns a promise for the next occurrence.

unsaturated + + +function + + + +

a function that sets a callback that is +called when the number of running workers is less than the concurrency & +buffer limits, and further tasks will not be queued. If the callback is +omitted, q.unsaturated() returns a promise for the next occurrence.

buffer + + +number + + + +

A minimum threshold buffer in order to say that +the queue is unsaturated.

empty + + +function + + + +

a function that sets a callback that is called +when the last item from the queue is given to a worker. If the callback +is omitted, q.empty() returns a promise for the next occurrence.

drain + + +function + + + +

a function that sets a callback that is called +when the last item from the queue has returned from the worker. If the +callback is omitted, q.drain() returns a promise for the next occurrence.

error + + +function + + + +

a function that sets a callback that is called +when a task errors. Has the signature function(error, task). If the +callback is omitted, error() returns a promise that rejects on the next +error.

paused + + +boolean + + + +

a boolean for determining whether the queue is +in a paused state.

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke with queue.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke with queue.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. No more tasks +should be pushed to the queue after calling this function. Invoke with queue.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
Example
+ +
const q = async.queue(worker, 2)
+q.push(item1)
+q.push(item2)
+q.push(item3)
+// queues are iterable, spread into an array to inspect
+const items = [...q] // [item1, item2, item3]
+// or use for of
+for (let item of q) {
+    console.log(item)
+}
+
+q.drain(() => {
+    console.log('all done')
+})
+// or
+await q.drain()
+ + + + + + + +
+ +
+ + + + + + +

Utils

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async utility functions.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) apply(fn) → {function}

+ + + + + +
+
import apply from 'async/apply';
+
+

Creates a continuation function with some arguments already applied.

+

Useful as a shorthand when combined with other control flow functions. Any +arguments passed to the returned function are added to the arguments +originally passed to apply.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function you want to eventually apply all +arguments to. Invokes with (arguments...).

arguments... + + +* + + + + + +

Any number of arguments to automatically apply +when the continuation is called.

+ + + + +
Returns:
+ + +
+

the partially-applied function

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// using apply
+async.parallel([
+    async.apply(fs.writeFile, 'testfile1', 'test1'),
+    async.apply(fs.writeFile, 'testfile2', 'test2')
+]);
+
+
+// the same process without using apply
+async.parallel([
+    function(callback) {
+        fs.writeFile('testfile1', 'test1', callback);
+    },
+    function(callback) {
+        fs.writeFile('testfile2', 'test2', callback);
+    }
+]);
+
+// It's possible to pass any number of additional arguments when calling the
+// continuation:
+
+node> var fn = async.apply(sys.puts, 'one');
+node> fn('two', 'three');
+one
+two
+three
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) asyncify(func) → {AsyncFunction}

+ + + + + +
+
import asyncify from 'async/asyncify';
+
+

Take a sync function and make it async, passing its return value to a +callback. This is useful for plugging sync functions into a waterfall, +series, or other async functions. Any arguments passed to the generated +function will be passed to the wrapped function (except for the final +callback argument). Errors thrown will be passed to the callback.

+

If the function passed to asyncify returns a Promise, that promises's +resolved/rejected state will be used to call the callback, rather than simply +the synchronous return value.

+

This also means you can asyncify ES2017 async functions.

+
+ + + +
+
Alias:
+
  • wrapSync
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
func + + +function + + + + + +

The synchronous function, or Promise-returning +function to convert to an AsyncFunction.

+ + + + +
Returns:
+ + +
+

An asynchronous wrapper of the func. To be +invoked with (args..., callback).

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
// passing a regular synchronous function
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(JSON.parse),
+    function (data, next) {
+        // data is the result of parsing the text.
+        // If there was a parsing error, it would have been caught.
+    }
+], callback);
+
+// passing a function returning a promise
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(function (contents) {
+        return db.model.create(contents);
+    }),
+    function (model, next) {
+        // `model` is the instantiated model object.
+        // If there was an error, this function would be skipped.
+    }
+], callback);
+
+// es2017 example, though `asyncify` is not needed if your JS environment
+// supports async functions out of the box
+var q = async.queue(async.asyncify(async function(file) {
+    var intermediateStep = await processFile(file);
+    return await somePromise(intermediateStep)
+}));
+
+q.push(files);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) constant() → {AsyncFunction}

+ + + + + +
+
import constant from 'async/constant';
+
+

Returns a function that when called, calls-back with the values provided. +Useful as the first function in a waterfall, or for plugging values in to +auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
arguments... + + +* + + + + + +

Any number of arguments to automatically invoke +callback with.

+ + + + +
Returns:
+ + +
+

Returns a function that when invoked, automatically +invokes the callback with the previous given arguments.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    async.constant(42),
+    function (value, next) {
+        // value === 42
+    },
+    //...
+], callback);
+
+async.waterfall([
+    async.constant(filename, "utf8"),
+    fs.readFile,
+    function (fileData, next) {
+        //...
+    }
+    //...
+], callback);
+
+async.auto({
+    hostname: async.constant("https://server.net/"),
+    port: findFreePort,
+    launchServer: ["hostname", "port", function (options, cb) {
+        startServer(options, cb);
+    }],
+    //...
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) dir(function)

+ + + + + +
+
import dir from 'async/dir';
+
+

Logs the result of an async function to the +console using console.dir to display the properties of the resulting object. +Only works in Node.js or in browsers that support console.dir and +console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, +console.dir is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, {hello: name});
+    }, 1000);
+};
+
+// in the node repl
+node> async.dir(hello, 'world');
+{hello: 'world'}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) ensureAsync(fn) → {AsyncFunction}

+ + + + + +
+
import ensureAsync from 'async/ensureAsync';
+
+

Wrap an async function and ensure it calls its callback on a later tick of +the event loop. If the function already calls its callback on a next tick, +no extra deferral is added. This is useful for preventing stack overflows +(RangeError: Maximum call stack size exceeded) and generally keeping +Zalgo +contained. ES2017 async functions are returned as-is -- they are immune +to Zalgo's corrupting influences, as they always resolve on a later tick.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function, one that expects a node-style +callback as its last argument.

+ + + + +
Returns:
+ + +
+

Returns a wrapped function with the exact same call +signature as the function passed in.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function sometimesAsync(arg, callback) {
+    if (cache[arg]) {
+        return callback(null, cache[arg]); // this would be synchronous!!
+    } else {
+        doSomeIO(arg, callback); // this IO would be asynchronous
+    }
+}
+
+// this has a risk of stack overflows if many results are cached in a row
+async.mapSeries(args, sometimesAsync, done);
+
+// this will defer sometimesAsync's callback if necessary,
+// preventing stack overflows
+async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) log(function)

+ + + + + +
+
import log from 'async/log';
+
+

Logs the result of an async function to the console. Only works in +Node.js or in browsers that support console.log and console.error (such +as FF and Chrome). If multiple arguments are returned from the async +function, console.log is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, 'hello ' + name);
+    }, 1000);
+};
+
+// in the node repl
+node> async.log(hello, 'world');
+'hello world'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) memoize(fn, hasher) → {AsyncFunction}

+ + + + + +
+
import memoize from 'async/memoize';
+
+

Caches the results of an async function. When creating a hash to store +function results against, the callback is omitted from the hash and an +optional hash function can be used.

+

Note: if the async function errs, the result will not be cached and +subsequent calls will call the wrapped function.

+

If no hash function is specified, the first argument is used as a hash key, +which may work reasonably if it is a string or a data type that converts to a +distinct string. Note that objects and arrays will not behave reasonably. +Neither will cases where the other arguments are significant. In such cases, +specify your own hash function.

+

The cache of results is exposed as the memo property of the function +returned by memoize.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function to proxy and cache results from.

hasher + + +function + + + + + +

An optional function for generating a custom hash +for storing results. It has all the arguments applied to it apart from the +callback, and must be synchronous.

+ + + + +
Returns:
+ + +
+

a memoized version of fn

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
var slow_fn = function(name, callback) {
+    // do something
+    callback(null, result);
+};
+var fn = async.memoize(slow_fn);
+
+// fn can now be used as if it were slow_fn
+fn('some name', function() {
+    // callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) nextTick(callback)

+ + + + + +
+
import nextTick from 'async/nextTick';
+
+

Calls callback on a later loop around the event loop. In Node.js this just +calls process.nextTick. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reflect(fn) → {function}

+ + + + + +
+
import reflect from 'async/reflect';
+
+

Wraps the async function in another function that always completes with a +result object, even when it errors.

+

The result object has either the property error or value.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function you want to wrap

+ + + + +
Returns:
+ + +
+
    +
  • A function that always passes null to it's callback as +the error. The second argument to the callback will be an object with +either an error or a value property.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.parallel([
+    async.reflect(function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff but error ...
+        callback('bad stuff happened');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    })
+],
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = 'bad stuff happened'
+    // results[2].value = 'two'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reflectAll(tasks) → {Array}

+ + + + + +
+
import reflectAll from 'async/reflectAll';
+
+

A helper function that wraps an array or an object of functions with reflect.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Object +| + +Iterable + + + + + +

The collection of +async functions to wrap in async.reflect.

+ + + + +
Returns:
+ + +
+

Returns an array of async functions, each wrapped in +async.reflect

+
+ + + +
+
+ Type +
+
+ +Array + + +
+
+ + + + +
Example
+ +
let tasks = [
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        // do some more stuff but error ...
+        callback(new Error('bad stuff happened'));
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+];
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = Error('bad stuff happened')
+    // results[2].value = 'two'
+});
+
+// an example using an object instead of an array
+let tasks = {
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    two: function(callback) {
+        callback('two');
+    },
+    three: function(callback) {
+        setTimeout(function() {
+            callback(null, 'three');
+        }, 100);
+    }
+};
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results.one.value = 'one'
+    // results.two.error = 'two'
+    // results.three.value = 'three'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) setImmediate(callback)

+ + + + + +
+
import setImmediate from 'async/setImmediate';
+
+

Calls callback on a later loop around the event loop. In Node.js this just +calls setImmediate. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timeout(asyncFn, milliseconds, infoopt) → {AsyncFunction}

+ + + + + +
+
import timeout from 'async/timeout';
+
+

Sets a time limit on an asynchronous function. If the function does not call +its callback within the specified milliseconds, it will be called with a +timeout error. The code property for the error object will be 'ETIMEDOUT'.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
asyncFn + + +AsyncFunction + + + + + +

The async function to limit in time.

milliseconds + + +number + + + + + +

The specified time limit.

info + + +* + + + + + + <optional> + +

Any variable you want attached (string, object, etc) +to timeout Error for more information..

+ + + + +
Returns:
+ + +
+

Returns a wrapped function that can be used with any +of the control flow functions. +Invoke this function with the same parameters as you would asyncFunc.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function myFunction(foo, callback) {
+    doAsyncTask(foo, function(err, data) {
+        // handle errors
+        if (err) return callback(err);
+
+        // do some stuff ...
+
+        // return processed data
+        return callback(null, data);
+    });
+}
+
+var wrapped = async.timeout(myFunction, 1000);
+
+// call `wrapped` as you would `myFunction`
+wrapped({ bar: 'bar' }, function(err, data) {
+    // if `myFunction` takes < 1000 ms to execute, `err`
+    // and `data` will have their expected values
+
+    // else `err` will be an Error with the code 'ETIMEDOUT'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) unmemoize(fn) → {AsyncFunction}

+ + + + + +
+
import unmemoize from 'async/unmemoize';
+
+

Undoes a memoized function, reverting it to the original, +unmemoized form. Handy for testing.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

the memoized function

+ + + + +
Returns:
+ + +
+

a function that calls the original unmemoized function

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/each.js.html b/docs/v3/each.js.html new file mode 100644 index 000000000..6166779f6 --- /dev/null +++ b/docs/v3/each.js.html @@ -0,0 +1,218 @@ + + + + + + + each.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

each.js

+ + + + + + + +
+
+
import eachOf from './eachOf.js'
+import withoutIndex from './internal/withoutIndex.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to
+ * each item in `coll`. Invoked with (item, callback).
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ * // dir4 does not exist
+ *
+ * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
+ * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
+ *
+ * // asynchronous function that deletes a file
+ * const deleteFile = function(file, callback) {
+ *     fs.unlink(file, callback);
+ * };
+ *
+ * // Using callbacks
+ * async.each(fileList, deleteFile, function(err) {
+ *     if( err ) {
+ *         console.log(err);
+ *     } else {
+ *         console.log('All files have been deleted successfully');
+ *     }
+ * });
+ *
+ * // Error Handling
+ * async.each(withMissingFileList, deleteFile, function(err){
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ *     // since dir4/file2.txt does not exist
+ *     // dir1/file1.txt could have been deleted
+ * });
+ *
+ * // Using Promises
+ * async.each(fileList, deleteFile)
+ * .then( () => {
+ *     console.log('All files have been deleted successfully');
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Error Handling
+ * async.each(fileList, deleteFile)
+ * .then( () => {
+ *     console.log('All files have been deleted successfully');
+ * }).catch( err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ *     // since dir4/file2.txt does not exist
+ *     // dir1/file1.txt could have been deleted
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         await async.each(files, deleteFile);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // Error Handling
+ * async () => {
+ *     try {
+ *         await async.each(withMissingFileList, deleteFile);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *         // since dir4/file2.txt does not exist
+ *         // dir1/file1.txt could have been deleted
+ *     }
+ * }
+ *
+ */
+function eachLimit(coll, iteratee, callback) {
+    return eachOf(coll, withoutIndex(wrapAsync(iteratee)), callback);
+}
+
+export default awaitify(eachLimit, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/eachLimit.js.html b/docs/v3/eachLimit.js.html new file mode 100644 index 000000000..694dbbd51 --- /dev/null +++ b/docs/v3/eachLimit.js.html @@ -0,0 +1,139 @@ + + + + + + + eachLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './internal/eachOfLimit.js'
+import withoutIndex from './internal/withoutIndex.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfLimit`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function eachLimit(coll, limit, iteratee, callback) {
+    return eachOfLimit(limit)(coll, withoutIndex(wrapAsync(iteratee)), callback);
+}
+export default awaitify(eachLimit, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/eachOf.js.html b/docs/v3/eachOf.js.html new file mode 100644 index 000000000..1edd79375 --- /dev/null +++ b/docs/v3/eachOf.js.html @@ -0,0 +1,265 @@ + + + + + + + eachOf.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOf.js

+ + + + + + + +
+
+
import isArrayLike from './internal/isArrayLike.js'
+import breakLoop from './internal/breakLoop.js'
+import eachOfLimit from './eachOfLimit.js'
+import once from './internal/once.js'
+import onlyOnce from './internal/onlyOnce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+    callback = once(callback);
+    var index = 0,
+        completed = 0,
+        {length} = coll,
+        canceled = false;
+    if (length === 0) {
+        callback(null);
+    }
+
+    function iteratorCallback(err, value) {
+        if (err === false) {
+            canceled = true
+        }
+        if (canceled === true) return
+        if (err) {
+            callback(err);
+        } else if ((++completed === length) || value === breakLoop) {
+            callback(null);
+        }
+    }
+
+    for (; index < length; index++) {
+        iteratee(coll[index], index, onlyOnce(iteratorCallback));
+    }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+function eachOfGeneric (coll, iteratee, callback) {
+    return eachOfLimit(coll, Infinity, iteratee, callback);
+}
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each
+ * item in `coll`.
+ * The `key` is the item's key, or index in the case of an array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ * @example
+ *
+ * // dev.json is a file containing a valid json object config for dev environment
+ * // dev.json is a file containing a valid json object config for test environment
+ * // prod.json is a file containing a valid json object config for prod environment
+ * // invalid.json is a file with a malformed json object
+ *
+ * let configs = {}; //global variable
+ * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'};
+ * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'};
+ *
+ * // asynchronous function that reads a json file and parses the contents as json object
+ * function parseFile(file, key, callback) {
+ *     fs.readFile(file, "utf8", function(err, data) {
+ *         if (err) return calback(err);
+ *         try {
+ *             configs[key] = JSON.parse(data);
+ *         } catch (e) {
+ *             return callback(e);
+ *         }
+ *         callback();
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.forEachOf(validConfigFileMap, parseFile, function (err) {
+ *     if (err) {
+ *         console.error(err);
+ *     } else {
+ *         console.log(configs);
+ *         // configs is now a map of JSON data, e.g.
+ *         // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+ *     }
+ * });
+ *
+ * //Error handing
+ * async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
+ *     if (err) {
+ *         console.error(err);
+ *         // JSON parse error exception
+ *     } else {
+ *         console.log(configs);
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.forEachOf(validConfigFileMap, parseFile)
+ * .then( () => {
+ *     console.log(configs);
+ *     // configs is now a map of JSON data, e.g.
+ *     // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+ * }).catch( err => {
+ *     console.error(err);
+ * });
+ *
+ * //Error handing
+ * async.forEachOf(invalidConfigFileMap, parseFile)
+ * .then( () => {
+ *     console.log(configs);
+ * }).catch( err => {
+ *     console.error(err);
+ *     // JSON parse error exception
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.forEachOf(validConfigFileMap, parseFile);
+ *         console.log(configs);
+ *         // configs is now a map of JSON data, e.g.
+ *         // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * //Error handing
+ * async () => {
+ *     try {
+ *         let result = await async.forEachOf(invalidConfigFileMap, parseFile);
+ *         console.log(configs);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // JSON parse error exception
+ *     }
+ * }
+ *
+ */
+function eachOf(coll, iteratee, callback) {
+    var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
+    return eachOfImplementation(coll, wrapAsync(iteratee), callback);
+}
+
+export default awaitify(eachOf, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/eachOfLimit.js.html b/docs/v3/eachOfLimit.js.html new file mode 100644 index 000000000..ec6014269 --- /dev/null +++ b/docs/v3/eachOfLimit.js.html @@ -0,0 +1,139 @@ + + + + + + + eachOfLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOfLimit.js

+ + + + + + + +
+
+
import _eachOfLimit from './internal/eachOfLimit.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+    return _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
+}
+
+export default awaitify(eachOfLimit, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/eachOfSeries.js.html b/docs/v3/eachOfSeries.js.html new file mode 100644 index 000000000..36ca6f705 --- /dev/null +++ b/docs/v3/eachOfSeries.js.html @@ -0,0 +1,134 @@ + + + + + + + eachOfSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachOfSeries.js

+ + + + + + + +
+
+
import eachOfLimit from './eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function eachOfSeries(coll, iteratee, callback) {
+    return eachOfLimit(coll, 1, iteratee, callback)
+}
+export default awaitify(eachOfSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/eachSeries.js.html b/docs/v3/eachSeries.js.html new file mode 100644 index 000000000..35fd1e8c7 --- /dev/null +++ b/docs/v3/eachSeries.js.html @@ -0,0 +1,139 @@ + + + + + + + eachSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

eachSeries.js

+ + + + + + + +
+
+
import eachLimit from './eachLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item
+ * in series and therefore the iteratee functions will complete in order.
+
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfSeries`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @returns {Promise} a promise, if a callback is omitted
+ */
+function eachSeries(coll, iteratee, callback) {
+    return eachLimit(coll, 1, iteratee, callback)
+}
+export default awaitify(eachSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/ensureAsync.js.html b/docs/v3/ensureAsync.js.html new file mode 100644 index 000000000..b5103a098 --- /dev/null +++ b/docs/v3/ensureAsync.js.html @@ -0,0 +1,163 @@ + + + + + + + ensureAsync.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

ensureAsync.js

+ + + + + + + +
+
+
import setImmediate from './internal/setImmediate.js'
+import { isAsync } from './internal/wrapAsync.js'
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop.  If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained. ES2017 `async` functions are returned as-is -- they are immune
+ * to Zalgo's corrupting influences, as they always resolve on a later tick.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {AsyncFunction} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ *     if (cache[arg]) {
+ *         return callback(null, cache[arg]); // this would be synchronous!!
+ *     } else {
+ *         doSomeIO(arg, callback); // this IO would be asynchronous
+ *     }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+export default function ensureAsync(fn) {
+    if (isAsync(fn)) return fn;
+    return function (...args/*, callback*/) {
+        var callback = args.pop()
+        var sync = true;
+        args.push((...innerArgs) => {
+            if (sync) {
+                setImmediate(() => callback(...innerArgs));
+            } else {
+                callback(...innerArgs);
+            }
+        });
+        fn.apply(this, args);
+        sync = false;
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/every.js.html b/docs/v3/every.js.html new file mode 100644 index 000000000..15b996f77 --- /dev/null +++ b/docs/v3/every.js.html @@ -0,0 +1,211 @@ + + + + + + + every.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

every.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ * // dir4 does not exist
+ *
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
+ * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ *    fs.access(file, fs.constants.F_OK, (err) => {
+ *        callback(null, !err);
+ *    });
+ * }
+ *
+ * // Using callbacks
+ * async.every(fileList, fileExists, function(err, result) {
+ *     console.log(result);
+ *     // true
+ *     // result is true since every file exists
+ * });
+ *
+ * async.every(withMissingFileList, fileExists, function(err, result) {
+ *     console.log(result);
+ *     // false
+ *     // result is false since NOT every file exists
+ * });
+ *
+ * // Using Promises
+ * async.every(fileList, fileExists)
+ * .then( result => {
+ *     console.log(result);
+ *     // true
+ *     // result is true since every file exists
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * async.every(withMissingFileList, fileExists)
+ * .then( result => {
+ *     console.log(result);
+ *     // false
+ *     // result is false since NOT every file exists
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.every(fileList, fileExists);
+ *         console.log(result);
+ *         // true
+ *         // result is true since every file exists
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * async () => {
+ *     try {
+ *         let result = await async.every(withMissingFileList, fileExists);
+ *         console.log(result);
+ *         // false
+ *         // result is false since NOT every file exists
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+function every(coll, iteratee, callback) {
+    return createTester(bool => !bool, res => !res)(eachOf, coll, iteratee, callback)
+}
+export default awaitify(every, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/everyLimit.js.html b/docs/v3/everyLimit.js.html new file mode 100644 index 000000000..84f488dcc --- /dev/null +++ b/docs/v3/everyLimit.js.html @@ -0,0 +1,138 @@ + + + + + + + everyLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

everyLimit.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ */
+function everyLimit(coll, limit, iteratee, callback) {
+    return createTester(bool => !bool, res => !res)(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(everyLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/everySeries.js.html b/docs/v3/everySeries.js.html new file mode 100644 index 000000000..e04af695f --- /dev/null +++ b/docs/v3/everySeries.js.html @@ -0,0 +1,137 @@ + + + + + + + everySeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

everySeries.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfSeries from './eachOfSeries.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in series.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ */
+function everySeries(coll, iteratee, callback) {
+    return createTester(bool => !bool, res => !res)(eachOfSeries, coll, iteratee, callback)
+}
+export default awaitify(everySeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/favicon.ico b/docs/v3/favicon.ico new file mode 100755 index 000000000..4a90dff47 Binary files /dev/null and b/docs/v3/favicon.ico differ diff --git a/docs/v3/filter.js.html b/docs/v3/filter.js.html new file mode 100644 index 000000000..ae6b14516 --- /dev/null +++ b/docs/v3/filter.js.html @@ -0,0 +1,185 @@ + + + + + + + filter.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filter.js

+ + + + + + + +
+
+
import _filter from './internal/filter.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback provided
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ *
+ * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ *    fs.access(file, fs.constants.F_OK, (err) => {
+ *        callback(null, !err);
+ *    });
+ * }
+ *
+ * // Using callbacks
+ * async.filter(files, fileExists, function(err, results) {
+ *    if(err) {
+ *        console.log(err);
+ *    } else {
+ *        console.log(results);
+ *        // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+ *        // results is now an array of the existing files
+ *    }
+ * });
+ *
+ * // Using Promises
+ * async.filter(files, fileExists)
+ * .then(results => {
+ *     console.log(results);
+ *     // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+ *     // results is now an array of the existing files
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.filter(files, fileExists);
+ *         console.log(results);
+ *         // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+ *         // results is now an array of the existing files
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+function filter (coll, iteratee, callback) {
+    return _filter(eachOf, coll, iteratee, callback)
+}
+export default awaitify(filter, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/filterLimit.js.html b/docs/v3/filterLimit.js.html new file mode 100644 index 000000000..47ad1bbd1 --- /dev/null +++ b/docs/v3/filterLimit.js.html @@ -0,0 +1,137 @@ + + + + + + + filterLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filterLimit.js

+ + + + + + + +
+
+
import _filter from './internal/filter.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback provided
+ */
+function filterLimit (coll, limit, iteratee, callback) {
+    return _filter(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(filterLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/filterSeries.js.html b/docs/v3/filterSeries.js.html new file mode 100644 index 000000000..17d91b1c1 --- /dev/null +++ b/docs/v3/filterSeries.js.html @@ -0,0 +1,135 @@ + + + + + + + filterSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

filterSeries.js

+ + + + + + + +
+
+
import _filter from './internal/filter.js'
+import eachOfSeries from './eachOfSeries.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ * @returns {Promise} a promise, if no callback provided
+ */
+function filterSeries (coll, iteratee, callback) {
+    return _filter(eachOfSeries, coll, iteratee, callback)
+}
+export default awaitify(filterSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Bold-webfont.eot b/docs/v3/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 000000000..5d20d9163 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Bold-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-Bold-webfont.svg b/docs/v3/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 000000000..3ed7be4bc --- /dev/null +++ b/docs/v3/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Bold-webfont.woff b/docs/v3/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 000000000..1205787b0 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Bold-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-BoldItalic-webfont.eot b/docs/v3/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 000000000..1f639a15f Binary files /dev/null and b/docs/v3/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-BoldItalic-webfont.svg b/docs/v3/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 000000000..6a2607b9d --- /dev/null +++ b/docs/v3/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-BoldItalic-webfont.woff b/docs/v3/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 000000000..ed760c062 Binary files /dev/null and b/docs/v3/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-Italic-webfont.eot b/docs/v3/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 000000000..0c8a0ae06 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Italic-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-Italic-webfont.svg b/docs/v3/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 000000000..e1075dcc2 --- /dev/null +++ b/docs/v3/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Italic-webfont.woff b/docs/v3/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 000000000..ff652e643 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Italic-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-Light-webfont.eot b/docs/v3/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 000000000..14868406a Binary files /dev/null and b/docs/v3/fonts/OpenSans-Light-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-Light-webfont.svg b/docs/v3/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 000000000..11a472ca8 --- /dev/null +++ b/docs/v3/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Light-webfont.woff b/docs/v3/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 000000000..e78607481 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Light-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-LightItalic-webfont.eot b/docs/v3/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 000000000..8f445929f Binary files /dev/null and b/docs/v3/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-LightItalic-webfont.svg b/docs/v3/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 000000000..431d7e354 --- /dev/null +++ b/docs/v3/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-LightItalic-webfont.woff b/docs/v3/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 000000000..43e8b9e6c Binary files /dev/null and b/docs/v3/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-Regular-webfont.eot b/docs/v3/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 000000000..6bbc3cf58 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Regular-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-Regular-webfont.svg b/docs/v3/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 000000000..25a395234 --- /dev/null +++ b/docs/v3/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Regular-webfont.woff b/docs/v3/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 000000000..e231183dc Binary files /dev/null and b/docs/v3/fonts/OpenSans-Regular-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-Semibold-webfont.eot b/docs/v3/fonts/OpenSans-Semibold-webfont.eot new file mode 100755 index 000000000..d8375dd0a Binary files /dev/null and b/docs/v3/fonts/OpenSans-Semibold-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-Semibold-webfont.svg b/docs/v3/fonts/OpenSans-Semibold-webfont.svg new file mode 100755 index 000000000..eec4db8bd --- /dev/null +++ b/docs/v3/fonts/OpenSans-Semibold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-Semibold-webfont.ttf b/docs/v3/fonts/OpenSans-Semibold-webfont.ttf new file mode 100755 index 000000000..b3290843a Binary files /dev/null and b/docs/v3/fonts/OpenSans-Semibold-webfont.ttf differ diff --git a/docs/v3/fonts/OpenSans-Semibold-webfont.woff b/docs/v3/fonts/OpenSans-Semibold-webfont.woff new file mode 100755 index 000000000..28d6adee0 Binary files /dev/null and b/docs/v3/fonts/OpenSans-Semibold-webfont.woff differ diff --git a/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.eot b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.eot new file mode 100755 index 000000000..0ab1db22e Binary files /dev/null and b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.eot differ diff --git a/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.svg b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.svg new file mode 100755 index 000000000..7166ec1b9 --- /dev/null +++ b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.ttf b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.ttf new file mode 100755 index 000000000..d2d6318f6 Binary files /dev/null and b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.ttf differ diff --git a/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.woff b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.woff new file mode 100755 index 000000000..d4dfca402 Binary files /dev/null and b/docs/v3/fonts/OpenSans-SemiboldItalic-webfont.woff differ diff --git a/docs/v3/forever.js.html b/docs/v3/forever.js.html new file mode 100644 index 000000000..fef302846 --- /dev/null +++ b/docs/v3/forever.js.html @@ -0,0 +1,157 @@ + + + + + + + forever.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

forever.js

+ + + + + + + +
+
+
import onlyOnce from './internal/onlyOnce.js'
+import ensureAsync from './ensureAsync.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the callback then `errback` is called with the
+ * error, and execution stops, otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} fn - an async function to call repeatedly.
+ * Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @returns {Promise} a promise that rejects if an error occurs and an errback
+ * is not passed
+ * @example
+ *
+ * async.forever(
+ *     function(next) {
+ *         // next is suitable for passing to things that need a callback(err [, whatever]);
+ *         // it will result in this function being called again.
+ *     },
+ *     function(err) {
+ *         // if next is called with a value in its first parameter, it will appear
+ *         // in here as 'err', and execution will stop.
+ *     }
+ * );
+ */
+function forever(fn, errback) {
+    var done = onlyOnce(errback);
+    var task = wrapAsync(ensureAsync(fn));
+
+    function next(err) {
+        if (err) return done(err);
+        if (err === false) return;
+        task(next);
+    }
+    return next();
+}
+export default awaitify(forever, 2)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/global.html b/docs/v3/global.html new file mode 100644 index 000000000..393446844 --- /dev/null +++ b/docs/v3/global.html @@ -0,0 +1,300 @@ + + + + + + + Global - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Global

+ + + + + + + +
+ +
+ +

+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + + + + +

AsyncFunction()

+ + + + + +
+

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. +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, +because the async function will be compiled to an ordinary function that +returns a promise.

+
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/groupBy.js.html b/docs/v3/groupBy.js.html new file mode 100644 index 000000000..73796717b --- /dev/null +++ b/docs/v3/groupBy.js.html @@ -0,0 +1,205 @@ + + + + + + + groupBy.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupBy.js

+ + + + + + + +
+
+
import groupByLimit from './groupByLimit.js'
+
+/**
+ * Returns a new object, where each value corresponds to an array of items, from
+ * `coll`, that returned the corresponding key. That is, the keys of the object
+ * correspond to the values passed to the `iteratee` callback.
+ *
+ * Note: Since this function applies the `iteratee` to each item in parallel,
+ * there is no guarantee that the `iteratee` functions will complete in order.
+ * However, the values for each key in the `result` will be in the same order as
+ * the original `coll`. For Objects, the values will roughly be in the order of
+ * the original Objects' keys (but this can vary across JavaScript engines).
+ *
+ * @name groupBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ * // dir4 does not exist
+ *
+ * const files = ['dir1/file1.txt','dir2','dir4']
+ *
+ * // asynchronous function that detects file type as none, file, or directory
+ * function detectFile(file, callback) {
+ *     fs.stat(file, function(err, stat) {
+ *         if (err) {
+ *             return callback(null, 'none');
+ *         }
+ *         callback(null, stat.isDirectory() ? 'directory' : 'file');
+ *     });
+ * }
+ *
+ * //Using callbacks
+ * async.groupBy(files, detectFile, function(err, result) {
+ *     if(err) {
+ *         console.log(err);
+ *     } else {
+ *	       console.log(result);
+ *         // {
+ *         //     file: [ 'dir1/file1.txt' ],
+ *         //     none: [ 'dir4' ],
+ *         //     directory: [ 'dir2']
+ *         // }
+ *         // result is object containing the files grouped by type
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.groupBy(files, detectFile)
+ * .then( result => {
+ *     console.log(result);
+ *     // {
+ *     //     file: [ 'dir1/file1.txt' ],
+ *     //     none: [ 'dir4' ],
+ *     //     directory: [ 'dir2']
+ *     // }
+ *     // result is object containing the files grouped by type
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.groupBy(files, detectFile);
+ *         console.log(result);
+ *         // {
+ *         //     file: [ 'dir1/file1.txt' ],
+ *         //     none: [ 'dir4' ],
+ *         //     directory: [ 'dir2']
+ *         // }
+ *         // result is object containing the files grouped by type
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+export default function groupBy (coll, iteratee, callback) {
+    return groupByLimit(coll, Infinity, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/groupByLimit.js.html b/docs/v3/groupByLimit.js.html new file mode 100644 index 000000000..8ea3fbb1c --- /dev/null +++ b/docs/v3/groupByLimit.js.html @@ -0,0 +1,163 @@ + + + + + + + groupByLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupByLimit.js

+ + + + + + + +
+
+
import mapLimit from './mapLimit.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name groupByLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function groupByLimit(coll, limit, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    return mapLimit(coll, limit, (val, iterCb) => {
+        _iteratee(val, (err, key) => {
+            if (err) return iterCb(err);
+            return iterCb(err, {key, val});
+        });
+    }, (err, mapResults) => {
+        var result = {};
+        // from MDN, handle object having an `hasOwnProperty` prop
+        var {hasOwnProperty} = Object.prototype;
+
+        for (var i = 0; i < mapResults.length; i++) {
+            if (mapResults[i]) {
+                var {key} = mapResults[i];
+                var {val} = mapResults[i];
+
+                if (hasOwnProperty.call(result, key)) {
+                    result[key].push(val);
+                } else {
+                    result[key] = [val];
+                }
+            }
+        }
+
+        return callback(err, result);
+    });
+}
+
+export default awaitify(groupByLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/groupBySeries.js.html b/docs/v3/groupBySeries.js.html new file mode 100644 index 000000000..12f074c2f --- /dev/null +++ b/docs/v3/groupBySeries.js.html @@ -0,0 +1,133 @@ + + + + + + + groupBySeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

groupBySeries.js

+ + + + + + + +
+
+
import groupByLimit from './groupByLimit.js'
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
+ *
+ * @name groupBySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whose
+ * properties are arrays of values which returned the corresponding key.
+ * @returns {Promise} a promise, if no callback is passed
+ */
+export default function groupBySeries (coll, iteratee, callback) {
+    return groupByLimit(coll, 1, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/img/async-logo.svg b/docs/v3/img/async-logo.svg new file mode 100644 index 000000000..d108be788 --- /dev/null +++ b/docs/v3/img/async-logo.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/index.html b/docs/v3/index.html new file mode 100644 index 000000000..43bcf3b3c --- /dev/null +++ b/docs/v3/index.html @@ -0,0 +1,340 @@ + + + + + + + Home - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +
+

Async Logo

+

Build Status via Travis CI +NPM version +Coverage Status +Join the chat at https:gitter.im/caolan/async

+

For Async v1.5.x documentation, go HERE

+

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via npm i async, +it can also be used directly in the browser.

+

Async is also installable via:

+
    +
  • yarn: yarn add async
  • +
+

Async provides around 70 functions that include the usual 'functional' +suspects (map, reduce, filter, each…) as well as some common patterns +for asynchronous control flow (parallel, series, waterfall…). All these +functions assume you follow the Node.js convention of providing a single +callback as the last argument of your asynchronous function -- a callback which expects an Error as its first argument -- and calling the callback once.

+

You can also pass async functions to Async methods, instead of callback-accepting functions. For more information, see AsyncFunction

+

Quick Examples

+
async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+    // results is now an array of stats for each file
+});
+
+async.filter(['file1','file2','file3'], function(filePath, callback) {
+  fs.access(filePath, function(err) {
+    callback(null, !err)
+  });
+}, function(err, results) {
+    // results now equals an array of the existing files
+});
+
+async.parallel([
+    function(callback) { ... },
+    function(callback) { ... }
+], function(err, results) {
+    // optional callback
+});
+
+async.series([
+    function(callback) { ... },
+    function(callback) { ... }
+]);
+
+

There are many more functions available so take a look at the docs below for a +full list. This module aims to be comprehensive, so if you feel anything is +missing please create a GitHub issue for it.

+

Common Pitfalls (StackOverflow)

+

Synchronous iteration functions

+

If you get an error like RangeError: Maximum call stack size exceeded. or other stack overflow issues when using async, you are likely using a synchronous iteratee. By synchronous we mean a function that calls its callback on the same tick in the javascript event loop, without doing any I/O or using any timers. Calling many callbacks iteratively will quickly overflow the stack. If you run into this issue, just defer your callback with async.setImmediate to start a new call stack on the next tick of the event loop.

+

This can also arise by accident if you callback early in certain cases:

+
async.eachSeries(hugeArray, function iteratee(item, callback) {
+    if (inCache(item)) {
+        callback(null, cache[item]); // if many items are cached, you'll overflow
+    } else {
+        doSomeIO(item, callback);
+    }
+}, function done() {
+    //...
+});
+
+

Just change it to:

+
async.eachSeries(hugeArray, function iteratee(item, callback) {
+    if (inCache(item)) {
+        async.setImmediate(function() {
+            callback(null, cache[item]);
+        });
+    } else {
+        doSomeIO(item, callback);
+        //...
+    }
+});
+
+

Async does not guard against synchronous iteratees for performance reasons. If you are still running into stack overflows, you can defer as suggested above, or wrap functions with async.ensureAsync Functions that are asynchronous by their nature do not have this problem and don't need the extra callback deferral.

+

If JavaScript's event loop is still a bit nebulous, check out this article or this talk for more detailed information about how it works.

+

Multiple callbacks

+

Make sure to always return when calling a callback early, otherwise you will cause multiple callbacks and unpredictable behavior in many cases.

+
async.waterfall([
+    function(callback) {
+        getSomething(options, function (err, result) {
+            if (err) {
+                callback(new Error("failed getting something:" + err.message));
+                // we should return here
+            }
+            // since we did not return, this callback still will be called and
+            // `processData` will be called twice
+            callback(null, result);
+        });
+    },
+    processData
+], done)
+
+

It is always good practice to return callback(err, result) whenever a callback call is not the last statement of a function.

+

Using ES2017 async functions

+

Async accepts async functions wherever we accept a Node-style callback function. However, we do not pass them a callback, and instead use the return value and handle any promise rejections or errors thrown.

+
async.mapLimit(files, 10, async file => { // <- no callback!
+    const text = await util.promisify(fs.readFile)(dir + file, 'utf8')
+    const body = JSON.parse(text) // <- a parse error here will be caught automatically
+    if (!(await checkValidity(body))) {
+        throw new Error(`${file} has invalid contents`) // <- this error will also be caught
+    }
+    return body // <- return a value!
+}, (err, contents) => {
+    if (err) throw err
+    console.log(contents)
+})
+
+

We can only detect native async functions, not transpiled versions (e.g. with Babel). Otherwise, you can wrap async functions in async.asyncify().

+

Binding a context to an iteratee

+

This section is really about bind, not about Async. If you are wondering how to +make Async execute your iteratees in a given context, or are confused as to why +a method of another library isn't working as an iteratee, study this example:

+
// Here is a simple object with an (unnecessarily roundabout) squaring method
+var AsyncSquaringLibrary = {
+    squareExponent: 2,
+    square: function(number, callback){
+        var result = Math.pow(number, this.squareExponent);
+        setTimeout(function(){
+            callback(null, result);
+        }, 200);
+    }
+};
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result) {
+    // result is [NaN, NaN, NaN]
+    // This fails because the `this.squareExponent` expression in the square
+    // function is not evaluated in the context of AsyncSquaringLibrary, and is
+    // therefore undefined.
+});
+
+async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result) {
+    // result is [1, 4, 9]
+    // With the help of bind we can attach a context to the iteratee before
+    // passing it to Async. Now the square function will be executed in its
+    // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`
+    // will be as expected.
+});
+
+

Subtle Memory Leaks

+

There are cases where you might want to exit early from async flow, when calling an Async method inside another async function:

+
function myFunction (args, outerCallback) {
+    async.waterfall([
+        //...
+        function (arg, next) {
+            if (someImportantCondition()) {
+                return outerCallback(null)
+            }
+        },
+        function (arg, next) {/*...*/}
+    ], function done (err) {
+        //...
+    })
+}
+
+

Something happened in a waterfall where you want to skip the rest of the execution, so you call an outer callack. However, Async will still wait for that inner next callback to be called, leaving some closure scope allocated.

+

As of version 3.0, you can call any Async callback with false as the error argument, and the rest of the execution of the Async method will be stopped or ignored.

+
        function (arg, next) {
+            if (someImportantCondition()) {
+                outerCallback(null)
+                return next(false) // ← signal that you called an outer callback
+            }
+        },
+
+

Mutating collections while processing them

+

If you pass an array to a collection method (such as each, mapLimit, or filterSeries), and then attempt to push, pop, or splice additional items on to the array, this could lead to unexpected or undefined behavior. Async will iterate until the original length of the array is met, and the indexes of items pop()ed or splice()d could already have been processed. Therefore, it is not recommended to modify the array after Async has begun iterating over it. If you do need to push, pop, or splice, use a queue instead.

+

Download

+

The source is available for download from +GitHub. +Alternatively, you can install using npm:

+
$ npm i async
+
+

You can then require() async as normal:

+
var async = require("async");
+
+

Or require individual methods:

+
var waterfall = require("async/waterfall");
+var map = require("async/map");
+
+

Development: async.js - 29.6kb Uncompressed

+

In the Browser

+

Async should work in any ES2015 environment (Node 6+ and all modern browsers).

+

If you want to use Async in an older environment, (e.g. Node 4, IE11) you will have to transpile.

+

Usage:

+
<script type="text/javascript" src="async.js"></script>
+<script type="text/javascript">
+
+    async.map(data, asyncProcess, function(err, results) {
+        alert(results);
+    });
+
+</script>
+
+

The portable versions of Async, including async.js and async.min.js, are +included in the /dist folder. Async can also be found on the jsDelivr CDN.

+

ES Modules

+

Async includes a .mjs version that should automatically be used by compatible bundlers such as Webpack or Rollup, anything that uses the module field of the package.json.

+

We also provide Async as a collection of purely ES2015 modules, in an alternative async-es package on npm.

+
$ npm install async-es
+
+
import waterfall from 'async-es/waterfall';
+import async from 'async-es';
+
+

Typescript

+

There are third-party type definitions for Async.

+
npm i -D @types/async
+
+

It is recommended to target ES2017 or higher in your tsconfig.json, so async functions are preserved:

+
{
+  "compilerOptions": {
+    "target": "es2017"
+  }
+}
+
+

Other Libraries

+
    +
  • limiter a package for rate-limiting based on requests per sec/hour.
  • +
  • neo-async an altername implementation of Async, focusing on speed.
  • +
  • co-async a library inspired by Async for use with co and generator functions.
  • +
  • promise-async a version of Async where all the methods are Promisified.
  • +
  • 'modern-async' an alternative to Async using only async/await and promises.
  • +
+
+ + + + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/index.js.html b/docs/v3/index.js.html new file mode 100644 index 000000000..cb4d55e45 --- /dev/null +++ b/docs/v3/index.js.html @@ -0,0 +1,467 @@ + + + + + + + index.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

index.js

+ + + + + + + +
+
+
/**
+ * 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
+ */
+
+import apply from './apply'
+import applyEach from './applyEach'
+import applyEachSeries from './applyEachSeries'
+import asyncify from './asyncify'
+import auto from './auto'
+import autoInject from './autoInject'
+import cargo from './cargo'
+import cargoQueue from './cargoQueue'
+import compose from './compose'
+import concat from './concat'
+import concatLimit from './concatLimit'
+import concatSeries from './concatSeries'
+import constant from './constant'
+import detect from './detect'
+import detectLimit from './detectLimit'
+import detectSeries from './detectSeries'
+import dir from './dir'
+import doUntil from './doUntil'
+import doWhilst from './doWhilst'
+import each from './each'
+import eachLimit from './eachLimit'
+import eachOf from './eachOf'
+import eachOfLimit from './eachOfLimit'
+import eachOfSeries from './eachOfSeries'
+import eachSeries from './eachSeries'
+import ensureAsync from './ensureAsync'
+import every from './every'
+import everyLimit from './everyLimit'
+import everySeries from './everySeries'
+import filter from './filter'
+import filterLimit from './filterLimit'
+import filterSeries from './filterSeries'
+import forever from './forever'
+import groupBy from './groupBy'
+import groupByLimit from './groupByLimit'
+import groupBySeries from './groupBySeries'
+import log from './log'
+import map from './map'
+import mapLimit from './mapLimit'
+import mapSeries from './mapSeries'
+import mapValues from './mapValues'
+import mapValuesLimit from './mapValuesLimit'
+import mapValuesSeries from './mapValuesSeries'
+import memoize from './memoize'
+import nextTick from './nextTick'
+import parallel from './parallel'
+import parallelLimit from './parallelLimit'
+import priorityQueue from './priorityQueue'
+import queue from './queue'
+import race from './race'
+import reduce from './reduce'
+import reduceRight from './reduceRight'
+import reflect from './reflect'
+import reflectAll from './reflectAll'
+import reject from './reject'
+import rejectLimit from './rejectLimit'
+import rejectSeries from './rejectSeries'
+import retry from './retry'
+import retryable from './retryable'
+import seq from './seq'
+import series from './series'
+import setImmediate from './setImmediate'
+import some from './some'
+import someLimit from './someLimit'
+import someSeries from './someSeries'
+import sortBy from './sortBy'
+import timeout from './timeout'
+import times from './times'
+import timesLimit from './timesLimit'
+import timesSeries from './timesSeries'
+import transform from './transform'
+import tryEach from './tryEach'
+import unmemoize from './unmemoize'
+import until from './until'
+import waterfall from './waterfall'
+import whilst from './whilst'
+
+export default {
+    apply,
+    applyEach,
+    applyEachSeries,
+    asyncify,
+    auto,
+    autoInject,
+    cargo,
+    cargoQueue,
+    compose,
+    concat,
+    concatLimit,
+    concatSeries,
+    constant,
+    detect,
+    detectLimit,
+    detectSeries,
+    dir,
+    doUntil,
+    doWhilst,
+    each,
+    eachLimit,
+    eachOf,
+    eachOfLimit,
+    eachOfSeries,
+    eachSeries,
+    ensureAsync,
+    every,
+    everyLimit,
+    everySeries,
+    filter,
+    filterLimit,
+    filterSeries,
+    forever,
+    groupBy,
+    groupByLimit,
+    groupBySeries,
+    log,
+    map,
+    mapLimit,
+    mapSeries,
+    mapValues,
+    mapValuesLimit,
+    mapValuesSeries,
+    memoize,
+    nextTick,
+    parallel,
+    parallelLimit,
+    priorityQueue,
+    queue,
+    race,
+    reduce,
+    reduceRight,
+    reflect,
+    reflectAll,
+    reject,
+    rejectLimit,
+    rejectSeries,
+    retry,
+    retryable,
+    seq,
+    series,
+    setImmediate,
+    some,
+    someLimit,
+    someSeries,
+    sortBy,
+    timeout,
+    times,
+    timesLimit,
+    timesSeries,
+    transform,
+    tryEach,
+    unmemoize,
+    until,
+    waterfall,
+    whilst,
+
+    // aliases
+    all: every,
+    allLimit: everyLimit,
+    allSeries: everySeries,
+    any: some,
+    anyLimit: someLimit,
+    anySeries: someSeries,
+    find: detect,
+    findLimit: detectLimit,
+    findSeries: detectSeries,
+    flatMap: concat,
+    flatMapLimit: concatLimit,
+    flatMapSeries: concatSeries,
+    forEach: each,
+    forEachSeries: eachSeries,
+    forEachLimit: eachLimit,
+    forEachOf: eachOf,
+    forEachOfSeries: eachOfSeries,
+    forEachOfLimit: eachOfLimit,
+    inject: reduce,
+    foldl: reduce,
+    foldr: reduceRight,
+    select: filter,
+    selectLimit: filterLimit,
+    selectSeries: filterSeries,
+    wrapSync: asyncify,
+    during: whilst,
+    doDuring: doWhilst
+};
+
+export {
+    apply as apply,
+    applyEach as applyEach,
+    applyEachSeries as applyEachSeries,
+    asyncify as asyncify,
+    auto as auto,
+    autoInject as autoInject,
+    cargo as cargo,
+    cargoQueue as cargoQueue,
+    compose as compose,
+    concat as concat,
+    concatLimit as concatLimit,
+    concatSeries as concatSeries,
+    constant as constant,
+    detect as detect,
+    detectLimit as detectLimit,
+    detectSeries as detectSeries,
+    dir as dir,
+    doUntil as doUntil,
+    doWhilst as doWhilst,
+    each as each,
+    eachLimit as eachLimit,
+    eachOf as eachOf,
+    eachOfLimit as eachOfLimit,
+    eachOfSeries as eachOfSeries,
+    eachSeries as eachSeries,
+    ensureAsync as ensureAsync,
+    every as every,
+    everyLimit as everyLimit,
+    everySeries as everySeries,
+    filter as filter,
+    filterLimit as filterLimit,
+    filterSeries as filterSeries,
+    forever as forever,
+    groupBy as groupBy,
+    groupByLimit as groupByLimit,
+    groupBySeries as groupBySeries,
+    log as log,
+    map as map,
+    mapLimit as mapLimit,
+    mapSeries as mapSeries,
+    mapValues as mapValues,
+    mapValuesLimit as mapValuesLimit,
+    mapValuesSeries as mapValuesSeries,
+    memoize as memoize,
+    nextTick as nextTick,
+    parallel as parallel,
+    parallelLimit as parallelLimit,
+    priorityQueue as priorityQueue,
+    queue as queue,
+    race as race,
+    reduce as reduce,
+    reduceRight as reduceRight,
+    reflect as reflect,
+    reflectAll as reflectAll,
+    reject as reject,
+    rejectLimit as rejectLimit,
+    rejectSeries as rejectSeries,
+    retry as retry,
+    retryable as retryable,
+    seq as seq,
+    series as series,
+    setImmediate as setImmediate,
+    some as some,
+    someLimit as someLimit,
+    someSeries as someSeries,
+    sortBy as sortBy,
+    timeout as timeout,
+    times as times,
+    timesLimit as timesLimit,
+    timesSeries as timesSeries,
+    transform as transform,
+    tryEach as tryEach,
+    unmemoize as unmemoize,
+    until as until,
+    waterfall as waterfall,
+    whilst as whilst,
+
+    // Aliases
+    every as all,
+    everyLimit as allLimit,
+    everySeries as allSeries,
+    some as any,
+    someLimit as anyLimit,
+    someSeries as anySeries,
+    detect as find,
+    detectLimit as findLimit,
+    detectSeries as findSeries,
+    concat as flatMap,
+    concatLimit as flatMapLimit,
+    concatSeries as flatMapSeries,
+    each as forEach,
+    eachSeries as forEachSeries,
+    eachLimit as forEachLimit,
+    eachOf as forEachOf,
+    eachOfSeries as forEachOfSeries,
+    eachOfLimit as forEachOfLimit,
+    reduce as inject,
+    reduce as foldl,
+    reduceRight as foldr,
+    filter as select,
+    filterLimit as selectLimit,
+    filterSeries as selectSeries,
+    asyncify as wrapSync,
+    whilst as during,
+    doWhilst as doDuring
+};
+
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/log.js.html b/docs/v3/log.js.html new file mode 100644 index 000000000..e18395158 --- /dev/null +++ b/docs/v3/log.js.html @@ -0,0 +1,139 @@ + + + + + + + log.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

log.js

+ + + + + + + +
+
+
import consoleFunc from './internal/consoleFunc.js'
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ *     setTimeout(function() {
+ *         callback(null, 'hello ' + name);
+ *     }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+export default consoleFunc('log');
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/map.js.html b/docs/v3/map.js.html new file mode 100644 index 000000000..380eabb2d --- /dev/null +++ b/docs/v3/map.js.html @@ -0,0 +1,234 @@ + + + + + + + map.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

map.js

+ + + + + + + +
+
+
import _map from './internal/map.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callbacks
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array.  The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines).
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * // file1.txt is a file that is 1000 bytes in size
+ * // file2.txt is a file that is 2000 bytes in size
+ * // file3.txt is a file that is 3000 bytes in size
+ * // file4.txt does not exist
+ *
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
+ * const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+ *
+ * // asynchronous function that returns the file size in bytes
+ * function getFileSizeInBytes(file, callback) {
+ *     fs.stat(file, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         callback(null, stat.size);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.map(fileList, getFileSizeInBytes, function(err, results) {
+ *     if (err) {
+ *         console.log(err);
+ *     } else {
+ *         console.log(results);
+ *         // results is now an array of the file size in bytes for each file, e.g.
+ *         // [ 1000, 2000, 3000]
+ *     }
+ * });
+ *
+ * // Error Handling
+ * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) {
+ *     if (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     } else {
+ *         console.log(results);
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.map(fileList, getFileSizeInBytes)
+ * .then( results => {
+ *     console.log(results);
+ *     // results is now an array of the file size in bytes for each file, e.g.
+ *     // [ 1000, 2000, 3000]
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Error Handling
+ * async.map(withMissingFileList, getFileSizeInBytes)
+ * .then( results => {
+ *     console.log(results);
+ * }).catch( err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.map(fileList, getFileSizeInBytes);
+ *         console.log(results);
+ *         // results is now an array of the file size in bytes for each file, e.g.
+ *         // [ 1000, 2000, 3000]
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // Error Handling
+ * async () => {
+ *     try {
+ *         let results = await async.map(withMissingFileList, getFileSizeInBytes);
+ *         console.log(results);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     }
+ * }
+ *
+ */
+function map (coll, iteratee, callback) {
+    return _map(eachOf, coll, iteratee, callback)
+}
+export default awaitify(map, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/mapLimit.js.html b/docs/v3/mapLimit.js.html new file mode 100644 index 000000000..6d119ced6 --- /dev/null +++ b/docs/v3/mapLimit.js.html @@ -0,0 +1,137 @@ + + + + + + + mapLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapLimit.js

+ + + + + + + +
+
+
import _map from './internal/map.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function mapLimit (coll, limit, iteratee, callback) {
+    return _map(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(mapLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/mapSeries.js.html b/docs/v3/mapSeries.js.html new file mode 100644 index 000000000..57b2067dd --- /dev/null +++ b/docs/v3/mapSeries.js.html @@ -0,0 +1,136 @@ + + + + + + + mapSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapSeries.js

+ + + + + + + +
+
+
import _map from './internal/map.js'
+import eachOfSeries from './eachOfSeries.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function mapSeries (coll, iteratee, callback) {
+    return _map(eachOfSeries, coll, iteratee, callback)
+}
+export default awaitify(mapSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/mapValues.js.html b/docs/v3/mapValues.js.html new file mode 100644 index 000000000..41238a466 --- /dev/null +++ b/docs/v3/mapValues.js.html @@ -0,0 +1,249 @@ + + + + + + + mapValues.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValues.js

+ + + + + + + +
+
+
import mapValuesLimit from './mapValuesLimit.js'
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed.  The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * // file1.txt is a file that is 1000 bytes in size
+ * // file2.txt is a file that is 2000 bytes in size
+ * // file3.txt is a file that is 3000 bytes in size
+ * // file4.txt does not exist
+ *
+ * const fileMap = {
+ *     f1: 'file1.txt',
+ *     f2: 'file2.txt',
+ *     f3: 'file3.txt'
+ * };
+ *
+ * const withMissingFileMap = {
+ *     f1: 'file1.txt',
+ *     f2: 'file2.txt',
+ *     f3: 'file4.txt'
+ * };
+ *
+ * // asynchronous function that returns the file size in bytes
+ * function getFileSizeInBytes(file, key, callback) {
+ *     fs.stat(file, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         callback(null, stat.size);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) {
+ *     if (err) {
+ *         console.log(err);
+ *     } else {
+ *         console.log(result);
+ *         // result is now a map of file size in bytes for each file, e.g.
+ *         // {
+ *         //     f1: 1000,
+ *         //     f2: 2000,
+ *         //     f3: 3000
+ *         // }
+ *     }
+ * });
+ *
+ * // Error handling
+ * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) {
+ *     if (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     } else {
+ *         console.log(result);
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.mapValues(fileMap, getFileSizeInBytes)
+ * .then( result => {
+ *     console.log(result);
+ *     // result is now a map of file size in bytes for each file, e.g.
+ *     // {
+ *     //     f1: 1000,
+ *     //     f2: 2000,
+ *     //     f3: 3000
+ *     // }
+ * }).catch (err => {
+ *     console.log(err);
+ * });
+ *
+ * // Error Handling
+ * async.mapValues(withMissingFileMap, getFileSizeInBytes)
+ * .then( result => {
+ *     console.log(result);
+ * }).catch (err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.mapValues(fileMap, getFileSizeInBytes);
+ *         console.log(result);
+ *         // result is now a map of file size in bytes for each file, e.g.
+ *         // {
+ *         //     f1: 1000,
+ *         //     f2: 2000,
+ *         //     f3: 3000
+ *         // }
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // Error Handling
+ * async () => {
+ *     try {
+ *         let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes);
+ *         console.log(result);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     }
+ * }
+ *
+ */
+export default function mapValues(obj, iteratee, callback) {
+    return mapValuesLimit(obj, Infinity, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/mapValuesLimit.js.html b/docs/v3/mapValuesLimit.js.html new file mode 100644 index 000000000..24d7402c3 --- /dev/null +++ b/docs/v3/mapValuesLimit.js.html @@ -0,0 +1,150 @@ + + + + + + + mapValuesLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValuesLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+import once from './internal/once.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+    callback = once(callback);
+    var newObj = {};
+    var _iteratee = wrapAsync(iteratee)
+    return eachOfLimit(limit)(obj, (val, key, next) => {
+        _iteratee(val, key, (err, result) => {
+            if (err) return next(err);
+            newObj[key] = result;
+            next(err);
+        });
+    }, err => callback(err, newObj));
+}
+
+export default awaitify(mapValuesLimit, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/mapValuesSeries.js.html b/docs/v3/mapValuesSeries.js.html new file mode 100644 index 000000000..96aa77f0c --- /dev/null +++ b/docs/v3/mapValuesSeries.js.html @@ -0,0 +1,134 @@ + + + + + + + mapValuesSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

mapValuesSeries.js

+ + + + + + + +
+
+
import mapValuesLimit from './mapValuesLimit.js'
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+export default function mapValuesSeries(obj, iteratee, callback) {
+    return mapValuesLimit(obj, 1, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/memoize.js.html b/docs/v3/memoize.js.html new file mode 100644 index 000000000..31db0baff --- /dev/null +++ b/docs/v3/memoize.js.html @@ -0,0 +1,182 @@ + + + + + + + memoize.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

memoize.js

+ + + + + + + +
+
+
import setImmediate from './internal/setImmediate.js'
+import initialParams from './internal/initialParams.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * Caches the results of an async function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * **Note: if the async function errs, the result will not be cached and
+ * subsequent calls will call the wrapped function.**
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {AsyncFunction} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ *     // do something
+ *     callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ *     // callback
+ * });
+ */
+export default function memoize(fn, hasher = v => v) {
+    var memo = Object.create(null);
+    var queues = Object.create(null);
+    var _fn = wrapAsync(fn);
+    var memoized = initialParams((args, callback) => {
+        var key = hasher(...args);
+        if (key in memo) {
+            setImmediate(() => callback(null, ...memo[key]));
+        } else if (key in queues) {
+            queues[key].push(callback);
+        } else {
+            queues[key] = [callback];
+            _fn(...args, (err, ...resultArgs) => {
+                // #1465 don't memoize if an error occurred
+                if (!err) {
+                    memo[key] = resultArgs;
+                }
+                var q = queues[key];
+                delete queues[key];
+                for (var i = 0, l = q.length; i < l; i++) {
+                    q[i](err, ...resultArgs);
+                }
+            });
+        }
+    });
+    memoized.memo = memo;
+    memoized.unmemoized = fn;
+    return memoized;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/module-Collections.html b/docs/v3/module-Collections.html new file mode 100644 index 000000000..e4f4bba30 --- /dev/null +++ b/docs/v3/module-Collections.html @@ -0,0 +1,10013 @@ + + + + + + + Collections - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Collections

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for manipulating collections, such as +arrays and objects.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) concat(coll, iteratee, callbackopt)

+ + + + + +
+
import concat from 'async/concat';
+
+

Applies iteratee to each item in coll, concatenating the results. Returns +the concatenated list. The iteratees are called in parallel, and the +results are concatenated as they return. The results array will be returned in +the original order of coll passed to the iteratee function.

+
+ + + +
+
Alias:
+
  • flatMap
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+let directoryList = ['dir1','dir2','dir3'];
+let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4'];
+
+// Using callbacks
+async.concat(directoryList, fs.readdir, function(err, results) {
+   if (err) {
+       console.log(err);
+   } else {
+       console.log(results);
+       // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+   }
+});
+
+// Error Handling
+async.concat(withMissingDirectoryList, fs.readdir, function(err, results) {
+   if (err) {
+       console.log(err);
+       // [ Error: ENOENT: no such file or directory ]
+       // since dir4 does not exist
+   } else {
+       console.log(results);
+   }
+});
+
+// Using Promises
+async.concat(directoryList, fs.readdir)
+.then(results => {
+    console.log(results);
+    // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+}).catch(err => {
+     console.log(err);
+});
+
+// Error Handling
+async.concat(withMissingDirectoryList, fs.readdir)
+.then(results => {
+    console.log(results);
+}).catch(err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4 does not exist
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.concat(directoryList, fs.readdir);
+        console.log(results);
+        // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ]
+    } catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let results = await async.concat(withMissingDirectoryList, fs.readdir);
+        console.log(results);
+    } catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+        // since dir4 does not exist
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) concatLimit(coll, limit, iteratee, callbackopt)

+ + + + + +
+
import concatLimit from 'async/concatLimit';
+
+

The same as concat but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • flatMapLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll, +which should use an array as its result. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) concatSeries(coll, iteratee, callbackopt)

+ + + + + +
+
import concatSeries from 'async/concatSeries';
+
+

The same as concat but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • flatMapSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each item in coll. +The iteratee should complete with an array an array of results. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is an array +containing the concatenated results of the iteratee function. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

A Promise, if no callback is passed

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detect(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detect from 'async/detect';
+
+

Returns the first value in coll that passes an async truth test. The +iteratee is applied in parallel, meaning the first iteratee to return +true will fire the detect callback with that result. That means the +result might not be the first item in the original coll (in terms of order) +that passes the test. +If order within the original coll is important, then look at +detectSeries.

+
+ + + +
+
Alias:
+
  • find
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // dir1/file1.txt
+       // result now equals the first file in the list that exists
+   }
+);
+
+// Using Promises
+async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists)
+.then(result => {
+    console.log(result);
+    // dir1/file1.txt
+    // result now equals the first file in the list that exists
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists);
+        console.log(result);
+        // dir1/file1.txt
+        // result now equals the file in the list that exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) detectLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detectLimit from 'async/detectLimit';
+
+

The same as detect but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • findLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) detectSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import detectSeries from 'async/detectSeries';
+
+

The same as detect but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • findSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A truth test to apply to each item in coll. +The iteratee must complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be the first item in the array that passes the truth test +(iteratee) or the value undefined if none passed. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) each(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import each from 'async/each';
+
+

Applies the function iteratee to each item in coll, in parallel. +The iteratee is called with an item from the list, and a callback for when +it has finished. If the iteratee passes an error to its callback, the +main callback (for the each function) is immediately called with the +error.

+

Note, that since this function applies iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEach
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to +each item in coll. Invoked with (item, callback). +The array index is not passed to the iteratee. +If you need the index, use eachOf.

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt'];
+const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt'];
+
+// asynchronous function that deletes a file
+const deleteFile = function(file, callback) {
+    fs.unlink(file, callback);
+};
+
+// Using callbacks
+async.each(fileList, deleteFile, function(err) {
+    if( err ) {
+        console.log(err);
+    } else {
+        console.log('All files have been deleted successfully');
+    }
+});
+
+// Error Handling
+async.each(withMissingFileList, deleteFile, function(err){
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4/file2.txt does not exist
+    // dir1/file1.txt could have been deleted
+});
+
+// Using Promises
+async.each(fileList, deleteFile)
+.then( () => {
+    console.log('All files have been deleted successfully');
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.each(fileList, deleteFile)
+.then( () => {
+    console.log('All files have been deleted successfully');
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+    // since dir4/file2.txt does not exist
+    // dir1/file1.txt could have been deleted
+});
+
+// Using async/await
+async () => {
+    try {
+        await async.each(files, deleteFile);
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        await async.each(withMissingFileList, deleteFile);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+        // since dir4/file2.txt does not exist
+        // dir1/file1.txt could have been deleted
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) eachLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachLimit from 'async/eachLimit';
+
+

The same as each but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • forEachLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfLimit. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOf(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOf from 'async/eachOf';
+
+

Like each, except that it passes the key (or index) as the second argument +to the iteratee.

+
+ + + +
+
Alias:
+
  • forEachOf
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each +item in coll. +The key is the item's key, or index in the case of an array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dev.json is a file containing a valid json object config for dev environment
+// dev.json is a file containing a valid json object config for test environment
+// prod.json is a file containing a valid json object config for prod environment
+// invalid.json is a file with a malformed json object
+
+let configs = {}; //global variable
+let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'};
+let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'};
+
+// asynchronous function that reads a json file and parses the contents as json object
+function parseFile(file, key, callback) {
+    fs.readFile(file, "utf8", function(err, data) {
+        if (err) return calback(err);
+        try {
+            configs[key] = JSON.parse(data);
+        } catch (e) {
+            return callback(e);
+        }
+        callback();
+    });
+}
+
+// Using callbacks
+async.forEachOf(validConfigFileMap, parseFile, function (err) {
+    if (err) {
+        console.error(err);
+    } else {
+        console.log(configs);
+        // configs is now a map of JSON data, e.g.
+        // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+    }
+});
+
+//Error handing
+async.forEachOf(invalidConfigFileMap, parseFile, function (err) {
+    if (err) {
+        console.error(err);
+        // JSON parse error exception
+    } else {
+        console.log(configs);
+    }
+});
+
+// Using Promises
+async.forEachOf(validConfigFileMap, parseFile)
+.then( () => {
+    console.log(configs);
+    // configs is now a map of JSON data, e.g.
+    // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+}).catch( err => {
+    console.error(err);
+});
+
+//Error handing
+async.forEachOf(invalidConfigFileMap, parseFile)
+.then( () => {
+    console.log(configs);
+}).catch( err => {
+    console.error(err);
+    // JSON parse error exception
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.forEachOf(validConfigFileMap, parseFile);
+        console.log(configs);
+        // configs is now a map of JSON data, e.g.
+        // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json}
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+//Error handing
+async () => {
+    try {
+        let result = await async.forEachOf(invalidConfigFileMap, parseFile);
+        console.log(configs);
+    }
+    catch (err) {
+        console.log(err);
+        // JSON parse error exception
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOfLimit from 'async/eachOfLimit';
+
+

The same as eachOf but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • forEachOfLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. The key is the item's key, or index in the case of an +array. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachOfSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachOfSeries from 'async/eachOfSeries';
+
+

The same as eachOf but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • forEachOfSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +Invoked with (item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) eachSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import eachSeries from 'async/eachSeries';
+
+

The same as each but runs only a single async operation at a time.

+

Note, that unlike each, this function applies iteratee to each item +in series and therefore the iteratee functions will complete in order.

+
+ + + +
+
Alias:
+
  • forEachSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each +item in coll. +The array index is not passed to the iteratee. +If you need the index, use eachOfSeries. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all +iteratee functions have finished, or an error occurs. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) every(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import every from 'async/every';
+
+

Returns true if every element in coll satisfies an async test. If any +iteratee call returns false, the main callback is immediately called.

+
+ + + +
+
Alias:
+
  • all
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.every(fileList, fileExists, function(err, result) {
+    console.log(result);
+    // true
+    // result is true since every file exists
+});
+
+async.every(withMissingFileList, fileExists, function(err, result) {
+    console.log(result);
+    // false
+    // result is false since NOT every file exists
+});
+
+// Using Promises
+async.every(fileList, fileExists)
+.then( result => {
+    console.log(result);
+    // true
+    // result is true since every file exists
+}).catch( err => {
+    console.log(err);
+});
+
+async.every(withMissingFileList, fileExists)
+.then( result => {
+    console.log(result);
+    // false
+    // result is false since NOT every file exists
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.every(fileList, fileExists);
+        console.log(result);
+        // true
+        // result is true since every file exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+async () => {
+    try {
+        let result = await async.every(withMissingFileList, fileExists);
+        console.log(result);
+        // false
+        // result is false since NOT every file exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) everyLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import everyLimit from 'async/everyLimit';
+
+

The same as every but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • allLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in parallel. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) everySeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import everySeries from 'async/everySeries';
+
+

The same as every but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • allSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collection in series. +The iteratee must complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result will be either true or false +depending on the values of the async tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filter(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filter from 'async/filter';
+
+

Returns a new array of all the values in coll which pass an async truth +test. This operation is performed in parallel, but the results array will be +in the same order as the original.

+
+ + + +
+
Alias:
+
  • select
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.filter(files, fileExists, function(err, results) {
+   if(err) {
+       console.log(err);
+   } else {
+       console.log(results);
+       // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+       // results is now an array of the existing files
+   }
+});
+
+// Using Promises
+async.filter(files, fileExists)
+.then(results => {
+    console.log(results);
+    // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+    // results is now an array of the existing files
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.filter(files, fileExists);
+        console.log(results);
+        // [ 'dir1/file1.txt', 'dir2/file3.txt' ]
+        // results is now an array of the existing files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) filterLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filterLimit from 'async/filterLimit';
+
+

The same as filter but runs a maximum of limit async operations at a +time.

+
+ + + +
+
Alias:
+
  • selectLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) filterSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import filterSeries from 'async/filterSeries';
+
+

The same as filter but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • selectSeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

A truth test to apply to each item in coll. +The iteratee is passed a callback(err, truthValue), which must be called +with a boolean argument once it has completed. Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results)

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBy(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupBy from 'async/groupBy';
+
+

Returns a new object, where each value corresponds to an array of items, from +coll, that returned the corresponding key. That is, the keys of the object +correspond to the values passed to the iteratee callback.

+

Note: Since this function applies the iteratee to each item in parallel, +there is no guarantee that the iteratee functions will complete in order. +However, the values for each key in the result will be in the same order as +the original coll. For Objects, the values will roughly be in the order of +the original Objects' keys (but this can vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+const files = ['dir1/file1.txt','dir2','dir4']
+
+// asynchronous function that detects file type as none, file, or directory
+function detectFile(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(null, 'none');
+        }
+        callback(null, stat.isDirectory() ? 'directory' : 'file');
+    });
+}
+
+//Using callbacks
+async.groupBy(files, detectFile, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+	       console.log(result);
+        // {
+        //     file: [ 'dir1/file1.txt' ],
+        //     none: [ 'dir4' ],
+        //     directory: [ 'dir2']
+        // }
+        // result is object containing the files grouped by type
+    }
+});
+
+// Using Promises
+async.groupBy(files, detectFile)
+.then( result => {
+    console.log(result);
+    // {
+    //     file: [ 'dir1/file1.txt' ],
+    //     none: [ 'dir4' ],
+    //     directory: [ 'dir2']
+    // }
+    // result is object containing the files grouped by type
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.groupBy(files, detectFile);
+        console.log(result);
+        // {
+        //     file: [ 'dir1/file1.txt' ],
+        //     none: [ 'dir4' ],
+        //     directory: [ 'dir2']
+        // }
+        // result is object containing the files grouped by type
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) groupByLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupByLimit from 'async/groupByLimit';
+
+

The same as groupBy but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whoses +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) groupBySeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import groupBySeries from 'async/groupBySeries';
+
+

The same as groupBy but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a key to group the value under. +Invoked with (value, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Result is an Object whose +properties are arrays of values which returned the corresponding key.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) map(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import map from 'async/map';
+
+

Produces a new collection of values by mapping each value in coll through +the iteratee function. The iteratee is called with an item from coll +and a callback for when it has finished processing. Each of these callbacks +takes 2 arguments: an error, and the transformed item from coll. If +iteratee passes an error to its callback, the main callback (for the +map function) is immediately called with the error.

+

Note, that since this function applies the iteratee to each item in +parallel, there is no guarantee that the iteratee functions will complete +in order. However, the results array will be in the same order as the +original coll.

+

If map is passed an Object, the results will be an Array. The results +will roughly be in the order of the original Objects' keys (but this can +vary across JavaScript engines).

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an Array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file4.txt'];
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.map(fileList, getFileSizeInBytes, function(err, results) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(results);
+        // results is now an array of the file size in bytes for each file, e.g.
+        // [ 1000, 2000, 3000]
+    }
+});
+
+// Error Handling
+async.map(withMissingFileList, getFileSizeInBytes, function(err, results) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(results);
+    }
+});
+
+// Using Promises
+async.map(fileList, getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+    // results is now an array of the file size in bytes for each file, e.g.
+    // [ 1000, 2000, 3000]
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.map(withMissingFileList, getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.map(fileList, getFileSizeInBytes);
+        console.log(results);
+        // results is now an array of the file size in bytes for each file, e.g.
+        // [ 1000, 2000, 3000]
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let results = await async.map(withMissingFileList, getFileSizeInBytes);
+        console.log(results);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapLimit from 'async/mapLimit';
+
+

The same as map but runs a maximum of limit async operations at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapSeries from 'async/mapSeries';
+
+

The same as map but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with the transformed item. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. Results is an array of the +transformed items from the coll. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValues(obj, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValues from 'async/mapValues';
+
+

A relative of map, designed for use with objects.

+

Produces a new Object by mapping each value of obj through the iteratee +function. The iteratee is called each value and key from obj and a +callback for when it has finished processing. Each of these callbacks takes +two arguments: an error, and the transformed item from obj. If iteratee +passes an error to its callback, the main callback (for the mapValues +function) is immediately called with the error.

+

Note, the order of the keys in the result is not guaranteed. The keys will +be roughly in the order they complete, (but this is very engine-specific)

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileMap = {
+    f1: 'file1.txt',
+    f2: 'file2.txt',
+    f3: 'file3.txt'
+};
+
+const withMissingFileMap = {
+    f1: 'file1.txt',
+    f2: 'file2.txt',
+    f3: 'file4.txt'
+};
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, key, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.mapValues(fileMap, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // result is now a map of file size in bytes for each file, e.g.
+        // {
+        //     f1: 1000,
+        //     f2: 2000,
+        //     f3: 3000
+        // }
+    }
+});
+
+// Error handling
+async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(result);
+    }
+});
+
+// Using Promises
+async.mapValues(fileMap, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+    // result is now a map of file size in bytes for each file, e.g.
+    // {
+    //     f1: 1000,
+    //     f2: 2000,
+    //     f3: 3000
+    // }
+}).catch (err => {
+    console.log(err);
+});
+
+// Error Handling
+async.mapValues(withMissingFileMap, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+}).catch (err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.mapValues(fileMap, getFileSizeInBytes);
+        console.log(result);
+        // result is now a map of file size in bytes for each file, e.g.
+        // {
+        //     f1: 1000,
+        //     f2: 2000,
+        //     f3: 3000
+        // }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes);
+        console.log(result);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesLimit(obj, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValuesLimit from 'async/mapValuesLimit';
+
+

The same as mapValues but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) mapValuesSeries(obj, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import mapValuesSeries from 'async/mapValuesSeries';
+
+

The same as mapValues but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
obj + + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

A function to apply to each value and key +in coll. +The iteratee should complete with the transformed value as its result. +Invoked with (value, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called when all iteratee +functions have finished, or an error occurs. result is a new object consisting +of each key from obj, with each transformed value on the right-hand side. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reduce(coll, memo, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reduce from 'async/reduce';
+
+

Reduces coll into a single value using an async iteratee to return each +successive step. memo is the initial state of the reduction. This function +only operates in series.

+

For performance reasons, it may make sense to split a call to this function +into a parallel map, and then use the normal Array.prototype.reduce on the +results. This function is for situations where each step in the reduction +needs to be async; if you can get the data before reducing it, then it's +probably a good idea to do so.

+
+ + + +
+
Alias:
+
  • foldl
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee completes with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+// file4.txt does not exist
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
+
+// asynchronous function that computes the file size in bytes
+// file size is added to the memoized value, then returned
+function getFileSizeInBytes(memo, file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, memo + stat.size);
+    });
+}
+
+// Using callbacks
+async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // 6000
+        // which is the sum of the file sizes of the three files
+    }
+});
+
+// Error Handling
+async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
+    if (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    } else {
+        console.log(result);
+    }
+});
+
+// Using Promises
+async.reduce(fileList, 0, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+    // 6000
+    // which is the sum of the file sizes of the three files
+}).catch( err => {
+    console.log(err);
+});
+
+// Error Handling
+async.reduce(withMissingFileList, 0, getFileSizeInBytes)
+.then( result => {
+    console.log(result);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.reduce(fileList, 0, getFileSizeInBytes);
+        console.log(result);
+        // 6000
+        // which is the sum of the file sizes of the three files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// Error Handling
+async () => {
+    try {
+        let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
+        console.log(result);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reduceRight(array, memo, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reduceRight from 'async/reduceRight';
+
+

Same as reduce, only operates on array in reverse order.

+
+ + + +
+
Alias:
+
  • foldr
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
array + + +Array + + + + + +

A collection to iterate over.

memo + + +* + + + + + +

The initial state of the reduction.

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +array to produce the next step in the reduction. +The iteratee should complete with the next state of the reduction. +If the iteratee completes with an error, the reduction is stopped and the +main callback is immediately called with the error. +Invoked with (memo, item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the reduced value. Invoked with +(err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reject(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import reject from 'async/reject';
+
+

The opposite of filter. Removes values that pass an async truth test.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+
+const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.reject(fileList, fileExists, function(err, results) {
+   // [ 'dir3/file6.txt' ]
+   // results now equals an array of the non-existing files
+});
+
+// Using Promises
+async.reject(fileList, fileExists)
+.then( results => {
+    console.log(results);
+    // [ 'dir3/file6.txt' ]
+    // results now equals an array of the non-existing files
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let results = await async.reject(fileList, fileExists);
+        console.log(results);
+        // [ 'dir3/file6.txt' ]
+        // results now equals an array of the non-existing files
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import rejectLimit from 'async/rejectLimit';
+
+

The same as reject but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) rejectSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import rejectSeries from 'async/rejectSeries';
+
+

The same as reject but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +function + + + + + +

An async truth test to apply to each item in +coll. +The should complete with a boolean value as its result. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) some(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import some from 'async/some';
+
+

Returns true if at least one element in the coll satisfies an async test. +If any iteratee call returns true, the main callback is immediately +called.

+
+ + + +
+
Alias:
+
  • any
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// dir1 is a directory that contains file1.txt, file2.txt
+// dir2 is a directory that contains file3.txt, file4.txt
+// dir3 is a directory that contains file5.txt
+// dir4 does not exist
+
+// asynchronous function that checks if a file exists
+function fileExists(file, callback) {
+   fs.access(file, fs.constants.F_OK, (err) => {
+       callback(null, !err);
+   });
+}
+
+// Using callbacks
+async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // true
+       // result is true since some file in the list exists
+   }
+);
+
+async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
+   function(err, result) {
+       console.log(result);
+       // false
+       // result is false since none of the files exists
+   }
+);
+
+// Using Promises
+async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
+.then( result => {
+    console.log(result);
+    // true
+    // result is true since some file in the list exists
+}).catch( err => {
+    console.log(err);
+});
+
+async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
+.then( result => {
+    console.log(result);
+    // false
+    // result is false since none of the files exists
+}).catch( err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
+        console.log(result);
+        // true
+        // result is true since some file in the list exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+async () => {
+    try {
+        let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
+        console.log(result);
+        // false
+        // result is false since none of the files exists
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) someLimit(coll, limit, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import someLimit from 'async/someLimit';
+
+

The same as some but runs a maximum of limit async operations at a time.

+
+ + + +
+
Alias:
+
  • anyLimit
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in parallel. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) someSeries(coll, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import someSeries from 'async/someSeries';
+
+

The same as some but runs only a single async operation at a time.

+
+ + + +
+
Alias:
+
  • anySeries
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async truth test to apply to each item +in the collections in series. +The iteratee should complete with a boolean result value. +Invoked with (item, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called as soon as any +iteratee returns true, or after all the iteratee functions have finished. +Result will be either true or false depending on the values of the async +tests. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) sortBy(coll, iteratee, callback) → {Promise}

+ + + + + +
+
import sortBy from 'async/sortBy';
+
+

Sorts a list by the results of running each coll value through an async +iteratee.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

iteratee + + +AsyncFunction + + + + + +

An async function to apply to each item in +coll. +The iteratee should complete with a value to use as the sort criteria as +its result. +Invoked with (item, callback).

callback + + +function + + + + + +

A callback which is called after all the +iteratee functions have finished, or an error occurs. Results is the items +from the original coll sorted by the values returned by the iteratee +calls. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// bigfile.txt is a file that is 251100 bytes in size
+// mediumfile.txt is a file that is 11000 bytes in size
+// smallfile.txt is a file that is 121 bytes in size
+
+// asynchronous function that returns the file size in bytes
+function getFileSizeInBytes(file, callback) {
+    fs.stat(file, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        callback(null, stat.size);
+    });
+}
+
+// Using callbacks
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes,
+    function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+        }
+    }
+);
+
+// By modifying the callback parameter the
+// sorting order can be influenced:
+
+// ascending order
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
+    getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+        if (getFileSizeErr) return callback(getFileSizeErr);
+        callback(null, fileSize);
+    });
+}, function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+        }
+    }
+);
+
+// descending order
+async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
+    getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+        if (getFileSizeErr) {
+            return callback(getFileSizeErr);
+        }
+        callback(null, fileSize * -1);
+    });
+}, function(err, results) {
+        if (err) {
+            console.log(err);
+        } else {
+            console.log(results);
+            // results is now the original array of files sorted by
+            // file size (ascending by default), e.g.
+            // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt']
+        }
+    }
+);
+
+// Error handling
+async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes,
+    function(err, results) {
+        if (err) {
+            console.log(err);
+            // [ Error: ENOENT: no such file or directory ]
+        } else {
+            console.log(results);
+        }
+    }
+);
+
+// Using Promises
+async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+    // results is now the original array of files sorted by
+    // file size (ascending by default), e.g.
+    // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+}).catch( err => {
+    console.log(err);
+});
+
+// Error handling
+async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes)
+.then( results => {
+    console.log(results);
+}).catch( err => {
+    console.log(err);
+    // [ Error: ENOENT: no such file or directory ]
+});
+
+// Using async/await
+(async () => {
+    try {
+        let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+        console.log(results);
+        // results is now the original array of files sorted by
+        // file size (ascending by default), e.g.
+        // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+    }
+    catch (err) {
+        console.log(err);
+    }
+})();
+
+// Error handling
+async () => {
+    try {
+        let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+        console.log(results);
+    }
+    catch (err) {
+        console.log(err);
+        // [ Error: ENOENT: no such file or directory ]
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) transform(coll, accumulatoropt, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import transform from 'async/transform';
+
+

A relative of reduce. Takes an Object or Array, and iterates over each +element in parallel, each step potentially mutating an accumulator value. +The type of the accumulator defaults to the type of collection passed in.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
coll + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection to iterate over.

accumulator + + +* + + + + + + <optional> + +

The initial state of the transform. If omitted, +it will default to an empty Object or Array, depending on the type of coll

iteratee + + +AsyncFunction + + + + + +

A function applied to each item in the +collection that potentially modifies the accumulator. +Invoked with (accumulator, item, key, callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after all the +iteratee functions have finished. Result is the transformed accumulator. +Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Examples
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+
+// helper function that returns human-readable size format from bytes
+function formatBytes(bytes, decimals = 2) {
+  // implementation not included for brevity
+  return humanReadbleFilesize;
+}
+
+const fileList = ['file1.txt','file2.txt','file3.txt'];
+
+// asynchronous function that returns the file size, transformed to human-readable format
+// e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+function transformFileSize(acc, value, key, callback) {
+    fs.stat(value, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        acc[key] = formatBytes(stat.size);
+        callback(null);
+    });
+}
+
+// Using callbacks
+async.transform(fileList, transformFileSize, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+    }
+});
+
+// Using Promises
+async.transform(fileList, transformFileSize)
+.then(result => {
+    console.log(result);
+    // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+(async () => {
+    try {
+        let result = await async.transform(fileList, transformFileSize);
+        console.log(result);
+        // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+    }
+    catch (err) {
+        console.log(err);
+    }
+})();
+ +
// file1.txt is a file that is 1000 bytes in size
+// file2.txt is a file that is 2000 bytes in size
+// file3.txt is a file that is 3000 bytes in size
+
+// helper function that returns human-readable size format from bytes
+function formatBytes(bytes, decimals = 2) {
+  // implementation not included for brevity
+  return humanReadbleFilesize;
+}
+
+const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' };
+
+// asynchronous function that returns the file size, transformed to human-readable format
+// e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+function transformFileSize(acc, value, key, callback) {
+    fs.stat(value, function(err, stat) {
+        if (err) {
+            return callback(err);
+        }
+        acc[key] = formatBytes(stat.size);
+        callback(null);
+    });
+}
+
+// Using callbacks
+async.transform(fileMap, transformFileSize, function(err, result) {
+    if(err) {
+        console.log(err);
+    } else {
+        console.log(result);
+        // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+    }
+});
+
+// Using Promises
+async.transform(fileMap, transformFileSize)
+.then(result => {
+    console.log(result);
+    // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+}).catch(err => {
+    console.log(err);
+});
+
+// Using async/await
+async () => {
+    try {
+        let result = await async.transform(fileMap, transformFileSize);
+        console.log(result);
+        // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/module-ControlFlow.html b/docs/v3/module-ControlFlow.html new file mode 100644 index 000000000..f3511a6e9 --- /dev/null +++ b/docs/v3/module-ControlFlow.html @@ -0,0 +1,7159 @@ + + + + + + + ControlFlow - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Control Flow

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async functions for controlling the flow through a script.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) applyEach(fns, …argsopt, callbackopt) → {AsyncFunction}

+ + + + + +
+
import applyEach from 'async/applyEach';
+
+

Applies the provided arguments to each function in the array, calling +callback after all functions have completed. If you only provide the first +argument, fns, then it will return a function which lets you pass in the +arguments as if it were a single function call. If more arguments are +provided, callback is required while args is still optional. The results +for each of the applied async functions are passed to the final callback +as an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of AsyncFunctions +to all call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • Returns a function that takes no args other than +an optional callback, that is the result of applying the args to each +of the functions.
  • +
+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
+
+appliedFn((err, results) => {
+    // results[0] is the results for `enableSearch`
+    // results[1] is the results for `updateSchema`
+});
+
+// partial application example:
+async.each(
+    buckets,
+    async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
+    callback
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) applyEachSeries(fns, …argsopt, callbackopt) → {AsyncFunction}

+ + + + + +
+
import applyEachSeries from 'async/applyEachSeries';
+
+

The same as applyEach but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fns + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of AsyncFunctions to all +call with the same arguments

args + + +* + + + + + + <optional> + +

any number of separate arguments to pass to the +function.

callback + + +function + + + + + + <optional> + +

the final argument should be the callback, +called when all functions have completed processing.

+ + + + +
Returns:
+ + +
+
    +
  • A function, that when called, is the result of +appling the args to the list of functions. It takes no args, other than +a callback.
  • +
+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) auto(tasks, concurrencyopt, callbackopt) → {Promise}

+ + + + + +
+
import auto from 'async/auto';
+
+

Determines the best order for running the AsyncFunctions in tasks, based on +their requirements. Each function can optionally depend on other functions +being completed first, and each function is run as soon as its requirements +are satisfied.

+

If any of the AsyncFunctions pass an error to their callback, the auto sequence +will stop. Further tasks will not execute (so any other functions depending +on it will not run), and the main callback is immediately called with the +error.

+

AsyncFunctions also receive an object containing the results of functions which +have completed so far as the first argument, if they have dependencies. If a +task function has no dependencies, it will only be passed a callback.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
tasks + + +Object + + + + + + + +

An object. Each of its properties is either a +function or an array of requirements, with the AsyncFunction itself the last item +in the array. The object's key of a property serves as the name of the task +defined by that property, i.e. can be used when specifying requirements for +other tasks. The function receives one or two arguments:

+
    +
  • a results object, containing the results of the previously executed +functions, only passed if the task has any dependencies,
  • +
  • a callback(err, result) function, which must be called when finished, +passing an error (which can be null) and the result of the function's +execution.
  • +
concurrency + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for +determining the maximum number of tasks that can be run in parallel. By +default, as many as possible.

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback. Results are always returned; however, if an +error occurs, no further tasks will be performed, and the results object +will only contain partial results. Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.auto({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        // once the file is written let's email a link to it...
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}, function(err, results) {
+    if (err) {
+        console.log('err = ', err);
+    }
+    console.log('results = ', results);
+    // results = {
+    //     get_data: ['data', 'converted to array']
+    //     make_folder; 'folder',
+    //     write_file: 'filename'
+    //     email_link: { file: 'filename', email: 'user@example.com' }
+    // }
+});
+
+//Using Promises
+async.auto({
+    get_data: function(callback) {
+        console.log('in get_data');
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        console.log('in make_folder');
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: ['get_data', 'make_folder', function(results, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(results, callback) {
+        // once the file is written let's email a link to it...
+        callback(null, {'file':results.write_file, 'email':'user@example.com'});
+    }]
+}).then(results => {
+    console.log('results = ', results);
+    // results = {
+    //     get_data: ['data', 'converted to array']
+    //     make_folder; 'folder',
+    //     write_file: 'filename'
+    //     email_link: { file: 'filename', email: 'user@example.com' }
+    // }
+}).catch(err => {
+    console.log('err = ', err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.auto({
+            get_data: function(callback) {
+                // async code to get some data
+                callback(null, 'data', 'converted to array');
+            },
+            make_folder: function(callback) {
+                // async code to create a directory to store a file in
+                // this is run at the same time as getting the data
+                callback(null, 'folder');
+            },
+            write_file: ['get_data', 'make_folder', function(results, callback) {
+                // once there is some data and the directory exists,
+                // write the data to a file in the directory
+                callback(null, 'filename');
+            }],
+            email_link: ['write_file', function(results, callback) {
+                // once the file is written let's email a link to it...
+                callback(null, {'file':results.write_file, 'email':'user@example.com'});
+            }]
+        });
+        console.log('results = ', results);
+        // results = {
+        //     get_data: ['data', 'converted to array']
+        //     make_folder; 'folder',
+        //     write_file: 'filename'
+        //     email_link: { file: 'filename', email: 'user@example.com' }
+        // }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) autoInject(tasks, callbackopt) → {Promise}

+ + + + + +
+
import autoInject from 'async/autoInject';
+
+

A dependency-injected version of the async.auto function. Dependent +tasks are specified as parameters to the function, after the usual callback +parameter, with the parameter names matching the names of the tasks it +depends on. This can provide even more readable task graphs which can be +easier to maintain.

+

If a final callback is specified, the task results are similarly injected, +specified as named parameters after the initial error parameter.

+

The autoInject function is purely syntactic sugar and its semantics are +otherwise equivalent to async.auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Object + + + + + +

An object, each of whose properties is an AsyncFunction of +the form 'func([dependencies...], callback). The object's key of a property +serves as the name of the task defined by that property, i.e. can be used +when specifying requirements for other tasks.

+
    +
  • The callback parameter is a callback(err, result) which must be called +when finished, passing an error (which can be null) and the result of +the function's execution. The remaining parameters name other tasks on +which the task is dependent, and the results from those tasks are the +arguments of those parameters.
  • +
callback + + +function + + + + + + <optional> + +

An optional callback which is called when all +the tasks have been completed. It receives the err argument if any tasks +pass an error to their callback, and a results object with any completed +task results, similar to auto.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//  The example from `auto` can be rewritten as follows:
+async.autoInject({
+    get_data: function(callback) {
+        // async code to get some data
+        callback(null, 'data', 'converted to array');
+    },
+    make_folder: function(callback) {
+        // async code to create a directory to store a file in
+        // this is run at the same time as getting the data
+        callback(null, 'folder');
+    },
+    write_file: function(get_data, make_folder, callback) {
+        // once there is some data and the directory exists,
+        // write the data to a file in the directory
+        callback(null, 'filename');
+    },
+    email_link: function(write_file, callback) {
+        // once the file is written let's email a link to it...
+        // write_file contains the filename returned by write_file.
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+
+// If you are using a JS minifier that mangles parameter names, `autoInject`
+// will not work with plain functions, since the parameter names will be
+// collapsed to a single letter identifier.  To work around this, you can
+// explicitly specify the names of the parameters your task function needs
+// in an array, similar to Angular.js dependency injection.
+
+// This still has an advantage over plain `auto`, since the results a task
+// depends on are still spread into arguments.
+async.autoInject({
+    //...
+    write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+        callback(null, 'filename');
+    }],
+    email_link: ['write_file', function(write_file, callback) {
+        callback(null, {'file':write_file, 'email':'user@example.com'});
+    }]
+    //...
+}, function(err, results) {
+    console.log('err = ', err);
+    console.log('email_link = ', results.email_link);
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargo(worker, payloadopt) → {QueueObject}

+ + + + + +
+
import cargo from 'async/cargo';
+
+

Creates a cargo object with the specified payload. Tasks added to the +cargo will be processed altogether (up to the payload limit). If the +worker is in progress, the task is queued until it becomes available. Once +the worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, cargo passes an array of tasks to a single worker, repeating +when the worker is finished.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargo object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargo and inner queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a cargo object with payload 2
+var cargo = async.cargo(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2);
+
+// add some items
+cargo.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargo.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+await cargo.push({name: 'baz'});
+console.log('finished processing baz');
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) cargoQueue(worker, concurrencyopt, payloadopt) → {QueueObject}

+ + + + + +
+
import cargoQueue from 'async/cargoQueue';
+
+

Creates a cargoQueue object with the specified payload. Tasks added to the +cargoQueue will be processed together (up to the payload limit) in concurrency parallel workers. +If the all workers are in progress, the task is queued until one becomes available. Once +a worker has completed some tasks, each callback of those tasks is +called. Check out these animations +for how cargo and queue work.

+

While queue passes only one task to one of a group of workers +at a time, and cargo passes an array of tasks to a single worker, +the cargoQueue passes an array of tasks to multiple parallel workers.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An asynchronous function for processing an array +of queued tasks. Invoked with (tasks, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

payload + + +number + + + + + + <optional> + + + + Infinity + +

An optional integer for determining +how many tasks should be processed per round; if omitted, the default is +unlimited.

+ + + + +
Returns:
+ + +
+

A cargoQueue object to manage the tasks. Callbacks can +attached as certain properties to listen for specific events during the +lifecycle of the cargoQueue and inner queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a cargoQueue object with payload 2 and concurrency 2
+var cargoQueue = async.cargoQueue(function(tasks, callback) {
+    for (var i=0; i<tasks.length; i++) {
+        console.log('hello ' + tasks[i].name);
+    }
+    callback();
+}, 2, 2);
+
+// add some items
+cargoQueue.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+cargoQueue.push({name: 'bar'}, function(err) {
+    console.log('finished processing bar');
+});
+cargoQueue.push({name: 'baz'}, function(err) {
+    console.log('finished processing baz');
+});
+cargoQueue.push({name: 'boo'}, function(err) {
+    console.log('finished processing boo');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) compose(…functions) → {function}

+ + + + + +
+
import compose from 'async/compose';
+
+

Creates a function which is a composition of the passed asynchronous +functions. Each function consumes the return value of the function that +follows. Composing functions f(), g(), and h() would produce the result +of f(g(h())), only this version uses callbacks to obtain the return values.

+

If the last argument to the composed function is not a function, a promise +is returned when you call it.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

an asynchronous function that is the composed +asynchronous functions

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
function add1(n, callback) {
+    setTimeout(function () {
+        callback(null, n + 1);
+    }, 10);
+}
+
+function mul3(n, callback) {
+    setTimeout(function () {
+        callback(null, n * 3);
+    }, 10);
+}
+
+var add1mul3 = async.compose(mul3, add1);
+add1mul3(4, function (err, result) {
+    // result now equals 15
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) doUntil(iteratee, test, callbackopt) → {Promise}

+ + + + + +
+
import doUntil from 'async/doUntil';
+
+

Like 'doWhilst', except the test is inverted. Note the +argument ordering differs from until.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform after each +execution of iteratee. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of iteratee

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) doWhilst(iteratee, test, callbackopt) → {Promise}

+ + + + + +
+
import doWhilst from 'async/doWhilst';
+
+

The post-check version of whilst. To reflect the difference in +the order of operations, the arguments test and iteratee are switched.

+

doWhilst is to whilst as do while is to while in plain JavaScript.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
iteratee + + +AsyncFunction + + + + + +

A function which is called each time test +passes. Invoked with (callback).

test + + +AsyncFunction + + + + + +

asynchronous truth test to perform after each +execution of iteratee. Invoked with (...args, callback), where ...args are the +non-error args from the previous callback of iteratee.

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. +callback will be passed an error and any arguments passed to the final +iteratee's callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) forever(fn, errbackopt) → {Promise}

+ + + + + +
+
import forever from 'async/forever';
+
+

Calls the asynchronous function fn with a callback parameter that allows it +to call itself again, in series, indefinitely. +If an error is passed to the callback then errback is called with the +error, and execution stops, otherwise it will never be called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function to call repeatedly. +Invoked with (next).

errback + + +function + + + + + + <optional> + +

when fn passes an error to it's callback, +this function will be called, and execution stops. Invoked with (err).

+ + + + +
Returns:
+ + +
+

a promise that rejects if an error occurs and an errback +is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.forever(
+    function(next) {
+        // next is suitable for passing to things that need a callback(err [, whatever]);
+        // it will result in this function being called again.
+    },
+    function(err) {
+        // if next is called with a value in its first parameter, it will appear
+        // in here as 'err', and execution will stop.
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallel(tasks, callbackopt) → {Promise}

+ + + + + +
+
import parallel from 'async/parallel';
+
+

Run the tasks collection of functions in parallel, without waiting until +the previous function has completed. If any of the functions pass an error to +its callback, the main callback is immediately called with the value of the +error. Once the tasks have completed, the results are passed to the final +callback as an array.

+

Note: parallel is about kicking-off I/O tasks in parallel, not about +parallel execution of code. If your tasks do not use any timers or perform +any I/O, they will actually be executed in series. Any synchronous setup +sections for each task will happen one after the other. JavaScript remains +single-threaded.

+

Hint: Use reflect to continue the +execution of other tasks when a task fails.

+

It is also possible to use an object instead of an array. Each property will +be run as a function and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.parallel.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+], function(err, results) {
+    console.log(results);
+    // results is equal to ['one','two'] even though
+    // the second function had a shorter timeout.
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+});
+
+//Using Promises
+async.parallel([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+]).then(results => {
+    console.log(results);
+    // results is equal to ['one','two'] even though
+    // the second function had a shorter timeout.
+}).catch(err => {
+    console.log(err);
+});
+
+// an example using an object instead of an array
+async.parallel({
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            callback(null, 2);
+        }, 100);
+    }
+}).then(results => {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+}).catch(err => {
+    console.log(err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.parallel([
+            function(callback) {
+                setTimeout(function() {
+                    callback(null, 'one');
+                }, 200);
+            },
+            function(callback) {
+                setTimeout(function() {
+                    callback(null, 'two');
+                }, 100);
+            }
+        ]);
+        console.log(results);
+        // results is equal to ['one','two'] even though
+        // the second function had a shorter timeout.
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// an example using an object instead of an array
+async () => {
+    try {
+        let results = await async.parallel({
+            one: function(callback) {
+                setTimeout(function() {
+                    callback(null, 1);
+                }, 200);
+            },
+           two: function(callback) {
+                setTimeout(function() {
+                    callback(null, 2);
+                }, 100);
+           }
+        });
+        console.log(results);
+        // results is equal to: { one: 1, two: 2 }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) parallelLimit(tasks, limit, callbackopt) → {Promise}

+ + + + + +
+
import parallelLimit from 'async/parallelLimit';
+
+

The same as parallel but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection of +async functions to run. +Each async function can complete with any number of optional result values.

limit + + +number + + + + + +

The maximum number of async operations at a time.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed successfully. This function gets a results array +(or object) containing all the result arguments passed to the task callbacks. +Invoked with (err, results).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) priorityQueue(worker, concurrency) → {QueueObject}

+ + + + + +
+
import priorityQueue from 'async/priorityQueue';
+
+

The same as async.queue only tasks are assigned a priority and +completed in ascending priority order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
worker + + +AsyncFunction + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). +Invoked with (task, callback).

concurrency + + +number + + + + + +

An integer for determining how many worker +functions should be run in parallel. If omitted, the concurrency defaults to +1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A priorityQueue object to manage the tasks. There are three +differences between queue and priorityQueue objects:

+
    +
  • push(task, priority, [callback]) - priority should be a number. If an +array of tasks is given, all tasks will be assigned the same priority.
  • +
  • pushAsync(task, priority, [callback]) - the same as priorityQueue.push, +except this returns a promise that rejects if an error occurs.
  • +
  • The unshift and unshiftAsync methods were removed.
  • +
+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) queue(worker, concurrencyopt) → {QueueObject}

+ + + + + +
+
import queue from 'async/queue';
+
+

Creates a queue object with the specified concurrency. Tasks added to the +queue are processed in parallel (up to the concurrency limit). If all +workers are in progress, the task is queued until one becomes available. +Once a worker completes a task, that task's callback is called.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
worker + + +AsyncFunction + + + + + + + +

An async function for processing a queued task. +If you want to handle errors from an individual task, pass a callback to +q.push(). Invoked with (task, callback).

concurrency + + +number + + + + + + <optional> + + + + 1 + +

An integer for determining how many +worker functions should be run in parallel. If omitted, the concurrency +defaults to 1. If the concurrency is 0, an error is thrown.

+ + + + +
Returns:
+ + +
+

A queue object to manage the tasks. Callbacks can be +attached as certain properties to listen for specific events during the +lifecycle of the queue.

+
+ + + +
+
+ Type +
+
+ +QueueObject + + +
+
+ + + + +
Example
+ +
// create a queue object with concurrency 2
+var q = async.queue(function(task, callback) {
+    console.log('hello ' + task.name);
+    callback();
+}, 2);
+
+// assign a callback
+q.drain(function() {
+    console.log('all items have been processed');
+});
+// or await the end
+await q.drain()
+
+// assign an error callback
+q.error(function(err, task) {
+    console.error('task experienced an error');
+});
+
+// add some items to the queue
+q.push({name: 'foo'}, function(err) {
+    console.log('finished processing foo');
+});
+// callback is optional
+q.push({name: 'bar'});
+
+// add some items to the queue (batch-wise)
+q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+    console.log('finished processing item');
+});
+
+// add some items to the front of the queue
+q.unshift({name: 'bar'}, function (err) {
+    console.log('finished processing bar');
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) race(tasks, callback) → {Promise}

+ + + + + +
+
import race from 'async/race';
+
+

Runs the tasks array of functions in parallel, without waiting until the +previous function has completed. Once any of the tasks complete or pass an +error to its callback, the main callback is immediately called. It's +equivalent to Promise.race().

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array containing async functions +to run. Each function can complete with an optional result value.

callback + + +function + + + + + +

A callback to run once any of the functions have +completed. This function gets an error or result from the first function that +completed. Invoked with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.race([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+],
+// main callback
+function(err, result) {
+    // the result will be equal to 'two' as it finishes earlier
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) retry(optsopt, task, callbackopt) → {Promise}

+ + + + + +
+
import retry from 'async/retry';
+
+

Attempts to get a successful response from task no more than times times +before returning an error. If the task is successful, the callback will be +passed the result of the successful task. If all attempts fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

Can be either an +object with times and interval or a number.

+
    +
  • times - The number of attempts to make before giving up. The default +is 5.
  • +
  • interval - The time to wait between retries, in milliseconds. The +default is 0. The interval may also be specified as a function of the +retry count (see example).
  • +
  • errorFilter - An optional synchronous function that is invoked on +erroneous result. If it returns true the retry attempts will continue; +if the function returns false the retry flow is aborted with the current +attempt's error and result being returned to the final callback. +Invoked with (err).
  • +
  • If opts is a number, the number specifies the number of times to retry, +with the default interval of 0.
  • +
task + + +AsyncFunction + + + + + + + +

An async function to retry. +Invoked with (callback).

callback + + +function + + + + + + <optional> + + + +

An optional callback which is called when the +task has succeeded, or after the final failed attempt. It receives the err +and result arguments of the last attempt at completing the task. Invoked +with (err, results).

+ + + + +
Returns:
+ + +
+

a promise if no callback provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// The `retry` function can be used as a stand-alone control flow by passing
+// a callback, as shown below:
+
+// try calling apiMethod 3 times
+async.retry(3, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 3 times, waiting 200 ms between each retry
+async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod 10 times with exponential backoff
+// (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+async.retry({
+  times: 10,
+  interval: function(retryCount) {
+    return 50 * Math.pow(2, retryCount);
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod the default 5 times no delay between each retry
+async.retry(apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// try calling apiMethod only when error condition satisfies, all other
+// errors will abort the retry control flow and return to final callback
+async.retry({
+  errorFilter: function(err) {
+    return err.message === 'Temporary error'; // only retry on a specific error
+  }
+}, apiMethod, function(err, result) {
+    // do something with the result
+});
+
+// to retry individual methods that are not as reliable within other
+// control flow functions, use the `retryable` wrapper:
+async.auto({
+    users: api.getUsers.bind(api),
+    payments: async.retryable(3, api.getPayments.bind(api))
+}, function(err, results) {
+    // do something with the results
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) retryable(optsopt, task) → {AsyncFunction}

+ + + + + +
+
import retryable from 'async/retryable';
+
+

A close relative of retry. This method +wraps a task and makes it retryable, rather than immediately calling it +with retries.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
opts + + +Object +| + +number + + + + + + <optional> + + + + {times: 5, interval: 0}| 5 + +

optional +options, exactly the same as from retry, except for a opts.arity that +is the arity of the task function, defaulting to task.length

task + + +AsyncFunction + + + + + + + +

the asynchronous function to wrap. +This function will be passed any arguments passed to the returned wrapper. +Invoked with (...args, callback).

+ + + + +
Returns:
+ + +
+

The wrapped function, which when invoked, will +retry on an error, based on the parameters specified in opts. +This function will accept the same parameters as task.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.auto({
+    dep1: async.retryable(3, getFromFlakyService),
+    process: ["dep1", async.retryable(3, function (results, cb) {
+        maybeProcessData(results.dep1, cb);
+    })]
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) seq(…functions) → {function}

+ + + + + +
+
import seq from 'async/seq';
+
+

Version of the compose function that is more natural to read. Each function +consumes the return value of the previous function. It is the equivalent of +compose with the arguments reversed.

+

Each function is executed with the this binding of the composed function.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
functions + + +AsyncFunction + + + + + +

the asynchronous functions to compose

+ + + + +
Returns:
+ + +
+

a function that composes the functions in order

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// Requires lodash (or underscore), express3 and dresende's orm2.
+// Part of an app, that fetches cats of the logged user.
+// This example uses `seq` function to avoid overnesting and error
+// handling clutter.
+app.get('/cats', function(request, response) {
+    var User = request.models.User;
+    async.seq(
+        User.get.bind(User),  // 'User.get' has signature (id, callback(err, data))
+        function(user, fn) {
+            user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+        }
+    )(req.session.user_id, function (err, cats) {
+        if (err) {
+            console.error(err);
+            response.json({ status: 'error', message: err.message });
+        } else {
+            response.json({ status: 'ok', message: 'Cats found', data: cats });
+        }
+    });
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) series(tasks, callbackopt) → {Promise}

+ + + + + +
+
import series from 'async/series';
+
+

Run the functions in the tasks collection in series, each one running once +the previous function has completed. If any functions in the series pass an +error to its callback, no more functions are run, and callback is +immediately called with the value of the error. Otherwise, callback +receives an array of results when tasks have completed.

+

It is also possible to use an object instead of an array. Each property will +be run as a function, and the results will be passed to the final callback +as an object instead of an array. This can be a more readable way of handling +results from async.series.

+

Note that while many implementations preserve the order of object +properties, the ECMAScript Language Specification +explicitly states that

+
+

The mechanics and order of enumerating the properties is not specified.

+
+

So if you rely on the order in which your series of functions are executed, +and want this to work on all platforms, consider using an array.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection containing +async functions to run in series. +Each function can complete with any number of optional result values.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This function gets a results array (or object) +containing all the result arguments passed to the task callbacks. Invoked +with (err, result).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
//Using Callbacks
+async.series([
+    function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 'two');
+        }, 100);
+    }
+], function(err, results) {
+    console.log(results);
+    // results is equal to ['one','two']
+});
+
+// an example using objects instead of arrays
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 2);
+        }, 100);
+    }
+}, function(err, results) {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+});
+
+//Using Promises
+async.series([
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+]).then(results => {
+    console.log(results);
+    // results is equal to ['one','two']
+}).catch(err => {
+    console.log(err);
+});
+
+// an example using an object instead of an array
+async.series({
+    one: function(callback) {
+        setTimeout(function() {
+            // do some async task
+            callback(null, 1);
+        }, 200);
+    },
+    two: function(callback) {
+        setTimeout(function() {
+            // then do another async task
+            callback(null, 2);
+        }, 100);
+    }
+}).then(results => {
+    console.log(results);
+    // results is equal to: { one: 1, two: 2 }
+}).catch(err => {
+    console.log(err);
+});
+
+//Using async/await
+async () => {
+    try {
+        let results = await async.series([
+            function(callback) {
+                setTimeout(function() {
+                    // do some async task
+                    callback(null, 'one');
+                }, 200);
+            },
+            function(callback) {
+                setTimeout(function() {
+                    // then do another async task
+                    callback(null, 'two');
+                }, 100);
+            }
+        ]);
+        console.log(results);
+        // results is equal to ['one','two']
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+
+// an example using an object instead of an array
+async () => {
+    try {
+        let results = await async.parallel({
+            one: function(callback) {
+                setTimeout(function() {
+                    // do some async task
+                    callback(null, 1);
+                }, 200);
+            },
+           two: function(callback) {
+                setTimeout(function() {
+                    // then do another async task
+                    callback(null, 2);
+                }, 100);
+           }
+        });
+        console.log(results);
+        // results is equal to: { one: 1, two: 2 }
+    }
+    catch (err) {
+        console.log(err);
+    }
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) times(n, iteratee, callback) → {Promise}

+ + + + + +
+
import times from 'async/times';
+
+

Calls the iteratee function n times, and accumulates results in the same +manner you would use with map.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
// Pretend this is some complicated async factory
+var createUser = function(id, callback) {
+    callback(null, {
+        id: 'user' + id
+    });
+};
+
+// generate 5 users
+async.times(5, function(n, next) {
+    createUser(n, function(err, user) {
+        next(err, user);
+    });
+}, function(err, users) {
+    // we should now have 5 users
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesLimit(count, limit, iteratee, callback) → {Promise}

+ + + + + +
+
import timesLimit from 'async/timesLimit';
+
+

The same as times but runs a maximum of limit async operations at a +time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
count + + +number + + + + + +

The number of times to run the function.

limit + + +number + + + + + +

The maximum number of async operations at a time.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see async.map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timesSeries(n, iteratee, callback) → {Promise}

+ + + + + +
+
import timesSeries from 'async/timesSeries';
+
+

The same as times but runs only a single async operation at a time.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
n + + +number + + + + + +

The number of times to run the function.

iteratee + + +AsyncFunction + + + + + +

The async function to call n times. +Invoked with the iteration index and a callback: (n, next).

callback + + +function + + + + + +

see map.

+ + + + +
Returns:
+ + +
+

a promise, if no callback is provided

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) tryEach(tasks, callbackopt) → {Promise}

+ + + + + +
+
import tryEach from 'async/tryEach';
+
+

It runs each task in series but stops whenever any of the functions were +successful. If one of the tasks were successful, the callback will be +passed the result of the successful task. If all tasks fail, the callback +will be passed the error and result (if any) of the final attempt.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Iterable +| + +AsyncIterable +| + +Object + + + + + +

A collection containing functions to +run, each function is passed a callback(err, result) it must call on +completion with an error err (which can be null) and an optional result +value.

callback + + +function + + + + + + <optional> + +

An optional callback which is called when one +of the tasks has succeeded, or all have failed. It receives the err and +result arguments of the last attempt at completing the task. Invoked with +(err, results).

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.tryEach([
+    function getDataFromFirstWebsite(callback) {
+        // Try getting the data from the first website
+        callback(err, data);
+    },
+    function getDataFromSecondWebsite(callback) {
+        // First website failed,
+        // Try getting the data from the backup website
+        callback(err, data);
+    }
+],
+// optional callback
+function(err, results) {
+    Now do something with the data.
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) until(test, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import until from 'async/until';
+
+

Repeatedly call iteratee until test returns true. Calls callback when +stopped, or an error occurs. callback will be passed an error and any +arguments passed to the final iteratee's callback.

+

The inverse of whilst.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of iteratee. Invoked with (callback).

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test fails. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has passed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if a callback is not passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
const results = []
+let finished = false
+async.until(function test(cb) {
+    cb(null, finished)
+}, function iter(next) {
+    fetchPage(url, (err, body) => {
+        if (err) return next(err)
+        results = results.concat(body.objects)
+        finished = !!body.next
+        next(err)
+    })
+}, function done (err) {
+    // all pages have been fetched
+})
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) waterfall(tasks, callbackopt) → {Promise}

+ + + + + +
+
import waterfall from 'async/waterfall';
+
+

Runs the tasks array of functions in series, each passing their results to +the next in the array. However, if any of the tasks pass an error to their +own callback, the next function is not executed, and the main callback is +immediately called with the error.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array + + + + + +

An array of async functions +to run. +Each function should complete with any number of result values. +The result values will be passed as arguments, in order, to the next task.

callback + + +function + + + + + + <optional> + +

An optional callback to run once all the +functions have completed. This will be passed the results of the last task's +callback. Invoked with (err, [results]).

+ + + + +
Returns:
+ + +
+

a promise, if a callback is omitted

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    function(callback) {
+        callback(null, 'one', 'two');
+    },
+    function(arg1, arg2, callback) {
+        // arg1 now equals 'one' and arg2 now equals 'two'
+        callback(null, 'three');
+    },
+    function(arg1, callback) {
+        // arg1 now equals 'three'
+        callback(null, 'done');
+    }
+], function (err, result) {
+    // result now equals 'done'
+});
+
+// Or, with named functions:
+async.waterfall([
+    myFirstFunction,
+    mySecondFunction,
+    myLastFunction,
+], function (err, result) {
+    // result now equals 'done'
+});
+function myFirstFunction(callback) {
+    callback(null, 'one', 'two');
+}
+function mySecondFunction(arg1, arg2, callback) {
+    // arg1 now equals 'one' and arg2 now equals 'two'
+    callback(null, 'three');
+}
+function myLastFunction(arg1, callback) {
+    // arg1 now equals 'three'
+    callback(null, 'done');
+}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) whilst(test, iteratee, callbackopt) → {Promise}

+ + + + + +
+
import whilst from 'async/whilst';
+
+

Repeatedly call iteratee, while test returns true. Calls callback when +stopped, or an error occurs.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
test + + +AsyncFunction + + + + + +

asynchronous truth test to perform before each +execution of iteratee. Invoked with (callback).

iteratee + + +AsyncFunction + + + + + +

An async function which is called each time +test passes. Invoked with (callback).

callback + + +function + + + + + + <optional> + +

A callback which is called after the test +function has failed and repeated execution of iteratee has stopped. callback +will be passed an error and any arguments passed to the final iteratee's +callback. Invoked with (err, [results]);

+ + + + +
Returns:
+ + +
+

a promise, if no callback is passed

+
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + +
Example
+ +
var count = 0;
+async.whilst(
+    function test(cb) { cb(null, count < 5); },
+    function iter(callback) {
+        count++;
+        setTimeout(function() {
+            callback(null, count);
+        }, 1000);
+    },
+    function (err, n) {
+        // 5 seconds have passed, n = 5
+    }
+);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +

Type Definitions

+ + + +

QueueObject

+ + + + +
+
import queue from 'async/queue';
+
+

A queue of tasks for the worker function to complete.

+
+ + + +
Type:
+
    +
  • + +Iterable + + +
  • +
+ + + + + +
Properties:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
length + + +function + + + +

a function returning the number of items +waiting to be processed. Invoke with queue.length().

started + + +boolean + + + +

a boolean indicating whether or not any +items have been pushed and processed by the queue.

running + + +function + + + +

a function returning the number of items +currently being processed. Invoke with queue.running().

workersList + + +function + + + +

a function returning the array of items +currently being processed. Invoke with queue.workersList().

idle + + +function + + + +

a function returning false if there are items +waiting or being processed, or true if not. Invoke with queue.idle().

concurrency + + +number + + + +

an integer for determining how many worker +functions should be run in parallel. This property can be changed after a +queue is created to alter the concurrency on-the-fly.

payload + + +number + + + +

an integer that specifies how many items are +passed to the worker function at a time. only applies if this is a +cargo object

push + + +AsyncFunction + + + +

add a new task to the queue. Calls callback +once the worker has finished processing the task. Instead of a single task, +a tasks array can be submitted. The respective callback is used for every +task in the list. Invoke with queue.push(task, [callback]),

unshift + + +AsyncFunction + + + +

add a new task to the front of the queue. +Invoke with queue.unshift(task, [callback]).

pushAsync + + +AsyncFunction + + + +

the same as q.push, except this returns +a promise that rejects if an error occurs.

unshiftAsync + + +AsyncFunction + + + +

the same as q.unshift, except this returns +a promise that rejects if an error occurs.

remove + + +function + + + +

remove items from the queue that match a test +function. The test function will be passed an object with a data property, +and a priority property, if this is a +priorityQueue object. +Invoked with queue.remove(testFn), where testFn is of the form +function ({data, priority}) {} and returns a Boolean.

saturated + + +function + + + +

a function that sets a callback that is +called when the number of running workers hits the concurrency limit, and +further tasks will be queued. If the callback is omitted, q.saturated() +returns a promise for the next occurrence.

unsaturated + + +function + + + +

a function that sets a callback that is +called when the number of running workers is less than the concurrency & +buffer limits, and further tasks will not be queued. If the callback is +omitted, q.unsaturated() returns a promise for the next occurrence.

buffer + + +number + + + +

A minimum threshold buffer in order to say that +the queue is unsaturated.

empty + + +function + + + +

a function that sets a callback that is called +when the last item from the queue is given to a worker. If the callback +is omitted, q.empty() returns a promise for the next occurrence.

drain + + +function + + + +

a function that sets a callback that is called +when the last item from the queue has returned from the worker. If the +callback is omitted, q.drain() returns a promise for the next occurrence.

error + + +function + + + +

a function that sets a callback that is called +when a task errors. Has the signature function(error, task). If the +callback is omitted, error() returns a promise that rejects on the next +error.

paused + + +boolean + + + +

a boolean for determining whether the queue is +in a paused state.

pause + + +function + + + +

a function that pauses the processing of tasks +until resume() is called. Invoke with queue.pause().

resume + + +function + + + +

a function that resumes the processing of +queued tasks when the queue is paused. Invoke with queue.resume().

kill + + +function + + + +

a function that removes the drain callback and +empties remaining tasks from the queue forcing it to go idle. No more tasks +should be pushed to the queue after calling this function. Invoke with queue.kill().

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
Example
+ +
const q = async.queue(worker, 2)
+q.push(item1)
+q.push(item2)
+q.push(item3)
+// queues are iterable, spread into an array to inspect
+const items = [...q] // [item1, item2, item3]
+// or use for of
+for (let item of q) {
+    console.log(item)
+}
+
+q.drain(() => {
+    console.log('all done')
+})
+// or
+await q.drain()
+ + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/module-Utils.html b/docs/v3/module-Utils.html new file mode 100644 index 000000000..171e77b21 --- /dev/null +++ b/docs/v3/module-Utils.html @@ -0,0 +1,2749 @@ + + + + + + + Utils - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

Utils

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

A collection of async utility functions.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Methods

+ + + + + + +

(static) apply(fn) → {function}

+ + + + + +
+
import apply from 'async/apply';
+
+

Creates a continuation function with some arguments already applied.

+

Useful as a shorthand when combined with other control flow functions. Any +arguments passed to the returned function are added to the arguments +originally passed to apply.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +function + + + + + +

The function you want to eventually apply all +arguments to. Invokes with (arguments...).

arguments... + + +* + + + + + +

Any number of arguments to automatically apply +when the continuation is called.

+ + + + +
Returns:
+ + +
+

the partially-applied function

+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
// using apply
+async.parallel([
+    async.apply(fs.writeFile, 'testfile1', 'test1'),
+    async.apply(fs.writeFile, 'testfile2', 'test2')
+]);
+
+
+// the same process without using apply
+async.parallel([
+    function(callback) {
+        fs.writeFile('testfile1', 'test1', callback);
+    },
+    function(callback) {
+        fs.writeFile('testfile2', 'test2', callback);
+    }
+]);
+
+// It's possible to pass any number of additional arguments when calling the
+// continuation:
+
+node> var fn = async.apply(sys.puts, 'one');
+node> fn('two', 'three');
+one
+two
+three
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) asyncify(func) → {AsyncFunction}

+ + + + + +
+
import asyncify from 'async/asyncify';
+
+

Take a sync function and make it async, passing its return value to a +callback. This is useful for plugging sync functions into a waterfall, +series, or other async functions. Any arguments passed to the generated +function will be passed to the wrapped function (except for the final +callback argument). Errors thrown will be passed to the callback.

+

If the function passed to asyncify returns a Promise, that promises's +resolved/rejected state will be used to call the callback, rather than simply +the synchronous return value.

+

This also means you can asyncify ES2017 async functions.

+
+ + + +
+
Alias:
+
  • wrapSync
+
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
func + + +function + + + + + +

The synchronous function, or Promise-returning +function to convert to an AsyncFunction.

+ + + + +
Returns:
+ + +
+

An asynchronous wrapper of the func. To be +invoked with (args..., callback).

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
// passing a regular synchronous function
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(JSON.parse),
+    function (data, next) {
+        // data is the result of parsing the text.
+        // If there was a parsing error, it would have been caught.
+    }
+], callback);
+
+// passing a function returning a promise
+async.waterfall([
+    async.apply(fs.readFile, filename, "utf8"),
+    async.asyncify(function (contents) {
+        return db.model.create(contents);
+    }),
+    function (model, next) {
+        // `model` is the instantiated model object.
+        // If there was an error, this function would be skipped.
+    }
+], callback);
+
+// es2017 example, though `asyncify` is not needed if your JS environment
+// supports async functions out of the box
+var q = async.queue(async.asyncify(async function(file) {
+    var intermediateStep = await processFile(file);
+    return await somePromise(intermediateStep)
+}));
+
+q.push(files);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) constant() → {AsyncFunction}

+ + + + + +
+
import constant from 'async/constant';
+
+

Returns a function that when called, calls-back with the values provided. +Useful as the first function in a waterfall, or for plugging values in to +auto.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
arguments... + + +* + + + + + +

Any number of arguments to automatically invoke +callback with.

+ + + + +
Returns:
+ + +
+

Returns a function that when invoked, automatically +invokes the callback with the previous given arguments.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
async.waterfall([
+    async.constant(42),
+    function (value, next) {
+        // value === 42
+    },
+    //...
+], callback);
+
+async.waterfall([
+    async.constant(filename, "utf8"),
+    fs.readFile,
+    function (fileData, next) {
+        //...
+    }
+    //...
+], callback);
+
+async.auto({
+    hostname: async.constant("https://server.net/"),
+    port: findFreePort,
+    launchServer: ["hostname", "port", function (options, cb) {
+        startServer(options, cb);
+    }],
+    //...
+}, callback);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) dir(function)

+ + + + + +
+
import dir from 'async/dir';
+
+

Logs the result of an async function to the +console using console.dir to display the properties of the resulting object. +Only works in Node.js or in browsers that support console.dir and +console.error (such as FF and Chrome). +If multiple arguments are returned from the async function, +console.dir is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, {hello: name});
+    }, 1000);
+};
+
+// in the node repl
+node> async.dir(hello, 'world');
+{hello: 'world'}
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) ensureAsync(fn) → {AsyncFunction}

+ + + + + +
+
import ensureAsync from 'async/ensureAsync';
+
+

Wrap an async function and ensure it calls its callback on a later tick of +the event loop. If the function already calls its callback on a next tick, +no extra deferral is added. This is useful for preventing stack overflows +(RangeError: Maximum call stack size exceeded) and generally keeping +Zalgo +contained. ES2017 async functions are returned as-is -- they are immune +to Zalgo's corrupting influences, as they always resolve on a later tick.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

an async function, one that expects a node-style +callback as its last argument.

+ + + + +
Returns:
+ + +
+

Returns a wrapped function with the exact same call +signature as the function passed in.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function sometimesAsync(arg, callback) {
+    if (cache[arg]) {
+        return callback(null, cache[arg]); // this would be synchronous!!
+    } else {
+        doSomeIO(arg, callback); // this IO would be asynchronous
+    }
+}
+
+// this has a risk of stack overflows if many results are cached in a row
+async.mapSeries(args, sometimesAsync, done);
+
+// this will defer sometimesAsync's callback if necessary,
+// preventing stack overflows
+async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) log(function)

+ + + + + +
+
import log from 'async/log';
+
+

Logs the result of an async function to the console. Only works in +Node.js or in browsers that support console.log and console.error (such +as FF and Chrome). If multiple arguments are returned from the async +function, console.log is called on each argument in order.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
function + + +AsyncFunction + + + + + +

The function you want to eventually apply +all arguments to.

arguments... + + +* + + + + + +

Any number of arguments to apply to the function.

+ + + + + + +
Example
+ +
// in a module
+var hello = function(name, callback) {
+    setTimeout(function() {
+        callback(null, 'hello ' + name);
+    }, 1000);
+};
+
+// in the node repl
+node> async.log(hello, 'world');
+'hello world'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) memoize(fn, hasher) → {AsyncFunction}

+ + + + + +
+
import memoize from 'async/memoize';
+
+

Caches the results of an async function. When creating a hash to store +function results against, the callback is omitted from the hash and an +optional hash function can be used.

+

Note: if the async function errs, the result will not be cached and +subsequent calls will call the wrapped function.

+

If no hash function is specified, the first argument is used as a hash key, +which may work reasonably if it is a string or a data type that converts to a +distinct string. Note that objects and arrays will not behave reasonably. +Neither will cases where the other arguments are significant. In such cases, +specify your own hash function.

+

The cache of results is exposed as the memo property of the function +returned by memoize.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function to proxy and cache results from.

hasher + + +function + + + + + +

An optional function for generating a custom hash +for storing results. It has all the arguments applied to it apart from the +callback, and must be synchronous.

+ + + + +
Returns:
+ + +
+

a memoized version of fn

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
var slow_fn = function(name, callback) {
+    // do something
+    callback(null, result);
+};
+var fn = async.memoize(slow_fn);
+
+// fn can now be used as if it were slow_fn
+fn('some name', function() {
+    // callback
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) nextTick(callback)

+ + + + + +
+
import nextTick from 'async/nextTick';
+
+

Calls callback on a later loop around the event loop. In Node.js this just +calls process.nextTick. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) reflect(fn) → {function}

+ + + + + +
+
import reflect from 'async/reflect';
+
+

Wraps the async function in another function that always completes with a +result object, even when it errors.

+

The result object has either the property error or value.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

The async function you want to wrap

+ + + + +
Returns:
+ + +
+
    +
  • A function that always passes null to it's callback as +the error. The second argument to the callback will be an object with +either an error or a value property.
  • +
+
+ + + +
+
+ Type +
+
+ +function + + +
+
+ + + + +
Example
+ +
async.parallel([
+    async.reflect(function(callback) {
+        // do some stuff ...
+        callback(null, 'one');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff but error ...
+        callback('bad stuff happened');
+    }),
+    async.reflect(function(callback) {
+        // do some more stuff ...
+        callback(null, 'two');
+    })
+],
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = 'bad stuff happened'
+    // results[2].value = 'two'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) reflectAll(tasks) → {Array}

+ + + + + +
+
import reflectAll from 'async/reflectAll';
+
+

A helper function that wraps an array or an object of functions with reflect.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tasks + + +Array +| + +Object +| + +Iterable + + + + + +

The collection of +async functions to wrap in async.reflect.

+ + + + +
Returns:
+ + +
+

Returns an array of async functions, each wrapped in +async.reflect

+
+ + + +
+
+ Type +
+
+ +Array + + +
+
+ + + + +
Example
+ +
let tasks = [
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    function(callback) {
+        // do some more stuff but error ...
+        callback(new Error('bad stuff happened'));
+    },
+    function(callback) {
+        setTimeout(function() {
+            callback(null, 'two');
+        }, 100);
+    }
+];
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results[0].value = 'one'
+    // results[1].error = Error('bad stuff happened')
+    // results[2].value = 'two'
+});
+
+// an example using an object instead of an array
+let tasks = {
+    one: function(callback) {
+        setTimeout(function() {
+            callback(null, 'one');
+        }, 200);
+    },
+    two: function(callback) {
+        callback('two');
+    },
+    three: function(callback) {
+        setTimeout(function() {
+            callback(null, 'three');
+        }, 100);
+    }
+};
+
+async.parallel(async.reflectAll(tasks),
+// optional callback
+function(err, results) {
+    // values
+    // results.one.value = 'one'
+    // results.two.error = 'two'
+    // results.three.value = 'three'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) setImmediate(callback)

+ + + + + +
+
import setImmediate from 'async/setImmediate';
+
+

Calls callback on a later loop around the event loop. In Node.js this just +calls setImmediate. In the browser it will use setImmediate if +available, otherwise setTimeout(callback, 0), which means other higher +priority events may precede the execution of callback.

+

This is used internally for browser-compatibility purposes.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
callback + + +function + + + + + +

The function to call on a later loop around +the event loop. Invoked with (args...).

args... + + +* + + + + + +

any number of additional arguments to pass to the +callback on the next tick.

+ + + + + + +
Example
+ +
var call_order = [];
+async.nextTick(function() {
+    call_order.push('two');
+    // call_order now equals ['one','two']
+});
+call_order.push('one');
+
+async.setImmediate(function (a, b, c) {
+    // a, b, and c equal 1, 2, and 3
+}, 1, 2, 3);
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + +

(static) timeout(asyncFn, milliseconds, infoopt) → {AsyncFunction}

+ + + + + +
+
import timeout from 'async/timeout';
+
+

Sets a time limit on an asynchronous function. If the function does not call +its callback within the specified milliseconds, it will be called with a +timeout error. The code property for the error object will be 'ETIMEDOUT'.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
asyncFn + + +AsyncFunction + + + + + +

The async function to limit in time.

milliseconds + + +number + + + + + +

The specified time limit.

info + + +* + + + + + + <optional> + +

Any variable you want attached (string, object, etc) +to timeout Error for more information..

+ + + + +
Returns:
+ + +
+

Returns a wrapped function that can be used with any +of the control flow functions. +Invoke this function with the same parameters as you would asyncFunc.

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + +
Example
+ +
function myFunction(foo, callback) {
+    doAsyncTask(foo, function(err, data) {
+        // handle errors
+        if (err) return callback(err);
+
+        // do some stuff ...
+
+        // return processed data
+        return callback(null, data);
+    });
+}
+
+var wrapped = async.timeout(myFunction, 1000);
+
+// call `wrapped` as you would `myFunction`
+wrapped({ bar: 'bar' }, function(err, data) {
+    // if `myFunction` takes < 1000 ms to execute, `err`
+    // and `data` will have their expected values
+
+    // else `err` will be an Error with the code 'ETIMEDOUT'
+});
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +

(static) unmemoize(fn) → {AsyncFunction}

+ + + + + +
+
import unmemoize from 'async/unmemoize';
+
+

Undoes a memoized function, reverting it to the original, +unmemoized form. Handy for testing.

+
+ + + + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fn + + +AsyncFunction + + + + + +

the memoized function

+ + + + +
Returns:
+ + +
+

a function that calls the original unmemoized function

+
+ + + +
+
+ Type +
+
+ +AsyncFunction + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/module-async.html b/docs/v3/module-async.html new file mode 100644 index 000000000..ead4f419d --- /dev/null +++ b/docs/v3/module-async.html @@ -0,0 +1,229 @@ + + + + + + + async - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

async

+ + + + + + + +
+ +
+ + + + + +
+ +
+
+ + +

Async is a utility module which provides straight-forward, powerful functions +for working with asynchronous JavaScript. Although originally designed for +use with Node.js and installable via +npm install --save async, it can also be used directly in the browser.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + +
See:
+
+ +
+ + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/nextTick.js.html b/docs/v3/nextTick.js.html new file mode 100644 index 000000000..c5617afee --- /dev/null +++ b/docs/v3/nextTick.js.html @@ -0,0 +1,154 @@ + + + + + + + nextTick.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

nextTick.js

+ + + + + + + +
+
+
/* istanbul ignore file */
+import { hasNextTick, hasSetImmediate, fallback, wrap }  from './internal/setImmediate.js'
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `process.nextTick`.  In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.setImmediate]{@link module:Utils.setImmediate}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ *     call_order.push('two');
+ *     // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ *     // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer;
+
+if (hasNextTick) {
+    _defer = process.nextTick;
+} else if (hasSetImmediate) {
+    _defer = setImmediate;
+} else {
+    _defer = fallback;
+}
+
+export default wrap(_defer);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/parallel.js.html b/docs/v3/parallel.js.html new file mode 100644 index 000000000..e5fefb6c4 --- /dev/null +++ b/docs/v3/parallel.js.html @@ -0,0 +1,274 @@ + + + + + + + parallel.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

parallel.js

+ + + + + + + +
+
+
import eachOf from './eachOf.js'
+import _parallel from './internal/parallel.js'
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code.  If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series.  Any synchronous setup
+ * sections for each task will happen one after the other.  JavaScript remains
+ * single-threaded.
+ *
+ * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
+ * execution of other tasks when a task fails.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ * @returns {Promise} a promise, if a callback is not passed
+ *
+ * @example
+ *
+ * //Using Callbacks
+ * async.parallel([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ], function(err, results) {
+ *     console.log(results);
+ *     // results is equal to ['one','two'] even though
+ *     // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }, function(err, results) {
+ *     console.log(results);
+ *     // results is equal to: { one: 1, two: 2 }
+ * });
+ *
+ * //Using Promises
+ * async.parallel([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ]).then(results => {
+ *     console.log(results);
+ *     // results is equal to ['one','two'] even though
+ *     // the second function had a shorter timeout.
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }).then(results => {
+ *     console.log(results);
+ *     // results is equal to: { one: 1, two: 2 }
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * //Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.parallel([
+ *             function(callback) {
+ *                 setTimeout(function() {
+ *                     callback(null, 'one');
+ *                 }, 200);
+ *             },
+ *             function(callback) {
+ *                 setTimeout(function() {
+ *                     callback(null, 'two');
+ *                 }, 100);
+ *             }
+ *         ]);
+ *         console.log(results);
+ *         // results is equal to ['one','two'] even though
+ *         // the second function had a shorter timeout.
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // an example using an object instead of an array
+ * async () => {
+ *     try {
+ *         let results = await async.parallel({
+ *             one: function(callback) {
+ *                 setTimeout(function() {
+ *                     callback(null, 1);
+ *                 }, 200);
+ *             },
+ *            two: function(callback) {
+ *                 setTimeout(function() {
+ *                     callback(null, 2);
+ *                 }, 100);
+ *            }
+ *         });
+ *         console.log(results);
+ *         // results is equal to: { one: 1, two: 2 }
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+export default function parallel(tasks, callback) {
+    return _parallel(eachOf, tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/parallelLimit.js.html b/docs/v3/parallelLimit.js.html new file mode 100644 index 000000000..4f7cf7688 --- /dev/null +++ b/docs/v3/parallelLimit.js.html @@ -0,0 +1,135 @@ + + + + + + + parallelLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

parallelLimit.js

+ + + + + + + +
+
+
import eachOfLimit from './internal/eachOfLimit.js'
+import parallel from './internal/parallel.js'
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ * @returns {Promise} a promise, if a callback is not passed
+ */
+export default function parallelLimit(tasks, limit, callback) {
+    return parallel(eachOfLimit(limit), tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/priorityQueue.js.html b/docs/v3/priorityQueue.js.html new file mode 100644 index 000000000..e1d8304df --- /dev/null +++ b/docs/v3/priorityQueue.js.html @@ -0,0 +1,177 @@ + + + + + + + priorityQueue.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

priorityQueue.js

+ + + + + + + +
+
+
import queue from './queue.js'
+import Heap from './internal/Heap.js'
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`.
+ * Invoked with (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel.  If omitted, the concurrency defaults to
+ * `1`.  If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are three
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ *   array of `tasks` is given, all tasks will be assigned the same priority.
+ * * `pushAsync(task, priority, [callback])` - the same as `priorityQueue.push`,
+ *   except this returns a promise that rejects if an error occurs.
+ * * The `unshift` and `unshiftAsync` methods were removed.
+ */
+export default function(worker, concurrency) {
+    // Start with a normal queue
+    var q = queue(worker, concurrency);
+
+    var {
+        push,
+        pushAsync
+    } = q;
+
+    q._tasks = new Heap();
+    q._createTaskItem = ({data, priority}, callback) => {
+        return {
+            data,
+            priority,
+            callback
+        };
+    };
+
+    function createDataItems(tasks, priority) {
+        if (!Array.isArray(tasks)) {
+            return {data: tasks, priority};
+        }
+        return tasks.map(data => { return {data, priority}; });
+    }
+
+    // Override push to accept second parameter representing priority
+    q.push = function(data, priority = 0, callback) {
+        return push(createDataItems(data, priority), callback);
+    };
+
+    q.pushAsync = function(data, priority = 0, callback) {
+        return pushAsync(createDataItems(data, priority), callback);
+    };
+
+    // Remove unshift functions
+    delete q.unshift;
+    delete q.unshiftAsync;
+
+    return q;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/queue.js.html b/docs/v3/queue.js.html new file mode 100644 index 000000000..fe2f7ce37 --- /dev/null +++ b/docs/v3/queue.js.html @@ -0,0 +1,260 @@ + + + + + + + queue.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

queue.js

+ + + + + + + +
+
+
import queue from './internal/queue.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Iterable} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {number} payload - an integer that specifies how many items are
+ * passed to the worker function at a time. only applies if this is a
+ * [cargo]{@link module:ControlFlow.cargo} object
+ * @property {AsyncFunction} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {AsyncFunction} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns
+ * a promise that rejects if an error occurs.
+ * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns
+ * a promise that rejects if an error occurs.
+ * @property {Function} remove - remove items from the queue that match a test
+ * function.  The test function will be passed an object with a `data` property,
+ * and a `priority` property, if this is a
+ * [priorityQueue]{@link module:ControlFlow.priorityQueue} object.
+ * Invoked with `queue.remove(testFn)`, where `testFn` is of the form
+ * `function ({data, priority}) {}` and returns a Boolean.
+ * @property {Function} saturated - a function that sets a callback that is
+ * called when the number of running workers hits the `concurrency` limit, and
+ * further tasks will be queued.  If the callback is omitted, `q.saturated()`
+ * returns a promise for the next occurrence.
+ * @property {Function} unsaturated - a function that sets a callback that is
+ * called when the number of running workers is less than the `concurrency` &
+ * `buffer` limits, and further tasks will not be queued. If the callback is
+ * omitted, `q.unsaturated()` returns a promise for the next occurrence.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a function that sets a callback that is called
+ * when the last item from the `queue` is given to a `worker`. If the callback
+ * is omitted, `q.empty()` returns a promise for the next occurrence.
+ * @property {Function} drain - a function that sets a callback that is called
+ * when the last item from the `queue` has returned from the `worker`. If the
+ * callback is omitted, `q.drain()` returns a promise for the next occurrence.
+ * @property {Function} error - a function that sets a callback that is called
+ * when a task errors. Has the signature `function(error, task)`. If the
+ * callback is omitted, `error()` returns a promise that rejects on the next
+ * error.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. No more tasks
+ * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
+ *
+ * @example
+ * const q = async.queue(worker, 2)
+ * q.push(item1)
+ * q.push(item2)
+ * q.push(item3)
+ * // queues are iterable, spread into an array to inspect
+ * const items = [...q] // [item1, item2, item3]
+ * // or use for of
+ * for (let item of q) {
+ *     console.log(item)
+ * }
+ *
+ * q.drain(() => {
+ *     console.log('all done')
+ * })
+ * // or
+ * await q.drain()
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`. Invoked with (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel.  If omitted, the concurrency
+ * defaults to `1`.  If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can be
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ *     console.log('hello ' + task.name);
+ *     callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain(function() {
+ *     console.log('all items have been processed');
+ * });
+ * // or await the end
+ * await q.drain()
+ *
+ * // assign an error callback
+ * q.error(function(err, task) {
+ *     console.error('task experienced an error');
+ * });
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ *     console.log('finished processing foo');
+ * });
+ * // callback is optional
+ * q.push({name: 'bar'});
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ *     console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ *     console.log('finished processing bar');
+ * });
+ */
+export default function (worker, concurrency) {
+    var _worker = wrapAsync(worker);
+    return queue((items, cb) => {
+        _worker(items[0], cb);
+    }, concurrency, 1);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/race.js.html b/docs/v3/race.js.html new file mode 100644 index 000000000..34cbdecb4 --- /dev/null +++ b/docs/v3/race.js.html @@ -0,0 +1,159 @@ + + + + + + + race.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

race.js

+ + + + + + + +
+
+
import once from './internal/once.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
+ * to run. Each function can complete with an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns {Promise} a promise, if a callback is omitted
+ * @example
+ *
+ * async.race([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ],
+ * // main callback
+ * function(err, result) {
+ *     // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+    callback = once(callback);
+    if (!Array.isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+    if (!tasks.length) return callback();
+    for (var i = 0, l = tasks.length; i < l; i++) {
+        wrapAsync(tasks[i])(callback);
+    }
+}
+
+export default awaitify(race, 2)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/reduce.js.html b/docs/v3/reduce.js.html new file mode 100644 index 000000000..f0f279498 --- /dev/null +++ b/docs/v3/reduce.js.html @@ -0,0 +1,242 @@ + + + + + + + reduce.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reduce.js

+ + + + + + + +
+
+
import eachOfSeries from './eachOfSeries.js'
+import once from './internal/once.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee completes with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * // file1.txt is a file that is 1000 bytes in size
+ * // file2.txt is a file that is 2000 bytes in size
+ * // file3.txt is a file that is 3000 bytes in size
+ * // file4.txt does not exist
+ *
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
+ * const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt'];
+ *
+ * // asynchronous function that computes the file size in bytes
+ * // file size is added to the memoized value, then returned
+ * function getFileSizeInBytes(memo, file, callback) {
+ *     fs.stat(file, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         callback(null, memo + stat.size);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) {
+ *     if (err) {
+ *         console.log(err);
+ *     } else {
+ *         console.log(result);
+ *         // 6000
+ *         // which is the sum of the file sizes of the three files
+ *     }
+ * });
+ *
+ * // Error Handling
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) {
+ *     if (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     } else {
+ *         console.log(result);
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.reduce(fileList, 0, getFileSizeInBytes)
+ * .then( result => {
+ *     console.log(result);
+ *     // 6000
+ *     // which is the sum of the file sizes of the three files
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Error Handling
+ * async.reduce(withMissingFileList, 0, getFileSizeInBytes)
+ * .then( result => {
+ *     console.log(result);
+ * }).catch( err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.reduce(fileList, 0, getFileSizeInBytes);
+ *         console.log(result);
+ *         // 6000
+ *         // which is the sum of the file sizes of the three files
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // Error Handling
+ * async () => {
+ *     try {
+ *         let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes);
+ *         console.log(result);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     }
+ * }
+ *
+ */
+function reduce(coll, memo, iteratee, callback) {
+    callback = once(callback);
+    var _iteratee = wrapAsync(iteratee);
+    return eachOfSeries(coll, (x, i, iterCb) => {
+        _iteratee(memo, x, (err, v) => {
+            memo = v;
+            iterCb(err);
+        });
+    }, err => callback(err, memo));
+}
+export default awaitify(reduce, 4)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/reduceRight.js.html b/docs/v3/reduceRight.js.html new file mode 100644 index 000000000..831fd81dc --- /dev/null +++ b/docs/v3/reduceRight.js.html @@ -0,0 +1,138 @@ + + + + + + + reduceRight.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reduceRight.js

+ + + + + + + +
+
+
import reduce from './reduce.js'
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee completes with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+export default function reduceRight (array, memo, iteratee, callback) {
+    var reversed = [...array].reverse();
+    return reduce(reversed, memo, iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/reflect.js.html b/docs/v3/reflect.js.html new file mode 100644 index 000000000..66eb059dc --- /dev/null +++ b/docs/v3/reflect.js.html @@ -0,0 +1,172 @@ + + + + + + + reflect.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reflect.js

+ + + + + + + +
+
+
import initialParams from './internal/initialParams.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * Wraps the async function in another function that always completes with a
+ * result object, even when it errors.
+ *
+ * The result object has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ *     async.reflect(function(callback) {
+ *         // do some stuff ...
+ *         callback(null, 'one');
+ *     }),
+ *     async.reflect(function(callback) {
+ *         // do some more stuff but error ...
+ *         callback('bad stuff happened');
+ *     }),
+ *     async.reflect(function(callback) {
+ *         // do some more stuff ...
+ *         callback(null, 'two');
+ *     })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results[0].value = 'one'
+ *     // results[1].error = 'bad stuff happened'
+ *     // results[2].value = 'two'
+ * });
+ */
+export default function reflect(fn) {
+    var _fn = wrapAsync(fn);
+    return initialParams(function reflectOn(args, reflectCallback) {
+        args.push((error, ...cbArgs) => {
+            let retVal = {};
+            if (error) {
+                retVal.error = error;
+            }
+            if (cbArgs.length > 0){
+                var value = cbArgs;
+                if (cbArgs.length <= 1) {
+                    [value] = cbArgs;
+                }
+                retVal.value = value;
+            }
+            reflectCallback(null, retVal);
+        });
+
+        return _fn.apply(this, args);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/reflectAll.js.html b/docs/v3/reflectAll.js.html new file mode 100644 index 000000000..044f2e2b7 --- /dev/null +++ b/docs/v3/reflectAll.js.html @@ -0,0 +1,190 @@ + + + + + + + reflectAll.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reflectAll.js

+ + + + + + + +
+
+
import reflect from './reflect.js'
+
+/**
+ * A helper function that wraps an array or an object of functions with `reflect`.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array|Object|Iterable} tasks - The collection of
+ * [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of async functions, each wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         // do some more stuff but error ...
+ *         callback(new Error('bad stuff happened'));
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results[0].value = 'one'
+ *     // results[1].error = Error('bad stuff happened')
+ *     // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         callback('two');
+ *     },
+ *     three: function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'three');
+ *         }, 100);
+ *     }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ *     // values
+ *     // results.one.value = 'one'
+ *     // results.two.error = 'two'
+ *     // results.three.value = 'three'
+ * });
+ */
+export default function reflectAll(tasks) {
+    var results;
+    if (Array.isArray(tasks)) {
+        results = tasks.map(reflect);
+    } else {
+        results = {};
+        Object.keys(tasks).forEach(key => {
+            results[key] = reflect.call(this, tasks[key]);
+        });
+    }
+    return results;
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/reject.js.html b/docs/v3/reject.js.html new file mode 100644 index 000000000..0613eaae3 --- /dev/null +++ b/docs/v3/reject.js.html @@ -0,0 +1,179 @@ + + + + + + + reject.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

reject.js

+ + + + + + + +
+
+
import _reject from './internal/reject.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ *
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ *    fs.access(file, fs.constants.F_OK, (err) => {
+ *        callback(null, !err);
+ *    });
+ * }
+ *
+ * // Using callbacks
+ * async.reject(fileList, fileExists, function(err, results) {
+ *    // [ 'dir3/file6.txt' ]
+ *    // results now equals an array of the non-existing files
+ * });
+ *
+ * // Using Promises
+ * async.reject(fileList, fileExists)
+ * .then( results => {
+ *     console.log(results);
+ *     // [ 'dir3/file6.txt' ]
+ *     // results now equals an array of the non-existing files
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.reject(fileList, fileExists);
+ *         console.log(results);
+ *         // [ 'dir3/file6.txt' ]
+ *         // results now equals an array of the non-existing files
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+function reject (coll, iteratee, callback) {
+    return _reject(eachOf, coll, iteratee, callback)
+}
+export default awaitify(reject, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/rejectLimit.js.html b/docs/v3/rejectLimit.js.html new file mode 100644 index 000000000..46689fff0 --- /dev/null +++ b/docs/v3/rejectLimit.js.html @@ -0,0 +1,136 @@ + + + + + + + rejectLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

rejectLimit.js

+ + + + + + + +
+
+
import _reject from './internal/reject.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function rejectLimit (coll, limit, iteratee, callback) {
+    return _reject(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(rejectLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/rejectSeries.js.html b/docs/v3/rejectSeries.js.html new file mode 100644 index 000000000..6de3ab096 --- /dev/null +++ b/docs/v3/rejectSeries.js.html @@ -0,0 +1,135 @@ + + + + + + + rejectSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

rejectSeries.js

+ + + + + + + +
+
+
import _reject from './internal/reject.js'
+import eachOfSeries from './eachOfSeries.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ */
+function rejectSeries (coll, iteratee, callback) {
+    return _reject(eachOfSeries, coll, iteratee, callback)
+}
+export default awaitify(rejectSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/retry.js.html b/docs/v3/retry.js.html new file mode 100644 index 000000000..f58669787 --- /dev/null +++ b/docs/v3/retry.js.html @@ -0,0 +1,259 @@ + + + + + + + retry.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

retry.js

+ + + + + + + +
+
+
import wrapAsync from './internal/wrapAsync.js'
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js'
+
+function constant(value) {
+    return function () {
+        return value;
+    }
+}
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @see [async.retryable]{@link module:ControlFlow.retryable}
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up.  The default
+ *   is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds.  The
+ *   default is `0`. The interval may also be specified as a function of the
+ *   retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ *   erroneous result. If it returns `true` the retry attempts will continue;
+ *   if the function returns `false` the retry flow is aborted with the current
+ *   attempt's error and result being returned to the final callback.
+ *   Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ *   with the default interval of `0`.
+ * @param {AsyncFunction} task - An async function to retry.
+ * Invoked with (callback).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ * @returns {Promise} a promise if no callback provided
+ *
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ *   times: 10,
+ *   interval: function(retryCount) {
+ *     return 50 * Math.pow(2, retryCount);
+ *   }
+ * }, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ *   errorFilter: function(err) {
+ *     return err.message === 'Temporary error'; // only retry on a specific error
+ *   }
+ * }, apiMethod, function(err, result) {
+ *     // do something with the result
+ * });
+ *
+ * // to retry individual methods that are not as reliable within other
+ * // control flow functions, use the `retryable` wrapper:
+ * async.auto({
+ *     users: api.getUsers.bind(api),
+ *     payments: async.retryable(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ *     // do something with the results
+ * });
+ *
+ */
+const DEFAULT_TIMES = 5;
+const DEFAULT_INTERVAL = 0;
+
+export default function retry(opts, task, callback) {
+    var options = {
+        times: DEFAULT_TIMES,
+        intervalFunc: constant(DEFAULT_INTERVAL)
+    };
+
+    if (arguments.length < 3 && typeof opts === 'function') {
+        callback = task || promiseCallback();
+        task = opts;
+    } else {
+        parseTimes(options, opts);
+        callback = callback || promiseCallback();
+    }
+
+    if (typeof task !== 'function') {
+        throw new Error("Invalid arguments for async.retry");
+    }
+
+    var _task = wrapAsync(task);
+
+    var attempt = 1;
+    function retryAttempt() {
+        _task((err, ...args) => {
+            if (err === false) return
+            if (err && attempt++ < options.times &&
+                (typeof options.errorFilter != 'function' ||
+                    options.errorFilter(err))) {
+                setTimeout(retryAttempt, options.intervalFunc(attempt - 1));
+            } else {
+                callback(err, ...args);
+            }
+        });
+    }
+
+    retryAttempt();
+    return callback[PROMISE_SYMBOL]
+}
+
+function parseTimes(acc, t) {
+    if (typeof t === 'object') {
+        acc.times = +t.times || DEFAULT_TIMES;
+
+        acc.intervalFunc = typeof t.interval === 'function' ?
+            t.interval :
+            constant(+t.interval || DEFAULT_INTERVAL);
+
+        acc.errorFilter = t.errorFilter;
+    } else if (typeof t === 'number' || typeof t === 'string') {
+        acc.times = +t || DEFAULT_TIMES;
+    } else {
+        throw new Error("Invalid arguments for async.retry");
+    }
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/retryable.js.html b/docs/v3/retryable.js.html new file mode 100644 index 000000000..218682807 --- /dev/null +++ b/docs/v3/retryable.js.html @@ -0,0 +1,168 @@ + + + + + + + retryable.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

retryable.js

+ + + + + + + +
+
+
import retry from './retry.js'
+import initialParams from './internal/initialParams.js'
+import {default as wrapAsync, isAsync} from './internal/wrapAsync.js'
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js'
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}.  This method
+ * wraps a task and makes it retryable, rather than immediately calling it
+ * with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`, except for a `opts.arity` that
+ * is the arity of the `task` function, defaulting to `task.length`
+ * @param {AsyncFunction} task - the asynchronous function to wrap.
+ * This function will be passed any arguments passed to the returned wrapper.
+ * Invoked with (...args, callback).
+ * @returns {AsyncFunction} The wrapped function, which when invoked, will
+ * retry on an error, based on the parameters specified in `opts`.
+ * This function will accept the same parameters as `task`.
+ * @example
+ *
+ * async.auto({
+ *     dep1: async.retryable(3, getFromFlakyService),
+ *     process: ["dep1", async.retryable(3, function (results, cb) {
+ *         maybeProcessData(results.dep1, cb);
+ *     })]
+ * }, callback);
+ */
+export default function retryable (opts, task) {
+    if (!task) {
+        task = opts;
+        opts = null;
+    }
+    let arity = (opts && opts.arity) || task.length
+    if (isAsync(task)) {
+        arity += 1
+    }
+    var _task = wrapAsync(task);
+    return initialParams((args, callback) => {
+        if (args.length < arity - 1 || callback == null) {
+            args.push(callback)
+            callback = promiseCallback()
+        }
+        function taskFn(cb) {
+            _task(...args, cb);
+        }
+
+        if (opts) retry(opts, taskFn, callback);
+        else retry(taskFn, callback);
+
+        return callback[PROMISE_SYMBOL]
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/scripts/async.js b/docs/v3/scripts/async.js new file mode 100644 index 000000000..d7b791898 --- /dev/null +++ b/docs/v3/scripts/async.js @@ -0,0 +1,6061 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.async = {})); +})(this, (function (exports) { 'use strict'; + + /** + * Creates a continuation function with some arguments already applied. + * + * Useful as a shorthand when combined with other control flow functions. Any + * arguments passed to the returned function are added to the arguments + * originally passed to apply. + * + * @name apply + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {Function} fn - The function you want to eventually apply all + * arguments to. Invokes with (arguments...). + * @param {...*} arguments... - Any number of arguments to automatically apply + * when the continuation is called. + * @returns {Function} the partially-applied function + * @example + * + * // using apply + * async.parallel([ + * async.apply(fs.writeFile, 'testfile1', 'test1'), + * async.apply(fs.writeFile, 'testfile2', 'test2') + * ]); + * + * + * // the same process without using apply + * async.parallel([ + * function(callback) { + * fs.writeFile('testfile1', 'test1', callback); + * }, + * function(callback) { + * fs.writeFile('testfile2', 'test2', callback); + * } + * ]); + * + * // It's possible to pass any number of additional arguments when calling the + * // continuation: + * + * node> var fn = async.apply(sys.puts, 'one'); + * node> fn('two', 'three'); + * one + * two + * three + */ + function apply(fn, ...args) { + return (...callArgs) => fn(...args,...callArgs); + } + + function initialParams (fn) { + return function (...args/*, callback*/) { + var callback = args.pop(); + return fn.call(this, args, callback); + }; + } + + /* istanbul ignore file */ + + var hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask; + var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; + var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; + + function fallback(fn) { + setTimeout(fn, 0); + } + + function wrap(defer) { + return (fn, ...args) => defer(() => fn(...args)); + } + + var _defer$1; + + if (hasQueueMicrotask) { + _defer$1 = queueMicrotask; + } else if (hasSetImmediate) { + _defer$1 = setImmediate; + } else if (hasNextTick) { + _defer$1 = process.nextTick; + } else { + _defer$1 = fallback; + } + + var setImmediate$1 = wrap(_defer$1); + + /** + * Take a sync function and make it async, passing its return value to a + * callback. This is useful for plugging sync functions into a waterfall, + * series, or other async functions. Any arguments passed to the generated + * function will be passed to the wrapped function (except for the final + * callback argument). Errors thrown will be passed to the callback. + * + * If the function passed to `asyncify` returns a Promise, that promises's + * resolved/rejected state will be used to call the callback, rather than simply + * the synchronous return value. + * + * This also means you can asyncify ES2017 `async` functions. + * + * @name asyncify + * @static + * @memberOf module:Utils + * @method + * @alias wrapSync + * @category Util + * @param {Function} func - The synchronous function, or Promise-returning + * function to convert to an {@link AsyncFunction}. + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be + * invoked with `(args..., callback)`. + * @example + * + * // passing a regular synchronous function + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(JSON.parse), + * function (data, next) { + * // data is the result of parsing the text. + * // If there was a parsing error, it would have been caught. + * } + * ], callback); + * + * // passing a function returning a promise + * async.waterfall([ + * async.apply(fs.readFile, filename, "utf8"), + * async.asyncify(function (contents) { + * return db.model.create(contents); + * }), + * function (model, next) { + * // `model` is the instantiated model object. + * // If there was an error, this function would be skipped. + * } + * ], callback); + * + * // es2017 example, though `asyncify` is not needed if your JS environment + * // supports async functions out of the box + * var q = async.queue(async.asyncify(async function(file) { + * var intermediateStep = await processFile(file); + * return await somePromise(intermediateStep) + * })); + * + * q.push(files); + */ + function asyncify(func) { + if (isAsync(func)) { + return function (...args/*, callback*/) { + const callback = args.pop(); + const promise = func.apply(this, args); + return handlePromise(promise, callback) + } + } + + return initialParams(function (args, callback) { + var result; + try { + result = func.apply(this, args); + } catch (e) { + return callback(e); + } + // if result is Promise object + if (result && typeof result.then === 'function') { + return handlePromise(result, callback) + } else { + callback(null, result); + } + }); + } + + function handlePromise(promise, callback) { + return promise.then(value => { + invokeCallback(callback, null, value); + }, err => { + invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err)); + }); + } + + function invokeCallback(callback, error, value) { + try { + callback(error, value); + } catch (err) { + setImmediate$1(e => { throw e }, err); + } + } + + function isAsync(fn) { + return fn[Symbol.toStringTag] === 'AsyncFunction'; + } + + function isAsyncGenerator(fn) { + return fn[Symbol.toStringTag] === 'AsyncGenerator'; + } + + function isAsyncIterable(obj) { + return typeof obj[Symbol.asyncIterator] === 'function'; + } + + function wrapAsync(asyncFn) { + if (typeof asyncFn !== 'function') throw new Error('expected a function') + return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; + } + + // conditionally promisify a function. + // only return a promise if a callback is omitted + function awaitify (asyncFn, arity) { + if (!arity) arity = asyncFn.length; + if (!arity) throw new Error('arity is undefined') + function awaitable (...args) { + if (typeof args[arity - 1] === 'function') { + return asyncFn.apply(this, args) + } + + return new Promise((resolve, reject) => { + args[arity - 1] = (err, ...cbArgs) => { + if (err) return reject(err) + resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]); + }; + asyncFn.apply(this, args); + }) + } + + return awaitable + } + + function applyEach$1 (eachfn) { + return function applyEach(fns, ...callArgs) { + const go = awaitify(function (callback) { + var that = this; + return eachfn(fns, (fn, cb) => { + wrapAsync(fn).apply(that, callArgs.concat(cb)); + }, callback); + }); + return go; + }; + } + + function _asyncMap(eachfn, arr, iteratee, callback) { + arr = arr || []; + var results = []; + var counter = 0; + var _iteratee = wrapAsync(iteratee); + + return eachfn(arr, (value, _, iterCb) => { + var index = counter++; + _iteratee(value, (err, v) => { + results[index] = v; + iterCb(err); + }); + }, err => { + callback(err, results); + }); + } + + function isArrayLike(value) { + return value && + typeof value.length === 'number' && + value.length >= 0 && + value.length % 1 === 0; + } + + // A temporary value used to identify if the loop should be broken. + // See #1064, #1293 + const breakLoop = {}; + + function once(fn) { + function wrapper (...args) { + if (fn === null) return; + var callFn = fn; + fn = null; + callFn.apply(this, args); + } + Object.assign(wrapper, fn); + return wrapper + } + + function getIterator (coll) { + return coll[Symbol.iterator] && coll[Symbol.iterator](); + } + + function createArrayIterator(coll) { + var i = -1; + var len = coll.length; + return function next() { + return ++i < len ? {value: coll[i], key: i} : null; + } + } + + function createES2015Iterator(iterator) { + var i = -1; + return function next() { + var item = iterator.next(); + if (item.done) + return null; + i++; + return {value: item.value, key: i}; + } + } + + function createObjectIterator(obj) { + var okeys = obj ? Object.keys(obj) : []; + var i = -1; + var len = okeys.length; + return function next() { + var key = okeys[++i]; + if (key === '__proto__') { + return next(); + } + return i < len ? {value: obj[key], key} : null; + }; + } + + function createIterator(coll) { + if (isArrayLike(coll)) { + return createArrayIterator(coll); + } + + var iterator = getIterator(coll); + return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll); + } + + function onlyOnce(fn) { + return function (...args) { + if (fn === null) throw new Error("Callback was already called."); + var callFn = fn; + fn = null; + callFn.apply(this, args); + }; + } + + // for async generators + function asyncEachOfLimit(generator, limit, iteratee, callback) { + let done = false; + let canceled = false; + let awaiting = false; + let running = 0; + let idx = 0; + + function replenish() { + //console.log('replenish') + if (running >= limit || awaiting || done) return + //console.log('replenish awaiting') + awaiting = true; + generator.next().then(({value, done: iterDone}) => { + //console.log('got value', value) + if (canceled || done) return + awaiting = false; + if (iterDone) { + done = true; + if (running <= 0) { + //console.log('done nextCb') + callback(null); + } + return; + } + running++; + iteratee(value, idx, iterateeCallback); + idx++; + replenish(); + }).catch(handleError); + } + + function iterateeCallback(err, result) { + //console.log('iterateeCallback') + running -= 1; + if (canceled) return + if (err) return handleError(err) + + if (err === false) { + done = true; + canceled = true; + return + } + + if (result === breakLoop || (done && running <= 0)) { + done = true; + //console.log('done iterCb') + return callback(null); + } + replenish(); + } + + function handleError(err) { + if (canceled) return + awaiting = false; + done = true; + callback(err); + } + + replenish(); + } + + var eachOfLimit$2 = (limit) => { + return (obj, iteratee, callback) => { + callback = once(callback); + if (limit <= 0) { + throw new RangeError('concurrency limit cannot be less than 1') + } + if (!obj) { + return callback(null); + } + if (isAsyncGenerator(obj)) { + return asyncEachOfLimit(obj, limit, iteratee, callback) + } + if (isAsyncIterable(obj)) { + return asyncEachOfLimit(obj[Symbol.asyncIterator](), limit, iteratee, callback) + } + var nextElem = createIterator(obj); + var done = false; + var canceled = false; + var running = 0; + var looping = false; + + function iterateeCallback(err, value) { + if (canceled) return + running -= 1; + if (err) { + done = true; + callback(err); + } + else if (err === false) { + done = true; + canceled = true; + } + else if (value === breakLoop || (done && running <= 0)) { + done = true; + return callback(null); + } + else if (!looping) { + replenish(); + } + } + + function replenish () { + looping = true; + while (running < limit && !done) { + var elem = nextElem(); + if (elem === null) { + done = true; + if (running <= 0) { + callback(null); + } + return; + } + running += 1; + iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); + } + looping = false; + } + + replenish(); + }; + }; + + /** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a + * time. + * + * @name eachOfLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. The `key` is the item's key, or index in the case of an + * array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachOfLimit(coll, limit, iteratee, callback) { + return eachOfLimit$2(limit)(coll, wrapAsync(iteratee), callback); + } + + var eachOfLimit$1 = awaitify(eachOfLimit, 4); + + // eachOf implementation optimized for array-likes + function eachOfArrayLike(coll, iteratee, callback) { + callback = once(callback); + var index = 0, + completed = 0, + {length} = coll, + canceled = false; + if (length === 0) { + callback(null); + } + + function iteratorCallback(err, value) { + if (err === false) { + canceled = true; + } + if (canceled === true) return + if (err) { + callback(err); + } else if ((++completed === length) || value === breakLoop) { + callback(null); + } + } + + for (; index < length; index++) { + iteratee(coll[index], index, onlyOnce(iteratorCallback)); + } + } + + // a generic version of eachOf which can handle array, object, and iterator cases. + function eachOfGeneric (coll, iteratee, callback) { + return eachOfLimit$1(coll, Infinity, iteratee, callback); + } + + /** + * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument + * to the iteratee. + * + * @name eachOf + * @static + * @memberOf module:Collections + * @method + * @alias forEachOf + * @category Collection + * @see [async.each]{@link module:Collections.each} + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each + * item in `coll`. + * The `key` is the item's key, or index in the case of an array. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dev.json is a file containing a valid json object config for dev environment + * // dev.json is a file containing a valid json object config for test environment + * // prod.json is a file containing a valid json object config for prod environment + * // invalid.json is a file with a malformed json object + * + * let configs = {}; //global variable + * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'}; + * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'}; + * + * // asynchronous function that reads a json file and parses the contents as json object + * function parseFile(file, key, callback) { + * fs.readFile(file, "utf8", function(err, data) { + * if (err) return calback(err); + * try { + * configs[key] = JSON.parse(data); + * } catch (e) { + * return callback(e); + * } + * callback(); + * }); + * } + * + * // Using callbacks + * async.forEachOf(validConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * } else { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * // JSON parse error exception + * } else { + * console.log(configs); + * } + * }); + * + * // Using Promises + * async.forEachOf(validConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * }).catch( err => { + * console.error(err); + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * }).catch( err => { + * console.error(err); + * // JSON parse error exception + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.forEachOf(validConfigFileMap, parseFile); + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * catch (err) { + * console.log(err); + * } + * } + * + * //Error handing + * async () => { + * try { + * let result = await async.forEachOf(invalidConfigFileMap, parseFile); + * console.log(configs); + * } + * catch (err) { + * console.log(err); + * // JSON parse error exception + * } + * } + * + */ + function eachOf(coll, iteratee, callback) { + var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; + return eachOfImplementation(coll, wrapAsync(iteratee), callback); + } + + var eachOf$1 = awaitify(eachOf, 3); + + /** + * Produces a new collection of values by mapping each value in `coll` through + * the `iteratee` function. The `iteratee` is called with an item from `coll` + * and a callback for when it has finished processing. Each of these callbacks + * takes 2 arguments: an `error`, and the transformed item from `coll`. If + * `iteratee` passes an error to its callback, the main `callback` (for the + * `map` function) is immediately called with the error. + * + * Note, that since this function applies the `iteratee` to each item in + * parallel, there is no guarantee that the `iteratee` functions will complete + * in order. However, the results array will be in the same order as the + * original `coll`. + * + * If `map` is passed an Object, the results will be an Array. The results + * will roughly be in the order of the original Objects' keys (but this can + * vary across JavaScript engines). + * + * @name map + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an Array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.map(fileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * }); + * + * // Using Promises + * async.map(fileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.map(fileList, getFileSizeInBytes); + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.map(withMissingFileList, getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function map (coll, iteratee, callback) { + return _asyncMap(eachOf$1, coll, iteratee, callback) + } + var map$1 = awaitify(map, 3); + + /** + * Applies the provided arguments to each function in the array, calling + * `callback` after all functions have completed. If you only provide the first + * argument, `fns`, then it will return a function which lets you pass in the + * arguments as if it were a single function call. If more arguments are + * provided, `callback` is required while `args` is still optional. The results + * for each of the applied async functions are passed to the final callback + * as an array. + * + * @name applyEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s + * to all call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {AsyncFunction} - Returns a function that takes no args other than + * an optional callback, that is the result of applying the `args` to each + * of the functions. + * @example + * + * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket') + * + * appliedFn((err, results) => { + * // results[0] is the results for `enableSearch` + * // results[1] is the results for `updateSchema` + * }); + * + * // partial application example: + * async.each( + * buckets, + * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(), + * callback + * ); + */ + var applyEach = applyEach$1(map$1); + + /** + * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time. + * + * @name eachOfSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.eachOf]{@link module:Collections.eachOf} + * @alias forEachOfSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * Invoked with (item, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachOfSeries(coll, iteratee, callback) { + return eachOfLimit$1(coll, 1, iteratee, callback) + } + var eachOfSeries$1 = awaitify(eachOfSeries, 3); + + /** + * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. + * + * @name mapSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function mapSeries (coll, iteratee, callback) { + return _asyncMap(eachOfSeries$1, coll, iteratee, callback) + } + var mapSeries$1 = awaitify(mapSeries, 3); + + /** + * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. + * + * @name applyEachSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.applyEach]{@link module:ControlFlow.applyEach} + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all + * call with the same arguments + * @param {...*} [args] - any number of separate arguments to pass to the + * function. + * @param {Function} [callback] - the final argument should be the callback, + * called when all functions have completed processing. + * @returns {AsyncFunction} - A function, that when called, is the result of + * appling the `args` to the list of functions. It takes no args, other than + * a callback. + */ + var applyEachSeries = applyEach$1(mapSeries$1); + + const PROMISE_SYMBOL = Symbol('promiseCallback'); + + function promiseCallback () { + let resolve, reject; + function callback (err, ...args) { + if (err) return reject(err) + resolve(args.length > 1 ? args : args[0]); + } + + callback[PROMISE_SYMBOL] = new Promise((res, rej) => { + resolve = res, + reject = rej; + }); + + return callback + } + + /** + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on + * their requirements. Each function can optionally depend on other functions + * being completed first, and each function is run as soon as its requirements + * are satisfied. + * + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence + * will stop. Further tasks will not execute (so any other functions depending + * on it will not run), and the main `callback` is immediately called with the + * error. + * + * {@link AsyncFunction}s also receive an object containing the results of functions which + * have completed so far as the first argument, if they have dependencies. If a + * task function has no dependencies, it will only be passed a callback. + * + * @name auto + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Object} tasks - An object. Each of its properties is either a + * function or an array of requirements, with the {@link AsyncFunction} itself the last item + * in the array. The object's key of a property serves as the name of the task + * defined by that property, i.e. can be used when specifying requirements for + * other tasks. The function receives one or two arguments: + * * a `results` object, containing the results of the previously executed + * functions, only passed if the task has any dependencies, + * * a `callback(err, result)` function, which must be called when finished, + * passing an `error` (which can be `null`) and the result of the function's + * execution. + * @param {number} [concurrency=Infinity] - An optional `integer` for + * determining the maximum number of tasks that can be run in parallel. By + * default, as many as possible. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback. Results are always returned; however, if an + * error occurs, no further `tasks` will be performed, and the results object + * will only contain partial results. Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + * @example + * + * //Using Callbacks + * async.auto({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }, function(err, results) { + * if (err) { + * console.log('err = ', err); + * } + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }); + * + * //Using Promises + * async.auto({ + * get_data: function(callback) { + * console.log('in get_data'); + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * console.log('in make_folder'); + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }).then(results => { + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }).catch(err => { + * console.log('err = ', err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.auto({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }); + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function auto(tasks, concurrency, callback) { + if (typeof concurrency !== 'number') { + // concurrency is optional, shift the args. + callback = concurrency; + concurrency = null; + } + callback = once(callback || promiseCallback()); + var numTasks = Object.keys(tasks).length; + if (!numTasks) { + return callback(null); + } + if (!concurrency) { + concurrency = numTasks; + } + + var results = {}; + var runningTasks = 0; + var canceled = false; + var hasError = false; + + var listeners = Object.create(null); + + var readyTasks = []; + + // for cycle detection: + var readyToCheck = []; // tasks that have been identified as reachable + // without the possibility of returning to an ancestor task + var uncheckedDependencies = {}; + + Object.keys(tasks).forEach(key => { + var task = tasks[key]; + if (!Array.isArray(task)) { + // no dependencies + enqueueTask(key, [task]); + readyToCheck.push(key); + return; + } + + var dependencies = task.slice(0, task.length - 1); + var remainingDependencies = dependencies.length; + if (remainingDependencies === 0) { + enqueueTask(key, task); + readyToCheck.push(key); + return; + } + uncheckedDependencies[key] = remainingDependencies; + + dependencies.forEach(dependencyName => { + if (!tasks[dependencyName]) { + throw new Error('async.auto task `' + key + + '` has a non-existent dependency `' + + dependencyName + '` in ' + + dependencies.join(', ')); + } + addListener(dependencyName, () => { + remainingDependencies--; + if (remainingDependencies === 0) { + enqueueTask(key, task); + } + }); + }); + }); + + checkForDeadlocks(); + processQueue(); + + function enqueueTask(key, task) { + readyTasks.push(() => runTask(key, task)); + } + + function processQueue() { + if (canceled) return + if (readyTasks.length === 0 && runningTasks === 0) { + return callback(null, results); + } + while(readyTasks.length && runningTasks < concurrency) { + var run = readyTasks.shift(); + run(); + } + + } + + function addListener(taskName, fn) { + var taskListeners = listeners[taskName]; + if (!taskListeners) { + taskListeners = listeners[taskName] = []; + } + + taskListeners.push(fn); + } + + function taskComplete(taskName) { + var taskListeners = listeners[taskName] || []; + taskListeners.forEach(fn => fn()); + processQueue(); + } + + + function runTask(key, task) { + if (hasError) return; + + var taskCallback = onlyOnce((err, ...result) => { + runningTasks--; + if (err === false) { + canceled = true; + return + } + if (result.length < 2) { + [result] = result; + } + if (err) { + var safeResults = {}; + Object.keys(results).forEach(rkey => { + safeResults[rkey] = results[rkey]; + }); + safeResults[key] = result; + hasError = true; + listeners = Object.create(null); + if (canceled) return + callback(err, safeResults); + } else { + results[key] = result; + taskComplete(key); + } + }); + + runningTasks++; + var taskFn = wrapAsync(task[task.length - 1]); + if (task.length > 1) { + taskFn(results, taskCallback); + } else { + taskFn(taskCallback); + } + } + + function checkForDeadlocks() { + // Kahn's algorithm + // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm + // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html + var currentTask; + var counter = 0; + while (readyToCheck.length) { + currentTask = readyToCheck.pop(); + counter++; + getDependents(currentTask).forEach(dependent => { + if (--uncheckedDependencies[dependent] === 0) { + readyToCheck.push(dependent); + } + }); + } + + if (counter !== numTasks) { + throw new Error( + 'async.auto cannot execute tasks due to a recursive dependency' + ); + } + } + + function getDependents(taskName) { + var result = []; + Object.keys(tasks).forEach(key => { + const task = tasks[key]; + if (Array.isArray(task) && task.indexOf(taskName) >= 0) { + result.push(key); + } + }); + return result; + } + + return callback[PROMISE_SYMBOL] + } + + var FN_ARGS = /^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/; + var ARROW_FN_ARGS = /^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/; + var FN_ARG_SPLIT = /,/; + var FN_ARG = /(=.+)?(\s*)$/; + + function stripComments(string) { + let stripped = ''; + let index = 0; + let endBlockComment = string.indexOf('*/'); + while (index < string.length) { + if (string[index] === '/' && string[index+1] === '/') { + // inline comment + let endIndex = string.indexOf('\n', index); + index = (endIndex === -1) ? string.length : endIndex; + } else if ((endBlockComment !== -1) && (string[index] === '/') && (string[index+1] === '*')) { + // block comment + let endIndex = string.indexOf('*/', index); + if (endIndex !== -1) { + index = endIndex + 2; + endBlockComment = string.indexOf('*/', index); + } else { + stripped += string[index]; + index++; + } + } else { + stripped += string[index]; + index++; + } + } + return stripped; + } + + function parseParams(func) { + const src = stripComments(func.toString()); + let match = src.match(FN_ARGS); + if (!match) { + match = src.match(ARROW_FN_ARGS); + } + if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src) + let [, args] = match; + return args + .replace(/\s/g, '') + .split(FN_ARG_SPLIT) + .map((arg) => arg.replace(FN_ARG, '').trim()); + } + + /** + * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent + * tasks are specified as parameters to the function, after the usual callback + * parameter, with the parameter names matching the names of the tasks it + * depends on. This can provide even more readable task graphs which can be + * easier to maintain. + * + * If a final callback is specified, the task results are similarly injected, + * specified as named parameters after the initial error parameter. + * + * The autoInject function is purely syntactic sugar and its semantics are + * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}. + * + * @name autoInject + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.auto]{@link module:ControlFlow.auto} + * @category Control Flow + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of + * the form 'func([dependencies...], callback). The object's key of a property + * serves as the name of the task defined by that property, i.e. can be used + * when specifying requirements for other tasks. + * * The `callback` parameter is a `callback(err, result)` which must be called + * when finished, passing an `error` (which can be `null`) and the result of + * the function's execution. The remaining parameters name other tasks on + * which the task is dependent, and the results from those tasks are the + * arguments of those parameters. + * @param {Function} [callback] - An optional callback which is called when all + * the tasks have been completed. It receives the `err` argument if any `tasks` + * pass an error to their callback, and a `results` object with any completed + * task results, similar to `auto`. + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // The example from `auto` can be rewritten as follows: + * async.autoInject({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: function(get_data, make_folder, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }, + * email_link: function(write_file, callback) { + * // once the file is written let's email a link to it... + * // write_file contains the filename returned by write_file. + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * } + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + * + * // If you are using a JS minifier that mangles parameter names, `autoInject` + * // will not work with plain functions, since the parameter names will be + * // collapsed to a single letter identifier. To work around this, you can + * // explicitly specify the names of the parameters your task function needs + * // in an array, similar to Angular.js dependency injection. + * + * // This still has an advantage over plain `auto`, since the results a task + * // depends on are still spread into arguments. + * async.autoInject({ + * //... + * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) { + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(write_file, callback) { + * callback(null, {'file':write_file, 'email':'user@example.com'}); + * }] + * //... + * }, function(err, results) { + * console.log('err = ', err); + * console.log('email_link = ', results.email_link); + * }); + */ + function autoInject(tasks, callback) { + var newTasks = {}; + + Object.keys(tasks).forEach(key => { + var taskFn = tasks[key]; + var params; + var fnIsAsync = isAsync(taskFn); + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); + + if (Array.isArray(taskFn)) { + params = [...taskFn]; + taskFn = params.pop(); + + newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); + } else if (hasNoDeps) { + // no dependencies, use the function as-is + newTasks[key] = taskFn; + } else { + params = parseParams(taskFn); + if ((taskFn.length === 0 && !fnIsAsync) && params.length === 0) { + throw new Error("autoInject task functions require explicit parameters."); + } + + // remove callback param + if (!fnIsAsync) params.pop(); + + newTasks[key] = params.concat(newTask); + } + + function newTask(results, taskCb) { + var newArgs = params.map(name => results[name]); + newArgs.push(taskCb); + wrapAsync(taskFn)(...newArgs); + } + }); + + return auto(newTasks, callback); + } + + // Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation + // used for queues. This implementation assumes that the node provided by the user can be modified + // to adjust the next and last properties. We implement only the minimal functionality + // for queue support. + class DLL { + constructor() { + this.head = this.tail = null; + this.length = 0; + } + + removeLink(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next; + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; + + node.prev = node.next = null; + this.length -= 1; + return node; + } + + empty () { + while(this.head) this.shift(); + return this; + } + + insertAfter(node, newNode) { + newNode.prev = node; + newNode.next = node.next; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; + node.next = newNode; + this.length += 1; + } + + insertBefore(node, newNode) { + newNode.prev = node.prev; + newNode.next = node; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; + node.prev = newNode; + this.length += 1; + } + + unshift(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); + } + + push(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); + } + + shift() { + return this.head && this.removeLink(this.head); + } + + pop() { + return this.tail && this.removeLink(this.tail); + } + + toArray() { + return [...this] + } + + *[Symbol.iterator] () { + var cur = this.head; + while (cur) { + yield cur.data; + cur = cur.next; + } + } + + remove (testFn) { + var curr = this.head; + while(curr) { + var {next} = curr; + if (testFn(curr)) { + this.removeLink(curr); + } + curr = next; + } + return this; + } + } + + function setInitial(dll, node) { + dll.length = 1; + dll.head = dll.tail = node; + } + + function queue$1(worker, concurrency, payload) { + if (concurrency == null) { + concurrency = 1; + } + else if(concurrency === 0) { + throw new RangeError('Concurrency must not be zero'); + } + + var _worker = wrapAsync(worker); + var numRunning = 0; + var workersList = []; + const events = { + error: [], + drain: [], + saturated: [], + unsaturated: [], + empty: [] + }; + + function on (event, handler) { + events[event].push(handler); + } + + function once (event, handler) { + const handleAndRemove = (...args) => { + off(event, handleAndRemove); + handler(...args); + }; + events[event].push(handleAndRemove); + } + + function off (event, handler) { + if (!event) return Object.keys(events).forEach(ev => events[ev] = []) + if (!handler) return events[event] = [] + events[event] = events[event].filter(ev => ev !== handler); + } + + function trigger (event, ...args) { + events[event].forEach(handler => handler(...args)); + } + + var processingScheduled = false; + function _insert(data, insertAtFront, rejectOnError, callback) { + if (callback != null && typeof callback !== 'function') { + throw new Error('task callback must be a function'); + } + q.started = true; + + var res, rej; + function promiseCallback (err, ...args) { + // we don't care about the error, let the global error handler + // deal with it + if (err) return rejectOnError ? rej(err) : res() + if (args.length <= 1) return res(args[0]) + res(args); + } + + var item = q._createTaskItem( + data, + rejectOnError ? promiseCallback : + (callback || promiseCallback) + ); + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); + } + + if (!processingScheduled) { + processingScheduled = true; + setImmediate$1(() => { + processingScheduled = false; + q.process(); + }); + } + + if (rejectOnError || !callback) { + return new Promise((resolve, reject) => { + res = resolve; + rej = reject; + }) + } + } + + function _createCB(tasks) { + return function (err, ...args) { + numRunning -= 1; + + for (var i = 0, l = tasks.length; i < l; i++) { + var task = tasks[i]; + + var index = workersList.indexOf(task); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); + } + + task.callback(err, ...args); + + if (err != null) { + trigger('error', err, task.data); + } + } + + if (numRunning <= (q.concurrency - q.buffer) ) { + trigger('unsaturated'); + } + + if (q.idle()) { + trigger('drain'); + } + q.process(); + }; + } + + function _maybeDrain(data) { + if (data.length === 0 && q.idle()) { + // call drain immediately if there are no tasks + setImmediate$1(() => trigger('drain')); + return true + } + return false + } + + const eventMethod = (name) => (handler) => { + if (!handler) { + return new Promise((resolve, reject) => { + once(name, (err, data) => { + if (err) return reject(err) + resolve(data); + }); + }) + } + off(name); + on(name, handler); + + }; + + var isProcessing = false; + var q = { + _tasks: new DLL(), + _createTaskItem (data, callback) { + return { + data, + callback + }; + }, + *[Symbol.iterator] () { + yield* q._tasks[Symbol.iterator](); + }, + concurrency, + payload, + buffer: concurrency / 4, + started: false, + paused: false, + push (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, false, callback)) + } + return _insert(data, false, false, callback); + }, + pushAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, true, callback)) + } + return _insert(data, false, true, callback); + }, + kill () { + off(); + q._tasks.empty(); + }, + unshift (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, false, callback)) + } + return _insert(data, true, false, callback); + }, + unshiftAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, true, callback)) + } + return _insert(data, true, true, callback); + }, + remove (testFn) { + q._tasks.remove(testFn); + }, + process () { + // Avoid trying to start too many processing operations. This can occur + // when callbacks resolve synchronously (#1267). + if (isProcessing) { + return; + } + isProcessing = true; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ + var tasks = [], data = []; + var l = q._tasks.length; + if (q.payload) l = Math.min(l, q.payload); + for (var i = 0; i < l; i++) { + var node = q._tasks.shift(); + tasks.push(node); + workersList.push(node); + data.push(node.data); + } + + numRunning += 1; + + if (q._tasks.length === 0) { + trigger('empty'); + } + + if (numRunning === q.concurrency) { + trigger('saturated'); + } + + var cb = onlyOnce(_createCB(tasks)); + _worker(data, cb); + } + isProcessing = false; + }, + length () { + return q._tasks.length; + }, + running () { + return numRunning; + }, + workersList () { + return workersList; + }, + idle() { + return q._tasks.length + numRunning === 0; + }, + pause () { + q.paused = true; + }, + resume () { + if (q.paused === false) { return; } + q.paused = false; + setImmediate$1(q.process); + } + }; + // define these as fixed properties, so people get useful errors when updating + Object.defineProperties(q, { + saturated: { + writable: false, + value: eventMethod('saturated') + }, + unsaturated: { + writable: false, + value: eventMethod('unsaturated') + }, + empty: { + writable: false, + value: eventMethod('empty') + }, + drain: { + writable: false, + value: eventMethod('drain') + }, + error: { + writable: false, + value: eventMethod('error') + }, + }); + return q; + } + + /** + * Creates a `cargo` object with the specified payload. Tasks added to the + * cargo will be processed altogether (up to the `payload` limit). If the + * `worker` is in progress, the task is queued until it becomes available. Once + * the `worker` has completed some tasks, each callback of those tasks is + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) + * for how `cargo` and `queue` work. + * + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers + * at a time, cargo passes an array of tasks to a single worker, repeating + * when the worker is finished. + * + * @name cargo + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. + * @param {number} [payload=Infinity] - An optional `integer` for determining + * how many tasks should be processed per round; if omitted, the default is + * unlimited. + * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the cargo and inner queue. + * @example + * + * // create a cargo object with payload 2 + * var cargo = async.cargo(function(tasks, callback) { + * for (var i=0; i { + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.reduce(withMissingFileList, 0, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.reduce(fileList, 0, getFileSizeInBytes); + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function reduce(coll, memo, iteratee, callback) { + callback = once(callback); + var _iteratee = wrapAsync(iteratee); + return eachOfSeries$1(coll, (x, i, iterCb) => { + _iteratee(memo, x, (err, v) => { + memo = v; + iterCb(err); + }); + }, err => callback(err, memo)); + } + var reduce$1 = awaitify(reduce, 4); + + /** + * Version of the compose function that is more natural to read. Each function + * consumes the return value of the previous function. It is the equivalent of + * [compose]{@link module:ControlFlow.compose} with the arguments reversed. + * + * Each function is executed with the `this` binding of the composed function. + * + * @name seq + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.compose]{@link module:ControlFlow.compose} + * @category Control Flow + * @param {...AsyncFunction} functions - the asynchronous functions to compose + * @returns {Function} a function that composes the `functions` in order + * @example + * + * // Requires lodash (or underscore), express3 and dresende's orm2. + * // Part of an app, that fetches cats of the logged user. + * // This example uses `seq` function to avoid overnesting and error + * // handling clutter. + * app.get('/cats', function(request, response) { + * var User = request.models.User; + * async.seq( + * User.get.bind(User), // 'User.get' has signature (id, callback(err, data)) + * function(user, fn) { + * user.getCats(fn); // 'getCats' has signature (callback(err, data)) + * } + * )(req.session.user_id, function (err, cats) { + * if (err) { + * console.error(err); + * response.json({ status: 'error', message: err.message }); + * } else { + * response.json({ status: 'ok', message: 'Cats found', data: cats }); + * } + * }); + * }); + */ + function seq(...functions) { + var _functions = functions.map(wrapAsync); + return function (...args) { + var that = this; + + var cb = args[args.length - 1]; + if (typeof cb == 'function') { + args.pop(); + } else { + cb = promiseCallback(); + } + + reduce$1(_functions, args, (newargs, fn, iterCb) => { + fn.apply(that, newargs.concat((err, ...nextargs) => { + iterCb(err, nextargs); + })); + }, + (err, results) => cb(err, ...results)); + + return cb[PROMISE_SYMBOL] + }; + } + + /** + * Creates a function which is a composition of the passed asynchronous + * functions. Each function consumes the return value of the function that + * follows. Composing functions `f()`, `g()`, and `h()` would produce the result + * of `f(g(h()))`, only this version uses callbacks to obtain the return values. + * + * If the last argument to the composed function is not a function, a promise + * is returned when you call it. + * + * Each function is executed with the `this` binding of the composed function. + * + * @name compose + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {...AsyncFunction} functions - the asynchronous functions to compose + * @returns {Function} an asynchronous function that is the composed + * asynchronous `functions` + * @example + * + * function add1(n, callback) { + * setTimeout(function () { + * callback(null, n + 1); + * }, 10); + * } + * + * function mul3(n, callback) { + * setTimeout(function () { + * callback(null, n * 3); + * }, 10); + * } + * + * var add1mul3 = async.compose(mul3, add1); + * add1mul3(4, function (err, result) { + * // result now equals 15 + * }); + */ + function compose(...args) { + return seq(...args.reverse()); + } + + /** + * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. + * + * @name mapLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.map]{@link module:Collections.map} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Results is an array of the + * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function mapLimit (coll, limit, iteratee, callback) { + return _asyncMap(eachOfLimit$2(limit), coll, iteratee, callback) + } + var mapLimit$1 = awaitify(mapLimit, 4); + + /** + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time. + * + * @name concatLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.concat]{@link module:Collections.concat} + * @category Collection + * @alias flatMapLimit + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`, + * which should use an array as its result. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + */ + function concatLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(coll, limit, (val, iterCb) => { + _iteratee(val, (err, ...args) => { + if (err) return iterCb(err); + return iterCb(err, args); + }); + }, (err, mapResults) => { + var result = []; + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + result = result.concat(...mapResults[i]); + } + } + + return callback(err, result); + }); + } + var concatLimit$1 = awaitify(concatLimit, 4); + + /** + * Applies `iteratee` to each item in `coll`, concatenating the results. Returns + * the concatenated list. The `iteratee`s are called in parallel, and the + * results are concatenated as they return. The results array will be returned in + * the original order of `coll` passed to the `iteratee` function. + * + * @name concat + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @alias flatMap + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`, + * which should use an array as its result. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * let directoryList = ['dir1','dir2','dir3']; + * let withMissingDirectoryList = ['dir1','dir2','dir3', 'dir4']; + * + * // Using callbacks + * async.concat(directoryList, fs.readdir, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * } + * }); + * + * // Error Handling + * async.concat(withMissingDirectoryList, fs.readdir, function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * } else { + * console.log(results); + * } + * }); + * + * // Using Promises + * async.concat(directoryList, fs.readdir) + * .then(results => { + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * }).catch(err => { + * console.log(err); + * }); + * + * // Error Handling + * async.concat(withMissingDirectoryList, fs.readdir) + * .then(results => { + * console.log(results); + * }).catch(err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.concat(directoryList, fs.readdir); + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * } catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.concat(withMissingDirectoryList, fs.readdir); + * console.log(results); + * } catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * } + * } + * + */ + function concat(coll, iteratee, callback) { + return concatLimit$1(coll, Infinity, iteratee, callback) + } + var concat$1 = awaitify(concat, 3); + + /** + * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time. + * + * @name concatSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.concat]{@link module:Collections.concat} + * @category Collection + * @alias flatMapSeries + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`. + * The iteratee should complete with an array an array of results. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + */ + function concatSeries(coll, iteratee, callback) { + return concatLimit$1(coll, 1, iteratee, callback) + } + var concatSeries$1 = awaitify(concatSeries, 3); + + /** + * Returns a function that when called, calls-back with the values provided. + * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to + * [`auto`]{@link module:ControlFlow.auto}. + * + * @name constant + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {...*} arguments... - Any number of arguments to automatically invoke + * callback with. + * @returns {AsyncFunction} Returns a function that when invoked, automatically + * invokes the callback with the previous given arguments. + * @example + * + * async.waterfall([ + * async.constant(42), + * function (value, next) { + * // value === 42 + * }, + * //... + * ], callback); + * + * async.waterfall([ + * async.constant(filename, "utf8"), + * fs.readFile, + * function (fileData, next) { + * //... + * } + * //... + * ], callback); + * + * async.auto({ + * hostname: async.constant("https://server.net/"), + * port: findFreePort, + * launchServer: ["hostname", "port", function (options, cb) { + * startServer(options, cb); + * }], + * //... + * }, callback); + */ + function constant$1(...args) { + return function (...ignoredArgs/*, callback*/) { + var callback = ignoredArgs.pop(); + return callback(null, ...args); + }; + } + + function _createTester(check, getResult) { + return (eachfn, arr, _iteratee, cb) => { + var testPassed = false; + var testResult; + const iteratee = wrapAsync(_iteratee); + eachfn(arr, (value, _, callback) => { + iteratee(value, (err, result) => { + if (err || err === false) return callback(err); + + if (check(result) && !testResult) { + testPassed = true; + testResult = getResult(true, value); + return callback(null, breakLoop); + } + callback(); + }); + }, err => { + if (err) return cb(err); + cb(null, testPassed ? testResult : getResult(false)); + }); + }; + } + + /** + * Returns the first value in `coll` that passes an async truth test. The + * `iteratee` is applied in parallel, meaning the first iteratee to return + * `true` will fire the detect `callback` with that result. That means the + * result might not be the first item in the original `coll` (in terms of order) + * that passes the test. + + * If order within the original `coll` is important, then look at + * [`detectSeries`]{@link module:Collections.detectSeries}. + * + * @name detect + * @static + * @memberOf module:Collections + * @method + * @alias find + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // dir1/file1.txt + * // result now equals the first file in the list that exists + * } + *); + * + * // Using Promises + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists) + * .then(result => { + * console.log(result); + * // dir1/file1.txt + * // result now equals the first file in the list that exists + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists); + * console.log(result); + * // dir1/file1.txt + * // result now equals the file in the list that exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function detect(coll, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOf$1, coll, iteratee, callback) + } + var detect$1 = awaitify(detect, 3); + + /** + * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a + * time. + * + * @name detectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findLimit + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + */ + function detectLimit(coll, limit, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var detectLimit$1 = awaitify(detectLimit, 4); + + /** + * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. + * + * @name detectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.detect]{@link module:Collections.detect} + * @alias findSeries + * @category Collections + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the `iteratee` functions have finished. + * Result will be the first item in the array that passes the truth test + * (iteratee) or the value `undefined` if none passed. Invoked with + * (err, result). + * @returns {Promise} a promise, if a callback is omitted + */ + function detectSeries(coll, iteratee, callback) { + return _createTester(bool => bool, (res, item) => item)(eachOfLimit$2(1), coll, iteratee, callback) + } + + var detectSeries$1 = awaitify(detectSeries, 3); + + function consoleFunc(name) { + return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => { + /* istanbul ignore else */ + if (typeof console === 'object') { + /* istanbul ignore else */ + if (err) { + /* istanbul ignore else */ + if (console.error) { + console.error(err); + } + } else if (console[name]) { /* istanbul ignore else */ + resultArgs.forEach(x => console[name](x)); + } + } + }) + } + + /** + * Logs the result of an [`async` function]{@link AsyncFunction} to the + * `console` using `console.dir` to display the properties of the resulting object. + * Only works in Node.js or in browsers that support `console.dir` and + * `console.error` (such as FF and Chrome). + * If multiple arguments are returned from the async function, + * `console.dir` is called on each argument in order. + * + * @name dir + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, {hello: name}); + * }, 1000); + * }; + * + * // in the node repl + * node> async.dir(hello, 'world'); + * {hello: 'world'} + */ + var dir = consoleFunc('dir'); + + /** + * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in + * the order of operations, the arguments `test` and `iteratee` are switched. + * + * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript. + * + * @name doWhilst + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - A function which is called each time `test` + * passes. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee`. + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. + * `callback` will be passed an error and any arguments passed to the final + * `iteratee`'s callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + */ + function doWhilst(iteratee, test, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results; + + function next(err, ...args) { + if (err) return callback(err); + if (err === false) return; + results = args; + _test(...args, check); + } + + function check(err, truth) { + if (err) return callback(err); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return check(null, true); + } + + var doWhilst$1 = awaitify(doWhilst, 3); + + /** + * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the + * argument ordering differs from `until`. + * + * @name doUntil + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} + * @category Control Flow + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee` + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + */ + function doUntil(iteratee, test, callback) { + const _test = wrapAsync(test); + return doWhilst$1(iteratee, (...args) => { + const cb = args.pop(); + _test(...args, (err, truth) => cb (err, !truth)); + }, callback); + } + + function _withoutIndex(iteratee) { + return (value, index, callback) => iteratee(value, callback); + } + + /** + * Applies the function `iteratee` to each item in `coll`, in parallel. + * The `iteratee` is called with an item from the list, and a callback for when + * it has finished. If the `iteratee` passes an error to its `callback`, the + * main `callback` (for the `each` function) is immediately called with the + * error. + * + * Note, that since this function applies `iteratee` to each item in parallel, + * there is no guarantee that the iteratee functions will complete in order. + * + * @name each + * @static + * @memberOf module:Collections + * @method + * @alias forEach + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to + * each item in `coll`. Invoked with (item, callback). + * The array index is not passed to the iteratee. + * If you need the index, use `eachOf`. + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt']; + * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt']; + * + * // asynchronous function that deletes a file + * const deleteFile = function(file, callback) { + * fs.unlink(file, callback); + * }; + * + * // Using callbacks + * async.each(fileList, deleteFile, function(err) { + * if( err ) { + * console.log(err); + * } else { + * console.log('All files have been deleted successfully'); + * } + * }); + * + * // Error Handling + * async.each(withMissingFileList, deleteFile, function(err){ + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using Promises + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using async/await + * async () => { + * try { + * await async.each(files, deleteFile); + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * await async.each(withMissingFileList, deleteFile); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * } + * } + * + */ + function eachLimit$2(coll, iteratee, callback) { + return eachOf$1(coll, _withoutIndex(wrapAsync(iteratee)), callback); + } + + var each = awaitify(eachLimit$2, 3); + + /** + * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. + * + * @name eachLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfLimit`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachLimit(coll, limit, iteratee, callback) { + return eachOfLimit$2(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback); + } + var eachLimit$1 = awaitify(eachLimit, 4); + + /** + * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. + * + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item + * in series and therefore the iteratee functions will complete in order. + + * @name eachSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.each]{@link module:Collections.each} + * @alias forEachSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfSeries`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called when all + * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted + */ + function eachSeries(coll, iteratee, callback) { + return eachLimit$1(coll, 1, iteratee, callback) + } + var eachSeries$1 = awaitify(eachSeries, 3); + + /** + * Wrap an async function and ensure it calls its callback on a later tick of + * the event loop. If the function already calls its callback on a next tick, + * no extra deferral is added. This is useful for preventing stack overflows + * (`RangeError: Maximum call stack size exceeded`) and generally keeping + * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) + * contained. ES2017 `async` functions are returned as-is -- they are immune + * to Zalgo's corrupting influences, as they always resolve on a later tick. + * + * @name ensureAsync + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - an async function, one that expects a node-style + * callback as its last argument. + * @returns {AsyncFunction} Returns a wrapped function with the exact same call + * signature as the function passed in. + * @example + * + * function sometimesAsync(arg, callback) { + * if (cache[arg]) { + * return callback(null, cache[arg]); // this would be synchronous!! + * } else { + * doSomeIO(arg, callback); // this IO would be asynchronous + * } + * } + * + * // this has a risk of stack overflows if many results are cached in a row + * async.mapSeries(args, sometimesAsync, done); + * + * // this will defer sometimesAsync's callback if necessary, + * // preventing stack overflows + * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); + */ + function ensureAsync(fn) { + if (isAsync(fn)) return fn; + return function (...args/*, callback*/) { + var callback = args.pop(); + var sync = true; + args.push((...innerArgs) => { + if (sync) { + setImmediate$1(() => callback(...innerArgs)); + } else { + callback(...innerArgs); + } + }); + fn.apply(this, args); + sync = false; + }; + } + + /** + * Returns `true` if every element in `coll` satisfies an async test. If any + * iteratee call returns `false`, the main `callback` is immediately called. + * + * @name every + * @static + * @memberOf module:Collections + * @method + * @alias all + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.every(fileList, fileExists, function(err, result) { + * console.log(result); + * // true + * // result is true since every file exists + * }); + * + * async.every(withMissingFileList, fileExists, function(err, result) { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }); + * + * // Using Promises + * async.every(fileList, fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since every file exists + * }).catch( err => { + * console.log(err); + * }); + * + * async.every(withMissingFileList, fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.every(fileList, fileExists); + * console.log(result); + * // true + * // result is true since every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.every(withMissingFileList, fileExists); + * console.log(result); + * // false + * // result is false since NOT every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function every(coll, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOf$1, coll, iteratee, callback) + } + var every$1 = awaitify(every, 3); + + /** + * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. + * + * @name everyLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function everyLimit(coll, limit, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var everyLimit$1 = awaitify(everyLimit, 4); + + /** + * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. + * + * @name everySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.every]{@link module:Collections.every} + * @alias allSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in series. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result will be either `true` or `false` + * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function everySeries(coll, iteratee, callback) { + return _createTester(bool => !bool, res => !res)(eachOfSeries$1, coll, iteratee, callback) + } + var everySeries$1 = awaitify(everySeries, 3); + + function filterArray(eachfn, arr, iteratee, callback) { + var truthValues = new Array(arr.length); + eachfn(arr, (x, index, iterCb) => { + iteratee(x, (err, v) => { + truthValues[index] = !!v; + iterCb(err); + }); + }, err => { + if (err) return callback(err); + var results = []; + for (var i = 0; i < arr.length; i++) { + if (truthValues[i]) results.push(arr[i]); + } + callback(null, results); + }); + } + + function filterGeneric(eachfn, coll, iteratee, callback) { + var results = []; + eachfn(coll, (x, index, iterCb) => { + iteratee(x, (err, v) => { + if (err) return iterCb(err); + if (v) { + results.push({index, value: x}); + } + iterCb(err); + }); + }, err => { + if (err) return callback(err); + callback(null, results + .sort((a, b) => a.index - b.index) + .map(v => v.value)); + }); + } + + function _filter(eachfn, coll, iteratee, callback) { + var filter = isArrayLike(coll) ? filterArray : filterGeneric; + return filter(eachfn, coll, wrapAsync(iteratee), callback); + } + + /** + * Returns a new array of all the values in `coll` which pass an async truth + * test. This operation is performed in parallel, but the results array will be + * in the same order as the original. + * + * @name filter + * @static + * @memberOf module:Collections + * @method + * @alias select + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.filter(files, fileExists, function(err, results) { + * if(err) { + * console.log(err); + * } else { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } + * }); + * + * // Using Promises + * async.filter(files, fileExists) + * .then(results => { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.filter(files, fileExists); + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function filter (coll, iteratee, callback) { + return _filter(eachOf$1, coll, iteratee, callback) + } + var filter$1 = awaitify(filter, 3); + + /** + * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a + * time. + * + * @name filterLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided + */ + function filterLimit (coll, limit, iteratee, callback) { + return _filter(eachOfLimit$2(limit), coll, iteratee, callback) + } + var filterLimit$1 = awaitify(filterLimit, 4); + + /** + * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. + * + * @name filterSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @alias selectSeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - A truth test to apply to each item in `coll`. + * The `iteratee` is passed a `callback(err, truthValue)`, which must be called + * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results) + * @returns {Promise} a promise, if no callback provided + */ + function filterSeries (coll, iteratee, callback) { + return _filter(eachOfSeries$1, coll, iteratee, callback) + } + var filterSeries$1 = awaitify(filterSeries, 3); + + /** + * Calls the asynchronous function `fn` with a callback parameter that allows it + * to call itself again, in series, indefinitely. + + * If an error is passed to the callback then `errback` is called with the + * error, and execution stops, otherwise it will never be called. + * + * @name forever + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} fn - an async function to call repeatedly. + * Invoked with (next). + * @param {Function} [errback] - when `fn` passes an error to it's callback, + * this function will be called, and execution stops. Invoked with (err). + * @returns {Promise} a promise that rejects if an error occurs and an errback + * is not passed + * @example + * + * async.forever( + * function(next) { + * // next is suitable for passing to things that need a callback(err [, whatever]); + * // it will result in this function being called again. + * }, + * function(err) { + * // if next is called with a value in its first parameter, it will appear + * // in here as 'err', and execution will stop. + * } + * ); + */ + function forever(fn, errback) { + var done = onlyOnce(errback); + var task = wrapAsync(ensureAsync(fn)); + + function next(err) { + if (err) return done(err); + if (err === false) return; + task(next); + } + return next(); + } + var forever$1 = awaitify(forever, 2); + + /** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. + * + * @name groupByLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ + function groupByLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(coll, limit, (val, iterCb) => { + _iteratee(val, (err, key) => { + if (err) return iterCb(err); + return iterCb(err, {key, val}); + }); + }, (err, mapResults) => { + var result = {}; + // from MDN, handle object having an `hasOwnProperty` prop + var {hasOwnProperty} = Object.prototype; + + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + var {key} = mapResults[i]; + var {val} = mapResults[i]; + + if (hasOwnProperty.call(result, key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } + } + + return callback(err, result); + }); + } + + var groupByLimit$1 = awaitify(groupByLimit, 4); + + /** + * Returns a new object, where each value corresponds to an array of items, from + * `coll`, that returned the corresponding key. That is, the keys of the object + * correspond to the values passed to the `iteratee` callback. + * + * Note: Since this function applies the `iteratee` to each item in parallel, + * there is no guarantee that the `iteratee` functions will complete in order. + * However, the values for each key in the `result` will be in the same order as + * the original `coll`. For Objects, the values will roughly be in the order of + * the original Objects' keys (but this can vary across JavaScript engines). + * + * @name groupBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const files = ['dir1/file1.txt','dir2','dir4'] + * + * // asynchronous function that detects file type as none, file, or directory + * function detectFile(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(null, 'none'); + * } + * callback(null, stat.isDirectory() ? 'directory' : 'file'); + * }); + * } + * + * //Using callbacks + * async.groupBy(files, detectFile, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * }); + * + * // Using Promises + * async.groupBy(files, detectFile) + * .then( result => { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.groupBy(files, detectFile); + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function groupBy (coll, iteratee, callback) { + return groupByLimit$1(coll, Infinity, iteratee, callback) + } + + /** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. + * + * @name groupBySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ + function groupBySeries (coll, iteratee, callback) { + return groupByLimit$1(coll, 1, iteratee, callback) + } + + /** + * Logs the result of an `async` function to the `console`. Only works in + * Node.js or in browsers that support `console.log` and `console.error` (such + * as FF and Chrome). If multiple arguments are returned from the async + * function, `console.log` is called on each argument in order. + * + * @name log + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. + * @param {...*} arguments... - Any number of arguments to apply to the function. + * @example + * + * // in a module + * var hello = function(name, callback) { + * setTimeout(function() { + * callback(null, 'hello ' + name); + * }, 1000); + * }; + * + * // in the node repl + * node> async.log(hello, 'world'); + * 'hello world' + */ + var log = consoleFunc('log'); + + /** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a + * time. + * + * @name mapValuesLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function mapValuesLimit(obj, limit, iteratee, callback) { + callback = once(callback); + var newObj = {}; + var _iteratee = wrapAsync(iteratee); + return eachOfLimit$2(limit)(obj, (val, key, next) => { + _iteratee(val, key, (err, result) => { + if (err) return next(err); + newObj[key] = result; + next(err); + }); + }, err => callback(err, newObj)); + } + + var mapValuesLimit$1 = awaitify(mapValuesLimit, 4); + + /** + * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. + * + * Produces a new Object by mapping each value of `obj` through the `iteratee` + * function. The `iteratee` is called each `value` and `key` from `obj` and a + * callback for when it has finished processing. Each of these callbacks takes + * two arguments: an `error`, and the transformed item from `obj`. If `iteratee` + * passes an error to its callback, the main `callback` (for the `mapValues` + * function) is immediately called with the error. + * + * Note, the order of the keys in the result is not guaranteed. The keys will + * be roughly in the order they complete, (but this is very engine-specific) + * + * @name mapValues + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file3.txt' + * }; + * + * const withMissingFileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file4.txt' + * }; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, key, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * } else { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * }); + * + * // Error handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(result); + * } + * }); + * + * // Using Promises + * async.mapValues(fileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * }).catch (err => { + * console.log(err); + * }); + * + * // Error Handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch (err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.mapValues(fileMap, getFileSizeInBytes); + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function mapValues(obj, iteratee, callback) { + return mapValuesLimit$1(obj, Infinity, iteratee, callback) + } + + /** + * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. + * + * @name mapValuesSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.mapValues]{@link module:Collections.mapValues} + * @category Collection + * @param {Object} obj - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function mapValuesSeries(obj, iteratee, callback) { + return mapValuesLimit$1(obj, 1, iteratee, callback) + } + + /** + * Caches the results of an async function. When creating a hash to store + * function results against, the callback is omitted from the hash and an + * optional hash function can be used. + * + * **Note: if the async function errs, the result will not be cached and + * subsequent calls will call the wrapped function.** + * + * If no hash function is specified, the first argument is used as a hash key, + * which may work reasonably if it is a string or a data type that converts to a + * distinct string. Note that objects and arrays will not behave reasonably. + * Neither will cases where the other arguments are significant. In such cases, + * specify your own hash function. + * + * The cache of results is exposed as the `memo` property of the function + * returned by `memoize`. + * + * @name memoize + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function to proxy and cache results from. + * @param {Function} hasher - An optional function for generating a custom hash + * for storing results. It has all the arguments applied to it apart from the + * callback, and must be synchronous. + * @returns {AsyncFunction} a memoized version of `fn` + * @example + * + * var slow_fn = function(name, callback) { + * // do something + * callback(null, result); + * }; + * var fn = async.memoize(slow_fn); + * + * // fn can now be used as if it were slow_fn + * fn('some name', function() { + * // callback + * }); + */ + function memoize(fn, hasher = v => v) { + var memo = Object.create(null); + var queues = Object.create(null); + var _fn = wrapAsync(fn); + var memoized = initialParams((args, callback) => { + var key = hasher(...args); + if (key in memo) { + setImmediate$1(() => callback(null, ...memo[key])); + } else if (key in queues) { + queues[key].push(callback); + } else { + queues[key] = [callback]; + _fn(...args, (err, ...resultArgs) => { + // #1465 don't memoize if an error occurred + if (!err) { + memo[key] = resultArgs; + } + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i](err, ...resultArgs); + } + }); + } + }); + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + } + + /* istanbul ignore file */ + + /** + * Calls `callback` on a later loop around the event loop. In Node.js this just + * calls `process.nextTick`. In the browser it will use `setImmediate` if + * available, otherwise `setTimeout(callback, 0)`, which means other higher + * priority events may precede the execution of `callback`. + * + * This is used internally for browser-compatibility purposes. + * + * @name nextTick + * @static + * @memberOf module:Utils + * @method + * @see [async.setImmediate]{@link module:Utils.setImmediate} + * @category Util + * @param {Function} callback - The function to call on a later loop around + * the event loop. Invoked with (args...). + * @param {...*} args... - any number of additional arguments to pass to the + * callback on the next tick. + * @example + * + * var call_order = []; + * async.nextTick(function() { + * call_order.push('two'); + * // call_order now equals ['one','two'] + * }); + * call_order.push('one'); + * + * async.setImmediate(function (a, b, c) { + * // a, b, and c equal 1, 2, and 3 + * }, 1, 2, 3); + */ + var _defer; + + if (hasNextTick) { + _defer = process.nextTick; + } else if (hasSetImmediate) { + _defer = setImmediate; + } else { + _defer = fallback; + } + + var nextTick = wrap(_defer); + + var _parallel = awaitify((eachfn, tasks, callback) => { + var results = isArrayLike(tasks) ? [] : {}; + + eachfn(tasks, (task, key, taskCb) => { + wrapAsync(task)((err, ...result) => { + if (result.length < 2) { + [result] = result; + } + results[key] = result; + taskCb(err); + }); + }, err => callback(err, results)); + }, 3); + + /** + * Run the `tasks` collection of functions in parallel, without waiting until + * the previous function has completed. If any of the functions pass an error to + * its callback, the main `callback` is immediately called with the value of the + * error. Once the `tasks` have completed, the results are passed to the final + * `callback` as an array. + * + * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about + * parallel execution of code. If your tasks do not use any timers or perform + * any I/O, they will actually be executed in series. Any synchronous setup + * sections for each task will happen one after the other. JavaScript remains + * single-threaded. + * + * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the + * execution of other tasks when a task fails. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.parallel}. + * + * @name parallel + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + * + * @example + * + * //Using Callbacks + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * }).catch(err => { + * console.log(err); + * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function parallel(tasks, callback) { + return _parallel(eachOf$1, tasks, callback); + } + + /** + * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a + * time. + * + * @name parallelLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.parallel]{@link module:ControlFlow.parallel} + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed successfully. This function gets a results array + * (or object) containing all the result arguments passed to the task callbacks. + * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + */ + function parallelLimit(tasks, limit, callback) { + return _parallel(eachOfLimit$2(limit), tasks, callback); + } + + /** + * A queue of tasks for the worker function to complete. + * @typedef {Iterable} QueueObject + * @memberOf module:ControlFlow + * @property {Function} length - a function returning the number of items + * waiting to be processed. Invoke with `queue.length()`. + * @property {boolean} started - a boolean indicating whether or not any + * items have been pushed and processed by the queue. + * @property {Function} running - a function returning the number of items + * currently being processed. Invoke with `queue.running()`. + * @property {Function} workersList - a function returning the array of items + * currently being processed. Invoke with `queue.workersList()`. + * @property {Function} idle - a function returning false if there are items + * waiting or being processed, or true if not. Invoke with `queue.idle()`. + * @property {number} concurrency - an integer for determining how many `worker` + * functions should be run in parallel. This property can be changed after a + * `queue` is created to alter the concurrency on-the-fly. + * @property {number} payload - an integer that specifies how many items are + * passed to the worker function at a time. only applies if this is a + * [cargo]{@link module:ControlFlow.cargo} object + * @property {AsyncFunction} push - add a new task to the `queue`. Calls `callback` + * once the `worker` has finished processing the task. Instead of a single task, + * a `tasks` array can be submitted. The respective callback is used for every + * task in the list. Invoke with `queue.push(task, [callback])`, + * @property {AsyncFunction} unshift - add a new task to the front of the `queue`. + * Invoke with `queue.unshift(task, [callback])`. + * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns + * a promise that rejects if an error occurs. + * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns + * a promise that rejects if an error occurs. + * @property {Function} remove - remove items from the queue that match a test + * function. The test function will be passed an object with a `data` property, + * and a `priority` property, if this is a + * [priorityQueue]{@link module:ControlFlow.priorityQueue} object. + * Invoked with `queue.remove(testFn)`, where `testFn` is of the form + * `function ({data, priority}) {}` and returns a Boolean. + * @property {Function} saturated - a function that sets a callback that is + * called when the number of running workers hits the `concurrency` limit, and + * further tasks will be queued. If the callback is omitted, `q.saturated()` + * returns a promise for the next occurrence. + * @property {Function} unsaturated - a function that sets a callback that is + * called when the number of running workers is less than the `concurrency` & + * `buffer` limits, and further tasks will not be queued. If the callback is + * omitted, `q.unsaturated()` returns a promise for the next occurrence. + * @property {number} buffer - A minimum threshold buffer in order to say that + * the `queue` is `unsaturated`. + * @property {Function} empty - a function that sets a callback that is called + * when the last item from the `queue` is given to a `worker`. If the callback + * is omitted, `q.empty()` returns a promise for the next occurrence. + * @property {Function} drain - a function that sets a callback that is called + * when the last item from the `queue` has returned from the `worker`. If the + * callback is omitted, `q.drain()` returns a promise for the next occurrence. + * @property {Function} error - a function that sets a callback that is called + * when a task errors. Has the signature `function(error, task)`. If the + * callback is omitted, `error()` returns a promise that rejects on the next + * error. + * @property {boolean} paused - a boolean for determining whether the queue is + * in a paused state. + * @property {Function} pause - a function that pauses the processing of tasks + * until `resume()` is called. Invoke with `queue.pause()`. + * @property {Function} resume - a function that resumes the processing of + * queued tasks when the queue is paused. Invoke with `queue.resume()`. + * @property {Function} kill - a function that removes the `drain` callback and + * empties remaining tasks from the queue forcing it to go idle. No more tasks + * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. + * + * @example + * const q = async.queue(worker, 2) + * q.push(item1) + * q.push(item2) + * q.push(item3) + * // queues are iterable, spread into an array to inspect + * const items = [...q] // [item1, item2, item3] + * // or use for of + * for (let item of q) { + * console.log(item) + * } + * + * q.drain(() => { + * console.log('all done') + * }) + * // or + * await q.drain() + */ + + /** + * Creates a `queue` object with the specified `concurrency`. Tasks added to the + * `queue` are processed in parallel (up to the `concurrency` limit). If all + * `worker`s are in progress, the task is queued until one becomes available. + * Once a `worker` completes a `task`, that `task`'s callback is called. + * + * @name queue + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. Invoked with (task, callback). + * @param {number} [concurrency=1] - An `integer` for determining how many + * `worker` functions should be run in parallel. If omitted, the concurrency + * defaults to `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can be + * attached as certain properties to listen for specific events during the + * lifecycle of the queue. + * @example + * + * // create a queue object with concurrency 2 + * var q = async.queue(function(task, callback) { + * console.log('hello ' + task.name); + * callback(); + * }, 2); + * + * // assign a callback + * q.drain(function() { + * console.log('all items have been processed'); + * }); + * // or await the end + * await q.drain() + * + * // assign an error callback + * q.error(function(err, task) { + * console.error('task experienced an error'); + * }); + * + * // add some items to the queue + * q.push({name: 'foo'}, function(err) { + * console.log('finished processing foo'); + * }); + * // callback is optional + * q.push({name: 'bar'}); + * + * // add some items to the queue (batch-wise) + * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { + * console.log('finished processing item'); + * }); + * + * // add some items to the front of the queue + * q.unshift({name: 'bar'}, function (err) { + * console.log('finished processing bar'); + * }); + */ + function queue (worker, concurrency) { + var _worker = wrapAsync(worker); + return queue$1((items, cb) => { + _worker(items[0], cb); + }, concurrency, 1); + } + + // Binary min-heap implementation used for priority queue. + // Implementation is stable, i.e. push time is considered for equal priorities + class Heap { + constructor() { + this.heap = []; + this.pushCount = Number.MIN_SAFE_INTEGER; + } + + get length() { + return this.heap.length; + } + + empty () { + this.heap = []; + return this; + } + + percUp(index) { + let p; + + while (index > 0 && smaller(this.heap[index], this.heap[p=parent(index)])) { + let t = this.heap[index]; + this.heap[index] = this.heap[p]; + this.heap[p] = t; + + index = p; + } + } + + percDown(index) { + let l; + + while ((l=leftChi(index)) < this.heap.length) { + if (l+1 < this.heap.length && smaller(this.heap[l+1], this.heap[l])) { + l = l+1; + } + + if (smaller(this.heap[index], this.heap[l])) { + break; + } + + let t = this.heap[index]; + this.heap[index] = this.heap[l]; + this.heap[l] = t; + + index = l; + } + } + + push(node) { + node.pushCount = ++this.pushCount; + this.heap.push(node); + this.percUp(this.heap.length-1); + } + + unshift(node) { + return this.heap.push(node); + } + + shift() { + let [top] = this.heap; + + this.heap[0] = this.heap[this.heap.length-1]; + this.heap.pop(); + this.percDown(0); + + return top; + } + + toArray() { + return [...this]; + } + + *[Symbol.iterator] () { + for (let i = 0; i < this.heap.length; i++) { + yield this.heap[i].data; + } + } + + remove (testFn) { + let j = 0; + for (let i = 0; i < this.heap.length; i++) { + if (!testFn(this.heap[i])) { + this.heap[j] = this.heap[i]; + j++; + } + } + + this.heap.splice(j); + + for (let i = parent(this.heap.length-1); i >= 0; i--) { + this.percDown(i); + } + + return this; + } + } + + function leftChi(i) { + return (i<<1)+1; + } + + function parent(i) { + return ((i+1)>>1)-1; + } + + function smaller(x, y) { + if (x.priority !== y.priority) { + return x.priority < y.priority; + } + else { + return x.pushCount < y.pushCount; + } + } + + /** + * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and + * completed in ascending priority order. + * + * @name priorityQueue + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @category Control Flow + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. + * Invoked with (task, callback). + * @param {number} concurrency - An `integer` for determining how many `worker` + * functions should be run in parallel. If omitted, the concurrency defaults to + * `1`. If the concurrency is `0`, an error is thrown. + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are three + * differences between `queue` and `priorityQueue` objects: + * * `push(task, priority, [callback])` - `priority` should be a number. If an + * array of `tasks` is given, all tasks will be assigned the same priority. + * * `pushAsync(task, priority, [callback])` - the same as `priorityQueue.push`, + * except this returns a promise that rejects if an error occurs. + * * The `unshift` and `unshiftAsync` methods were removed. + */ + function priorityQueue(worker, concurrency) { + // Start with a normal queue + var q = queue(worker, concurrency); + + var { + push, + pushAsync + } = q; + + q._tasks = new Heap(); + q._createTaskItem = ({data, priority}, callback) => { + return { + data, + priority, + callback + }; + }; + + function createDataItems(tasks, priority) { + if (!Array.isArray(tasks)) { + return {data: tasks, priority}; + } + return tasks.map(data => { return {data, priority}; }); + } + + // Override push to accept second parameter representing priority + q.push = function(data, priority = 0, callback) { + return push(createDataItems(data, priority), callback); + }; + + q.pushAsync = function(data, priority = 0, callback) { + return pushAsync(createDataItems(data, priority), callback); + }; + + // Remove unshift functions + delete q.unshift; + delete q.unshiftAsync; + + return q; + } + + /** + * Runs the `tasks` array of functions in parallel, without waiting until the + * previous function has completed. Once any of the `tasks` complete or pass an + * error to its callback, the main `callback` is immediately called. It's + * equivalent to `Promise.race()`. + * + * @name race + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction} + * to run. Each function can complete with an optional `result` value. + * @param {Function} callback - A callback to run once any of the functions have + * completed. This function gets an error or result from the first function that + * completed. Invoked with (err, result). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * async.race([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ], + * // main callback + * function(err, result) { + * // the result will be equal to 'two' as it finishes earlier + * }); + */ + function race(tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); + if (!tasks.length) return callback(); + for (var i = 0, l = tasks.length; i < l; i++) { + wrapAsync(tasks[i])(callback); + } + } + + var race$1 = awaitify(race, 2); + + /** + * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. + * + * @name reduceRight + * @static + * @memberOf module:Collections + * @method + * @see [async.reduce]{@link module:Collections.reduce} + * @alias foldr + * @category Collection + * @param {Array} array - A collection to iterate over. + * @param {*} memo - The initial state of the reduction. + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee completes with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the reduced value. Invoked with + * (err, result). + * @returns {Promise} a promise, if no callback is passed + */ + function reduceRight (array, memo, iteratee, callback) { + var reversed = [...array].reverse(); + return reduce$1(reversed, memo, iteratee, callback); + } + + /** + * Wraps the async function in another function that always completes with a + * result object, even when it errors. + * + * The result object has either the property `error` or `value`. + * + * @name reflect + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} fn - The async function you want to wrap + * @returns {Function} - A function that always passes null to it's callback as + * the error. The second argument to the callback will be an `object` with + * either an `error` or a `value` property. + * @example + * + * async.parallel([ + * async.reflect(function(callback) { + * // do some stuff ... + * callback(null, 'one'); + * }), + * async.reflect(function(callback) { + * // do some more stuff but error ... + * callback('bad stuff happened'); + * }), + * async.reflect(function(callback) { + * // do some more stuff ... + * callback(null, 'two'); + * }) + * ], + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = 'bad stuff happened' + * // results[2].value = 'two' + * }); + */ + function reflect(fn) { + var _fn = wrapAsync(fn); + return initialParams(function reflectOn(args, reflectCallback) { + args.push((error, ...cbArgs) => { + let retVal = {}; + if (error) { + retVal.error = error; + } + if (cbArgs.length > 0){ + var value = cbArgs; + if (cbArgs.length <= 1) { + [value] = cbArgs; + } + retVal.value = value; + } + reflectCallback(null, retVal); + }); + + return _fn.apply(this, args); + }); + } + + /** + * A helper function that wraps an array or an object of functions with `reflect`. + * + * @name reflectAll + * @static + * @memberOf module:Utils + * @method + * @see [async.reflect]{@link module:Utils.reflect} + * @category Util + * @param {Array|Object|Iterable} tasks - The collection of + * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. + * @returns {Array} Returns an array of async functions, each wrapped in + * `async.reflect` + * @example + * + * let tasks = [ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * // do some more stuff but error ... + * callback(new Error('bad stuff happened')); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results[0].value = 'one' + * // results[1].error = Error('bad stuff happened') + * // results[2].value = 'two' + * }); + * + * // an example using an object instead of an array + * let tasks = { + * one: function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * two: function(callback) { + * callback('two'); + * }, + * three: function(callback) { + * setTimeout(function() { + * callback(null, 'three'); + * }, 100); + * } + * }; + * + * async.parallel(async.reflectAll(tasks), + * // optional callback + * function(err, results) { + * // values + * // results.one.value = 'one' + * // results.two.error = 'two' + * // results.three.value = 'three' + * }); + */ + function reflectAll(tasks) { + var results; + if (Array.isArray(tasks)) { + results = tasks.map(reflect); + } else { + results = {}; + Object.keys(tasks).forEach(key => { + results[key] = reflect.call(this, tasks[key]); + }); + } + return results; + } + + function reject$2(eachfn, arr, _iteratee, callback) { + const iteratee = wrapAsync(_iteratee); + return _filter(eachfn, arr, (value, cb) => { + iteratee(value, (err, v) => { + cb(err, !v); + }); + }, callback); + } + + /** + * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. + * + * @name reject + * @static + * @memberOf module:Collections + * @method + * @see [async.filter]{@link module:Collections.filter} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.reject(fileList, fileExists, function(err, results) { + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * }); + * + * // Using Promises + * async.reject(fileList, fileExists) + * .then( results => { + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.reject(fileList, fileExists); + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function reject (coll, iteratee, callback) { + return reject$2(eachOf$1, coll, iteratee, callback) + } + var reject$1 = awaitify(reject, 3); + + /** + * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a + * time. + * + * @name rejectLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function rejectLimit (coll, limit, iteratee, callback) { + return reject$2(eachOfLimit$2(limit), coll, iteratee, callback) + } + var rejectLimit$1 = awaitify(rejectLimit, 4); + + /** + * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. + * + * @name rejectSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.reject]{@link module:Collections.reject} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed + */ + function rejectSeries (coll, iteratee, callback) { + return reject$2(eachOfSeries$1, coll, iteratee, callback) + } + var rejectSeries$1 = awaitify(rejectSeries, 3); + + function constant(value) { + return function () { + return value; + } + } + + /** + * Attempts to get a successful response from `task` no more than `times` times + * before returning an error. If the task is successful, the `callback` will be + * passed the result of the successful task. If all attempts fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name retry + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @see [async.retryable]{@link module:ControlFlow.retryable} + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an + * object with `times` and `interval` or a number. + * * `times` - The number of attempts to make before giving up. The default + * is `5`. + * * `interval` - The time to wait between retries, in milliseconds. The + * default is `0`. The interval may also be specified as a function of the + * retry count (see example). + * * `errorFilter` - An optional synchronous function that is invoked on + * erroneous result. If it returns `true` the retry attempts will continue; + * if the function returns `false` the retry flow is aborted with the current + * attempt's error and result being returned to the final callback. + * Invoked with (err). + * * If `opts` is a number, the number specifies the number of times to retry, + * with the default interval of `0`. + * @param {AsyncFunction} task - An async function to retry. + * Invoked with (callback). + * @param {Function} [callback] - An optional callback which is called when the + * task has succeeded, or after the final failed attempt. It receives the `err` + * and `result` arguments of the last attempt at completing the `task`. Invoked + * with (err, results). + * @returns {Promise} a promise if no callback provided + * + * @example + * + * // The `retry` function can be used as a stand-alone control flow by passing + * // a callback, as shown below: + * + * // try calling apiMethod 3 times + * async.retry(3, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 3 times, waiting 200 ms between each retry + * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod 10 times with exponential backoff + * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds) + * async.retry({ + * times: 10, + * interval: function(retryCount) { + * return 50 * Math.pow(2, retryCount); + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod the default 5 times no delay between each retry + * async.retry(apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // try calling apiMethod only when error condition satisfies, all other + * // errors will abort the retry control flow and return to final callback + * async.retry({ + * errorFilter: function(err) { + * return err.message === 'Temporary error'; // only retry on a specific error + * } + * }, apiMethod, function(err, result) { + * // do something with the result + * }); + * + * // to retry individual methods that are not as reliable within other + * // control flow functions, use the `retryable` wrapper: + * async.auto({ + * users: api.getUsers.bind(api), + * payments: async.retryable(3, api.getPayments.bind(api)) + * }, function(err, results) { + * // do something with the results + * }); + * + */ + const DEFAULT_TIMES = 5; + const DEFAULT_INTERVAL = 0; + + function retry(opts, task, callback) { + var options = { + times: DEFAULT_TIMES, + intervalFunc: constant(DEFAULT_INTERVAL) + }; + + if (arguments.length < 3 && typeof opts === 'function') { + callback = task || promiseCallback(); + task = opts; + } else { + parseTimes(options, opts); + callback = callback || promiseCallback(); + } + + if (typeof task !== 'function') { + throw new Error("Invalid arguments for async.retry"); + } + + var _task = wrapAsync(task); + + var attempt = 1; + function retryAttempt() { + _task((err, ...args) => { + if (err === false) return + if (err && attempt++ < options.times && + (typeof options.errorFilter != 'function' || + options.errorFilter(err))) { + setTimeout(retryAttempt, options.intervalFunc(attempt - 1)); + } else { + callback(err, ...args); + } + }); + } + + retryAttempt(); + return callback[PROMISE_SYMBOL] + } + + function parseTimes(acc, t) { + if (typeof t === 'object') { + acc.times = +t.times || DEFAULT_TIMES; + + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant(+t.interval || DEFAULT_INTERVAL); + + acc.errorFilter = t.errorFilter; + } else if (typeof t === 'number' || typeof t === 'string') { + acc.times = +t || DEFAULT_TIMES; + } else { + throw new Error("Invalid arguments for async.retry"); + } + } + + /** + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method + * wraps a task and makes it retryable, rather than immediately calling it + * with retries. + * + * @name retryable + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.retry]{@link module:ControlFlow.retry} + * @category Control Flow + * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional + * options, exactly the same as from `retry`, except for a `opts.arity` that + * is the arity of the `task` function, defaulting to `task.length` + * @param {AsyncFunction} task - the asynchronous function to wrap. + * This function will be passed any arguments passed to the returned wrapper. + * Invoked with (...args, callback). + * @returns {AsyncFunction} The wrapped function, which when invoked, will + * retry on an error, based on the parameters specified in `opts`. + * This function will accept the same parameters as `task`. + * @example + * + * async.auto({ + * dep1: async.retryable(3, getFromFlakyService), + * process: ["dep1", async.retryable(3, function (results, cb) { + * maybeProcessData(results.dep1, cb); + * })] + * }, callback); + */ + function retryable (opts, task) { + if (!task) { + task = opts; + opts = null; + } + let arity = (opts && opts.arity) || task.length; + if (isAsync(task)) { + arity += 1; + } + var _task = wrapAsync(task); + return initialParams((args, callback) => { + if (args.length < arity - 1 || callback == null) { + args.push(callback); + callback = promiseCallback(); + } + function taskFn(cb) { + _task(...args, cb); + } + + if (opts) retry(opts, taskFn, callback); + else retry(taskFn, callback); + + return callback[PROMISE_SYMBOL] + }); + } + + /** + * Run the functions in the `tasks` collection in series, each one running once + * the previous function has completed. If any functions in the series pass an + * error to its callback, no more functions are run, and `callback` is + * immediately called with the value of the error. Otherwise, `callback` + * receives an array of results when `tasks` have completed. + * + * It is also possible to use an object instead of an array. Each property will + * be run as a function, and the results will be passed to the final `callback` + * as an object instead of an array. This can be a more readable way of handling + * results from {@link async.series}. + * + * **Note** that while many implementations preserve the order of object + * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6) + * explicitly states that + * + * > The mechanics and order of enumerating the properties is not specified. + * + * So if you rely on the order in which your series of functions are executed, + * and want this to work on all platforms, consider using an array. + * + * @name series + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing + * [async functions]{@link AsyncFunction} to run in series. + * Each function can complete with any number of optional `result` values. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This function gets a results array (or object) + * containing all the result arguments passed to the `task` callbacks. Invoked + * with (err, result). + * @return {Promise} a promise, if no callback is passed + * @example + * + * //Using Callbacks + * async.series([ + * function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); + * } + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] + * }); + * + * // an example using objects instead of arrays + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }, function(err, results) { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.series([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] + * }).catch(err => { + * console.log(err); + * }); + * + * // an example using an object instead of an array + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.series([ + * function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function series(tasks, callback) { + return _parallel(eachOfSeries$1, tasks, callback); + } + + /** + * Returns `true` if at least one element in the `coll` satisfies an async test. + * If any iteratee call returns `true`, the main `callback` is immediately + * called. + * + * @name some + * @static + * @memberOf module:Collections + * @method + * @alias any + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + *); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // false + * // result is false since none of the files exists + * } + *); + * + * // Using Promises + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since some file in the list exists + * }).catch( err => { + * console.log(err); + * }); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since none of the files exists + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists); + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists); + * console.log(result); + * // false + * // result is false since none of the files exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function some(coll, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOf$1, coll, iteratee, callback) + } + var some$1 = awaitify(some, 3); + + /** + * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. + * + * @name someLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anyLimit + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function someLimit(coll, limit, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOfLimit$2(limit), coll, iteratee, callback) + } + var someLimit$1 = awaitify(someLimit, 4); + + /** + * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. + * + * @name someSeries + * @static + * @memberOf module:Collections + * @method + * @see [async.some]{@link module:Collections.some} + * @alias anySeries + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in series. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called as soon as any + * iteratee returns `true`, or after all the iteratee functions have finished. + * Result will be either `true` or `false` depending on the values of the async + * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + */ + function someSeries(coll, iteratee, callback) { + return _createTester(Boolean, res => res)(eachOfSeries$1, coll, iteratee, callback) + } + var someSeries$1 = awaitify(someSeries, 3); + + /** + * Sorts a list by the results of running each `coll` value through an async + * `iteratee`. + * + * @name sortBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a value to use as the sort criteria as + * its `result`. + * Invoked with (item, callback). + * @param {Function} callback - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is the items + * from the original `coll` sorted by the values returned by the `iteratee` + * calls. Invoked with (err, results). + * @returns {Promise} a promise, if no callback passed + * @example + * + * // bigfile.txt is a file that is 251100 bytes in size + * // mediumfile.txt is a file that is 11000 bytes in size + * // smallfile.txt is a file that is 121 bytes in size + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); + * + * // By modifying the callback parameter the + * // sorting order can be influenced: + * + * // ascending order + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) return callback(getFileSizeErr); + * callback(null, fileSize); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); + * + * // descending order + * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) { + * return callback(getFileSizeErr); + * } + * callback(null, fileSize * -1); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt'] + * } + * } + * ); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * } + * ); + * + * // Using Promises + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * }).catch( err => { + * console.log(err); + * }); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * (async () => { + * try { + * let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * + * // Error handling + * async () => { + * try { + * let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * + */ + function sortBy (coll, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return map$1(coll, (x, iterCb) => { + _iteratee(x, (err, criteria) => { + if (err) return iterCb(err); + iterCb(err, {value: x, criteria}); + }); + }, (err, results) => { + if (err) return callback(err); + callback(null, results.sort(comparator).map(v => v.value)); + }); + + function comparator(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + } + } + var sortBy$1 = awaitify(sortBy, 3); + + /** + * Sets a time limit on an asynchronous function. If the function does not call + * its callback within the specified milliseconds, it will be called with a + * timeout error. The code property for the error object will be `'ETIMEDOUT'`. + * + * @name timeout + * @static + * @memberOf module:Utils + * @method + * @category Util + * @param {AsyncFunction} asyncFn - The async function to limit in time. + * @param {number} milliseconds - The specified time limit. + * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) + * to timeout Error for more information.. + * @returns {AsyncFunction} Returns a wrapped function that can be used with any + * of the control flow functions. + * Invoke this function with the same parameters as you would `asyncFunc`. + * @example + * + * function myFunction(foo, callback) { + * doAsyncTask(foo, function(err, data) { + * // handle errors + * if (err) return callback(err); + * + * // do some stuff ... + * + * // return processed data + * return callback(null, data); + * }); + * } + * + * var wrapped = async.timeout(myFunction, 1000); + * + * // call `wrapped` as you would `myFunction` + * wrapped({ bar: 'bar' }, function(err, data) { + * // if `myFunction` takes < 1000 ms to execute, `err` + * // and `data` will have their expected values + * + * // else `err` will be an Error with the code 'ETIMEDOUT' + * }); + */ + function timeout(asyncFn, milliseconds, info) { + var fn = wrapAsync(asyncFn); + + return initialParams((args, callback) => { + var timedOut = false; + var timer; + + function timeoutCallback() { + var name = asyncFn.name || 'anonymous'; + var error = new Error('Callback function "' + name + '" timed out.'); + error.code = 'ETIMEDOUT'; + if (info) { + error.info = info; + } + timedOut = true; + callback(error); + } + + args.push((...cbArgs) => { + if (!timedOut) { + callback(...cbArgs); + clearTimeout(timer); + } + }); + + // setup timer and call original function + timer = setTimeout(timeoutCallback, milliseconds); + fn(...args); + }); + } + + function range(size) { + var result = Array(size); + while (size--) { + result[size] = size; + } + return result; + } + + /** + * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a + * time. + * + * @name timesLimit + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} count - The number of times to run the function. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see [async.map]{@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + */ + function timesLimit(count, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit$1(range(count), limit, _iteratee, callback); + } + + /** + * Calls the `iteratee` function `n` times, and accumulates results in the same + * manner you would use with [map]{@link module:Collections.map}. + * + * @name times + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.map]{@link module:Collections.map} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + * @example + * + * // Pretend this is some complicated async factory + * var createUser = function(id, callback) { + * callback(null, { + * id: 'user' + id + * }); + * }; + * + * // generate 5 users + * async.times(5, function(n, next) { + * createUser(n, function(err, user) { + * next(err, user); + * }); + * }, function(err, users) { + * // we should now have 5 users + * }); + */ + function times (n, iteratee, callback) { + return timesLimit(n, Infinity, iteratee, callback) + } + + /** + * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. + * + * @name timesSeries + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.times]{@link module:ControlFlow.times} + * @category Control Flow + * @param {number} n - The number of times to run the function. + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). + * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided + */ + function timesSeries (n, iteratee, callback) { + return timesLimit(n, 1, iteratee, callback) + } + + /** + * A relative of `reduce`. Takes an Object or Array, and iterates over each + * element in parallel, each step potentially mutating an `accumulator` value. + * The type of the accumulator defaults to the type of collection passed in. + * + * @name transform + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {*} [accumulator] - The initial state of the transform. If omitted, + * it will default to an empty Object or Array, depending on the type of `coll` + * @param {AsyncFunction} iteratee - A function applied to each item in the + * collection that potentially modifies the accumulator. + * Invoked with (accumulator, item, key, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished. Result is the transformed accumulator. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); + * }); + * } + * + * // Using callbacks + * async.transform(fileList, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } + * }); + * + * // Using Promises + * async.transform(fileList, transformFileSize) + * .then(result => { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * (async () => { + * try { + * let result = await async.transform(fileList, transformFileSize); + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * + * @example + * + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' }; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); + * }); + * } + * + * // Using callbacks + * async.transform(fileMap, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * }); + * + * // Using Promises + * async.transform(fileMap, transformFileSize) + * .then(result => { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.transform(fileMap, transformFileSize); + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ + function transform (coll, accumulator, iteratee, callback) { + if (arguments.length <= 3 && typeof accumulator === 'function') { + callback = iteratee; + iteratee = accumulator; + accumulator = Array.isArray(coll) ? [] : {}; + } + callback = once(callback || promiseCallback()); + var _iteratee = wrapAsync(iteratee); + + eachOf$1(coll, (v, k, cb) => { + _iteratee(accumulator, v, k, cb); + }, err => callback(err, accumulator)); + return callback[PROMISE_SYMBOL] + } + + /** + * It runs each task in series but stops whenever any of the functions were + * successful. If one of the tasks were successful, the `callback` will be + * passed the result of the successful task. If all tasks fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name tryEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing functions to + * run, each function is passed a `callback(err, result)` it must call on + * completion with an error `err` (which can be `null`) and an optional `result` + * value. + * @param {Function} [callback] - An optional callback which is called when one + * of the tasks has succeeded, or all have failed. It receives the `err` and + * `result` arguments of the last attempt at completing the `task`. Invoked with + * (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * async.tryEach([ + * function getDataFromFirstWebsite(callback) { + * // Try getting the data from the first website + * callback(err, data); + * }, + * function getDataFromSecondWebsite(callback) { + * // First website failed, + * // Try getting the data from the backup website + * callback(err, data); + * } + * ], + * // optional callback + * function(err, results) { + * Now do something with the data. + * }); + * + */ + function tryEach(tasks, callback) { + var error = null; + var result; + return eachSeries$1(tasks, (task, taskCb) => { + wrapAsync(task)((err, ...args) => { + if (err === false) return taskCb(err); + + if (args.length < 2) { + [result] = args; + } else { + result = args; + } + error = err; + taskCb(err ? null : {}); + }); + }, () => callback(error, result)); + } + + var tryEach$1 = awaitify(tryEach); + + /** + * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original, + * unmemoized form. Handy for testing. + * + * @name unmemoize + * @static + * @memberOf module:Utils + * @method + * @see [async.memoize]{@link module:Utils.memoize} + * @category Util + * @param {AsyncFunction} fn - the memoized function + * @returns {AsyncFunction} a function that calls the original unmemoized function + */ + function unmemoize(fn) { + return (...args) => { + return (fn.unmemoized || fn)(...args); + }; + } + + /** + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. + * + * @name whilst + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` passes. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has failed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed + * @example + * + * var count = 0; + * async.whilst( + * function test(cb) { cb(null, count < 5); }, + * function iter(callback) { + * count++; + * setTimeout(function() { + * callback(null, count); + * }, 1000); + * }, + * function (err, n) { + * // 5 seconds have passed, n = 5 + * } + * ); + */ + function whilst(test, iteratee, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results = []; + + function next(err, ...rest) { + if (err) return callback(err); + results = rest; + if (err === false) return; + _test(check); + } + + function check(err, truth) { + if (err) return callback(err); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return _test(check); + } + var whilst$1 = awaitify(whilst, 3); + + /** + * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when + * stopped, or an error occurs. `callback` will be passed an error and any + * arguments passed to the final `iteratee`'s callback. + * + * The inverse of [whilst]{@link module:ControlFlow.whilst}. + * + * @name until + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.whilst]{@link module:ControlFlow.whilst} + * @category Control Flow + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {Function} [callback] - A callback which is called after the test + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s + * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if a callback is not passed + * + * @example + * const results = [] + * let finished = false + * async.until(function test(cb) { + * cb(null, finished) + * }, function iter(next) { + * fetchPage(url, (err, body) => { + * if (err) return next(err) + * results = results.concat(body.objects) + * finished = !!body.next + * next(err) + * }) + * }, function done (err) { + * // all pages have been fetched + * }) + */ + function until(test, iteratee, callback) { + const _test = wrapAsync(test); + return whilst$1((cb) => _test((err, truth) => cb (err, !truth)), iteratee, callback); + } + + /** + * Runs the `tasks` array of functions in series, each passing their results to + * the next in the array. However, if any of the `tasks` pass an error to their + * own callback, the next function is not executed, and the main `callback` is + * immediately called with the error. + * + * @name waterfall + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} + * to run. + * Each function should complete with any number of `result` values. + * The `result` values will be passed as arguments, in order, to the next task. + * @param {Function} [callback] - An optional callback to run once all the + * functions have completed. This will be passed the results of the last task's + * callback. Invoked with (err, [results]). + * @returns {Promise} a promise, if a callback is omitted + * @example + * + * async.waterfall([ + * function(callback) { + * callback(null, 'one', 'two'); + * }, + * function(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * }, + * function(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + * ], function (err, result) { + * // result now equals 'done' + * }); + * + * // Or, with named functions: + * async.waterfall([ + * myFirstFunction, + * mySecondFunction, + * myLastFunction, + * ], function (err, result) { + * // result now equals 'done' + * }); + * function myFirstFunction(callback) { + * callback(null, 'one', 'two'); + * } + * function mySecondFunction(arg1, arg2, callback) { + * // arg1 now equals 'one' and arg2 now equals 'two' + * callback(null, 'three'); + * } + * function myLastFunction(arg1, callback) { + * // arg1 now equals 'three' + * callback(null, 'done'); + * } + */ + function waterfall (tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); + if (!tasks.length) return callback(); + var taskIndex = 0; + + function nextTask(args) { + var task = wrapAsync(tasks[taskIndex++]); + task(...args, onlyOnce(next)); + } + + function next(err, ...args) { + if (err === false) return + if (err || taskIndex === tasks.length) { + return callback(err, ...args); + } + nextTask(args); + } + + nextTask([]); + } + + var waterfall$1 = awaitify(waterfall); + + /** + * 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 + */ + + + var index = { + apply, + applyEach, + applyEachSeries, + asyncify, + auto, + autoInject, + cargo: cargo$1, + cargoQueue: cargo, + compose, + concat: concat$1, + concatLimit: concatLimit$1, + concatSeries: concatSeries$1, + constant: constant$1, + detect: detect$1, + detectLimit: detectLimit$1, + detectSeries: detectSeries$1, + dir, + doUntil, + doWhilst: doWhilst$1, + each, + eachLimit: eachLimit$1, + eachOf: eachOf$1, + eachOfLimit: eachOfLimit$1, + eachOfSeries: eachOfSeries$1, + eachSeries: eachSeries$1, + ensureAsync, + every: every$1, + everyLimit: everyLimit$1, + everySeries: everySeries$1, + filter: filter$1, + filterLimit: filterLimit$1, + filterSeries: filterSeries$1, + forever: forever$1, + groupBy, + groupByLimit: groupByLimit$1, + groupBySeries, + log, + map: map$1, + mapLimit: mapLimit$1, + mapSeries: mapSeries$1, + mapValues, + mapValuesLimit: mapValuesLimit$1, + mapValuesSeries, + memoize, + nextTick, + parallel, + parallelLimit, + priorityQueue, + queue, + race: race$1, + reduce: reduce$1, + reduceRight, + reflect, + reflectAll, + reject: reject$1, + rejectLimit: rejectLimit$1, + rejectSeries: rejectSeries$1, + retry, + retryable, + seq, + series, + setImmediate: setImmediate$1, + some: some$1, + someLimit: someLimit$1, + someSeries: someSeries$1, + sortBy: sortBy$1, + timeout, + times, + timesLimit, + timesSeries, + transform, + tryEach: tryEach$1, + unmemoize, + until, + waterfall: waterfall$1, + whilst: whilst$1, + + // aliases + all: every$1, + allLimit: everyLimit$1, + allSeries: everySeries$1, + any: some$1, + anyLimit: someLimit$1, + anySeries: someSeries$1, + find: detect$1, + findLimit: detectLimit$1, + findSeries: detectSeries$1, + flatMap: concat$1, + flatMapLimit: concatLimit$1, + flatMapSeries: concatSeries$1, + forEach: each, + forEachSeries: eachSeries$1, + forEachLimit: eachLimit$1, + forEachOf: eachOf$1, + forEachOfSeries: eachOfSeries$1, + forEachOfLimit: eachOfLimit$1, + inject: reduce$1, + foldl: reduce$1, + foldr: reduceRight, + select: filter$1, + selectLimit: filterLimit$1, + selectSeries: filterSeries$1, + wrapSync: asyncify, + during: whilst$1, + doDuring: doWhilst$1 + }; + + exports.all = every$1; + exports.allLimit = everyLimit$1; + exports.allSeries = everySeries$1; + exports.any = some$1; + exports.anyLimit = someLimit$1; + exports.anySeries = someSeries$1; + exports.apply = apply; + exports.applyEach = applyEach; + exports.applyEachSeries = applyEachSeries; + exports.asyncify = asyncify; + exports.auto = auto; + exports.autoInject = autoInject; + exports.cargo = cargo$1; + exports.cargoQueue = cargo; + exports.compose = compose; + exports.concat = concat$1; + exports.concatLimit = concatLimit$1; + exports.concatSeries = concatSeries$1; + exports.constant = constant$1; + exports.default = index; + exports.detect = detect$1; + exports.detectLimit = detectLimit$1; + exports.detectSeries = detectSeries$1; + exports.dir = dir; + exports.doDuring = doWhilst$1; + exports.doUntil = doUntil; + exports.doWhilst = doWhilst$1; + exports.during = whilst$1; + exports.each = each; + exports.eachLimit = eachLimit$1; + exports.eachOf = eachOf$1; + exports.eachOfLimit = eachOfLimit$1; + exports.eachOfSeries = eachOfSeries$1; + exports.eachSeries = eachSeries$1; + exports.ensureAsync = ensureAsync; + exports.every = every$1; + exports.everyLimit = everyLimit$1; + exports.everySeries = everySeries$1; + exports.filter = filter$1; + exports.filterLimit = filterLimit$1; + exports.filterSeries = filterSeries$1; + exports.find = detect$1; + exports.findLimit = detectLimit$1; + exports.findSeries = detectSeries$1; + exports.flatMap = concat$1; + exports.flatMapLimit = concatLimit$1; + exports.flatMapSeries = concatSeries$1; + exports.foldl = reduce$1; + exports.foldr = reduceRight; + exports.forEach = each; + exports.forEachLimit = eachLimit$1; + exports.forEachOf = eachOf$1; + exports.forEachOfLimit = eachOfLimit$1; + exports.forEachOfSeries = eachOfSeries$1; + exports.forEachSeries = eachSeries$1; + exports.forever = forever$1; + exports.groupBy = groupBy; + exports.groupByLimit = groupByLimit$1; + exports.groupBySeries = groupBySeries; + exports.inject = reduce$1; + exports.log = log; + exports.map = map$1; + exports.mapLimit = mapLimit$1; + exports.mapSeries = mapSeries$1; + exports.mapValues = mapValues; + exports.mapValuesLimit = mapValuesLimit$1; + exports.mapValuesSeries = mapValuesSeries; + exports.memoize = memoize; + exports.nextTick = nextTick; + exports.parallel = parallel; + exports.parallelLimit = parallelLimit; + exports.priorityQueue = priorityQueue; + exports.queue = queue; + exports.race = race$1; + exports.reduce = reduce$1; + exports.reduceRight = reduceRight; + exports.reflect = reflect; + exports.reflectAll = reflectAll; + exports.reject = reject$1; + exports.rejectLimit = rejectLimit$1; + exports.rejectSeries = rejectSeries$1; + exports.retry = retry; + exports.retryable = retryable; + exports.select = filter$1; + exports.selectLimit = filterLimit$1; + exports.selectSeries = filterSeries$1; + exports.seq = seq; + exports.series = series; + exports.setImmediate = setImmediate$1; + exports.some = some$1; + exports.someLimit = someLimit$1; + exports.someSeries = someSeries$1; + exports.sortBy = sortBy$1; + exports.timeout = timeout; + exports.times = times; + exports.timesLimit = timesLimit; + exports.timesSeries = timesSeries; + exports.transform = transform; + exports.tryEach = tryEach$1; + exports.unmemoize = unmemoize; + exports.until = until; + exports.waterfall = waterfall$1; + exports.whilst = whilst$1; + exports.wrapSync = asyncify; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/docs/v3/scripts/jsdoc-custom.js b/docs/v3/scripts/jsdoc-custom.js new file mode 100644 index 000000000..0d233e6a4 --- /dev/null +++ b/docs/v3/scripts/jsdoc-custom.js @@ -0,0 +1,129 @@ +/* eslint no-undef: "off" */ +if (typeof setImmediate !== 'function' && typeof async === 'object') { + window.setImmediate = async.setImmediate; +} + +$(() => { + function matchSubstrs(methodName) { + var tokens = []; + var len = methodName.length; + for (var size = 1; size <= len; size++){ + for (var i = 0; i+size<= len; i++){ + tokens.push(methodName.substr(i, size)); + } + } + return tokens; + } + + var methodNames = new Bloodhound({ + datumTokenizer: matchSubstrs, + queryTokenizer: Bloodhound.tokenizers.whitespace, + prefetch: { + url: './data/methodNames.json', + cache: false + } + }); + + var sourceFiles = new Bloodhound({ + datumTokenizer: matchSubstrs, + queryTokenizer: Bloodhound.tokenizers.whitespace, + prefetch: { + url: './data/sourceFiles.json', + cache: false + } + }); + + var githubIssues = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.whitespace, + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: { + url: 'https://api.github.com/search/issues?q=%QUERY+repo:caolan/async', + cache: true, + wildcard: '%QUERY', + transform(response) { + return $.map(response.items, (issue) => { + // if (issue.state !== 'open') { + // return null; + // } + return { + url: issue.html_url, + name: issue.number + ': ' + issue.title, + number: issue.number + }; + }).sort((a, b) => { + return b.number - a.number; + }); + } + } + }); + + $('.typeahead').typeahead({ + hint: true, + highlight: true, + minLength: 1 + }, { + name: 'Methods', + source: methodNames, + templates: { + header: '

Methods

' + } + }, { + name: 'Files', + source: sourceFiles, + templates: { + header: '

Source Files

' + } + }, { + name: 'Issues', + source: githubIssues, + display: 'name', + templates: { + header: '

Issues

' + } + }).on('typeahead:select', (ev, suggestion) => { + var host; + if (location.origin != "null") { + host = location.origin; + } else { + host = location.protocol + '//' + location.host; + } + + var _path = location.pathname.split("/"); + var currentPage = _path[_path.length - 1]; + host += "/" + _path.slice(1, -1).join("/") + "/"; + + // handle issues + if (typeof suggestion !== 'string') { + location.href = suggestion.url; + // handle source files + } else if (suggestion.indexOf('.html') !== -1) { + location.href = host + suggestion; + } else { + var parenIndex = suggestion.indexOf('('); + if (parenIndex !== -1) { + suggestion = suggestion.substring(0, parenIndex-1); + } + + // handle searching from one of the source files or the home page + if (currentPage !== 'docs.html') { + location.href = host + 'docs.html#' + suggestion; + } else { + var $el = document.getElementById(suggestion); + $('#main-container').animate({ scrollTop: $el.offsetTop - 60 }, 500); + location.hash = '#'+suggestion; + } + } + }).focus(); + + function fixOldHash() { + var {hash} = window.location; + if (hash) { + var hashMatches = hash.match(/^#\.(\w+)$/); + if (hashMatches) { + window.location.hash = '#'+hashMatches[1]; + } + } + } + + fixOldHash(); +}); diff --git a/docs/v3/scripts/linenumber.js b/docs/v3/scripts/linenumber.js new file mode 100644 index 000000000..8d52f7eaf --- /dev/null +++ b/docs/v3/scripts/linenumber.js @@ -0,0 +1,25 @@ +/*global document */ +(function() { + var source = document.getElementsByClassName('prettyprint source linenums'); + var i = 0; + var lineNumber = 0; + var lineId; + var lines; + var totalLines; + var anchorHash; + + if (source && source[0]) { + anchorHash = document.location.hash.substring(1); + lines = source[0].getElementsByTagName('li'); + totalLines = lines.length; + + for (; i < totalLines; i++) { + lineNumber++; + lineId = 'line' + lineNumber; + lines[i].id = lineId; + if (lineId === anchorHash) { + lines[i].className += ' selected'; + } + } + } +})(); diff --git a/docs/v3/scripts/prettify/Apache-License-2.0.txt b/docs/v3/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/docs/v3/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/v3/scripts/prettify/lang-css.js b/docs/v3/scripts/prettify/lang-css.js new file mode 100644 index 000000000..041e1f590 --- /dev/null +++ b/docs/v3/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/v3/scripts/prettify/prettify.js b/docs/v3/scripts/prettify/prettify.js new file mode 100644 index 000000000..eef5ad7e6 --- /dev/null +++ b/docs/v3/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p + + + + + + seq.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

seq.js

+ + + + + + + +
+
+
import reduce from './reduce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js'
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...AsyncFunction} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ *     var User = request.models.User;
+ *     async.seq(
+ *         User.get.bind(User),  // 'User.get' has signature (id, callback(err, data))
+ *         function(user, fn) {
+ *             user.getCats(fn);      // 'getCats' has signature (callback(err, data))
+ *         }
+ *     )(req.session.user_id, function (err, cats) {
+ *         if (err) {
+ *             console.error(err);
+ *             response.json({ status: 'error', message: err.message });
+ *         } else {
+ *             response.json({ status: 'ok', message: 'Cats found', data: cats });
+ *         }
+ *     });
+ * });
+ */
+export default function seq(...functions) {
+    var _functions = functions.map(wrapAsync);
+    return function (...args) {
+        var that = this;
+
+        var cb = args[args.length - 1];
+        if (typeof cb == 'function') {
+            args.pop();
+        } else {
+            cb = promiseCallback();
+        }
+
+        reduce(_functions, args, (newargs, fn, iterCb) => {
+            fn.apply(that, newargs.concat((err, ...nextargs) => {
+                iterCb(err, nextargs);
+            }));
+        },
+        (err, results) => cb(err, ...results));
+
+        return cb[PROMISE_SYMBOL]
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/series.js.html b/docs/v3/series.js.html new file mode 100644 index 000000000..1c429cd75 --- /dev/null +++ b/docs/v3/series.js.html @@ -0,0 +1,280 @@ + + + + + + + series.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

series.js

+ + + + + + + +
+
+
import _parallel from './internal/parallel.js'
+import eachOfSeries from './eachOfSeries.js'
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ *  results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing
+ * [async functions]{@link AsyncFunction} to run in series.
+ * Each function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @return {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * //Using Callbacks
+ * async.series([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             // do some async task
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             // then do another async task
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ], function(err, results) {
+ *     console.log(results);
+ *     // results is equal to ['one','two']
+ * });
+ *
+ * // an example using objects instead of arrays
+ * async.series({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             // do some async task
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         setTimeout(function() {
+ *             // then do another async task
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }, function(err, results) {
+ *     console.log(results);
+ *     // results is equal to: { one: 1, two: 2 }
+ * });
+ *
+ * //Using Promises
+ * async.series([
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'one');
+ *         }, 200);
+ *     },
+ *     function(callback) {
+ *         setTimeout(function() {
+ *             callback(null, 'two');
+ *         }, 100);
+ *     }
+ * ]).then(results => {
+ *     console.log(results);
+ *     // results is equal to ['one','two']
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.series({
+ *     one: function(callback) {
+ *         setTimeout(function() {
+ *             // do some async task
+ *             callback(null, 1);
+ *         }, 200);
+ *     },
+ *     two: function(callback) {
+ *         setTimeout(function() {
+ *             // then do another async task
+ *             callback(null, 2);
+ *         }, 100);
+ *     }
+ * }).then(results => {
+ *     console.log(results);
+ *     // results is equal to: { one: 1, two: 2 }
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * //Using async/await
+ * async () => {
+ *     try {
+ *         let results = await async.series([
+ *             function(callback) {
+ *                 setTimeout(function() {
+ *                     // do some async task
+ *                     callback(null, 'one');
+ *                 }, 200);
+ *             },
+ *             function(callback) {
+ *                 setTimeout(function() {
+ *                     // then do another async task
+ *                     callback(null, 'two');
+ *                 }, 100);
+ *             }
+ *         ]);
+ *         console.log(results);
+ *         // results is equal to ['one','two']
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * // an example using an object instead of an array
+ * async () => {
+ *     try {
+ *         let results = await async.parallel({
+ *             one: function(callback) {
+ *                 setTimeout(function() {
+ *                     // do some async task
+ *                     callback(null, 1);
+ *                 }, 200);
+ *             },
+ *            two: function(callback) {
+ *                 setTimeout(function() {
+ *                     // then do another async task
+ *                     callback(null, 2);
+ *                 }, 100);
+ *            }
+ *         });
+ *         console.log(results);
+ *         // results is equal to: { one: 1, two: 2 }
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+export default function series(tasks, callback) {
+    return _parallel(eachOfSeries, tasks, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/setImmediate.js.html b/docs/v3/setImmediate.js.html new file mode 100644 index 000000000..754ad5782 --- /dev/null +++ b/docs/v3/setImmediate.js.html @@ -0,0 +1,143 @@ + + + + + + + setImmediate.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

setImmediate.js

+ + + + + + + +
+
+
import setImmediate from './internal/setImmediate.js'
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`.  In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name setImmediate
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.nextTick]{@link module:Utils.nextTick}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ *     call_order.push('two');
+ *     // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ *     // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+export default setImmediate;
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/some.js.html b/docs/v3/some.js.html new file mode 100644 index 000000000..f6071a287 --- /dev/null +++ b/docs/v3/some.js.html @@ -0,0 +1,214 @@ + + + + + + + some.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

some.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOf from './eachOf.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ * @example
+ *
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ * // dir4 does not exist
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ *    fs.access(file, fs.constants.F_OK, (err) => {
+ *        callback(null, !err);
+ *    });
+ * }
+ *
+ * // Using callbacks
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists,
+ *    function(err, result) {
+ *        console.log(result);
+ *        // true
+ *        // result is true since some file in the list exists
+ *    }
+ *);
+ *
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists,
+ *    function(err, result) {
+ *        console.log(result);
+ *        // false
+ *        // result is false since none of the files exists
+ *    }
+ *);
+ *
+ * // Using Promises
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists)
+ * .then( result => {
+ *     console.log(result);
+ *     // true
+ *     // result is true since some file in the list exists
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists)
+ * .then( result => {
+ *     console.log(result);
+ *     // false
+ *     // result is false since none of the files exists
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists);
+ *         console.log(result);
+ *         // true
+ *         // result is true since some file in the list exists
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ * async () => {
+ *     try {
+ *         let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists);
+ *         console.log(result);
+ *         // false
+ *         // result is false since none of the files exists
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+function some(coll, iteratee, callback) {
+    return createTester(Boolean, res => res)(eachOf, coll, iteratee, callback)
+}
+export default awaitify(some, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/someLimit.js.html b/docs/v3/someLimit.js.html new file mode 100644 index 000000000..1696dd3ac --- /dev/null +++ b/docs/v3/someLimit.js.html @@ -0,0 +1,139 @@ + + + + + + + someLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

someLimit.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfLimit from './internal/eachOfLimit.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ */
+function someLimit(coll, limit, iteratee, callback) {
+    return createTester(Boolean, res => res)(eachOfLimit(limit), coll, iteratee, callback)
+}
+export default awaitify(someLimit, 4);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/someSeries.js.html b/docs/v3/someSeries.js.html new file mode 100644 index 000000000..f59ba1181 --- /dev/null +++ b/docs/v3/someSeries.js.html @@ -0,0 +1,138 @@ + + + + + + + someSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

someSeries.js

+ + + + + + + +
+
+
import createTester from './internal/createTester.js'
+import eachOfSeries from './eachOfSeries.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in series.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ */
+function someSeries(coll, iteratee, callback) {
+    return createTester(Boolean, res => res)(eachOfSeries, coll, iteratee, callback)
+}
+export default awaitify(someSeries, 3);
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/sortBy.js.html b/docs/v3/sortBy.js.html new file mode 100644 index 000000000..41b764d59 --- /dev/null +++ b/docs/v3/sortBy.js.html @@ -0,0 +1,281 @@ + + + + + + + sortBy.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

sortBy.js

+ + + + + + + +
+
+
import map from './map.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a value to use as the sort criteria as
+ * its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @returns {Promise} a promise, if no callback passed
+ * @example
+ *
+ * // bigfile.txt is a file that is 251100 bytes in size
+ * // mediumfile.txt is a file that is 11000 bytes in size
+ * // smallfile.txt is a file that is 121 bytes in size
+ *
+ * // asynchronous function that returns the file size in bytes
+ * function getFileSizeInBytes(file, callback) {
+ *     fs.stat(file, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         callback(null, stat.size);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes,
+ *     function(err, results) {
+ *         if (err) {
+ *             console.log(err);
+ *         } else {
+ *             console.log(results);
+ *             // results is now the original array of files sorted by
+ *             // file size (ascending by default), e.g.
+ *             // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+ *         }
+ *     }
+ * );
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) {
+ *     getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+ *         if (getFileSizeErr) return callback(getFileSizeErr);
+ *         callback(null, fileSize);
+ *     });
+ * }, function(err, results) {
+ *         if (err) {
+ *             console.log(err);
+ *         } else {
+ *             console.log(results);
+ *             // results is now the original array of files sorted by
+ *             // file size (ascending by default), e.g.
+ *             // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+ *         }
+ *     }
+ * );
+ *
+ * // descending order
+ * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) {
+ *     getFileSizeInBytes(file, function(getFileSizeErr, fileSize) {
+ *         if (getFileSizeErr) {
+ *             return callback(getFileSizeErr);
+ *         }
+ *         callback(null, fileSize * -1);
+ *     });
+ * }, function(err, results) {
+ *         if (err) {
+ *             console.log(err);
+ *         } else {
+ *             console.log(results);
+ *             // results is now the original array of files sorted by
+ *             // file size (ascending by default), e.g.
+ *             // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt']
+ *         }
+ *     }
+ * );
+ *
+ * // Error handling
+ * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes,
+ *     function(err, results) {
+ *         if (err) {
+ *             console.log(err);
+ *             // [ Error: ENOENT: no such file or directory ]
+ *         } else {
+ *             console.log(results);
+ *         }
+ *     }
+ * );
+ *
+ * // Using Promises
+ * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes)
+ * .then( results => {
+ *     console.log(results);
+ *     // results is now the original array of files sorted by
+ *     // file size (ascending by default), e.g.
+ *     // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+ * }).catch( err => {
+ *     console.log(err);
+ * });
+ *
+ * // Error handling
+ * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes)
+ * .then( results => {
+ *     console.log(results);
+ * }).catch( err => {
+ *     console.log(err);
+ *     // [ Error: ENOENT: no such file or directory ]
+ * });
+ *
+ * // Using async/await
+ * (async () => {
+ *     try {
+ *         let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+ *         console.log(results);
+ *         // results is now the original array of files sorted by
+ *         // file size (ascending by default), e.g.
+ *         // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt']
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * })();
+ *
+ * // Error handling
+ * async () => {
+ *     try {
+ *         let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes);
+ *         console.log(results);
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *         // [ Error: ENOENT: no such file or directory ]
+ *     }
+ * }
+ *
+ */
+function sortBy (coll, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    return map(coll, (x, iterCb) => {
+        _iteratee(x, (err, criteria) => {
+            if (err) return iterCb(err);
+            iterCb(err, {value: x, criteria});
+        });
+    }, (err, results) => {
+        if (err) return callback(err);
+        callback(null, results.sort(comparator).map(v => v.value));
+    });
+
+    function comparator(left, right) {
+        var a = left.criteria, b = right.criteria;
+        return a < b ? -1 : a > b ? 1 : 0;
+    }
+}
+export default awaitify(sortBy, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/styles/jsdoc-default.css b/docs/v3/styles/jsdoc-default.css new file mode 100644 index 000000000..ef165bfa2 --- /dev/null +++ b/docs/v3/styles/jsdoc-default.css @@ -0,0 +1,829 @@ +* { + box-sizing: border-box +} + +html, body { + height: 100%; + width: 100%; +} + +body { + color: #4d4e53; + background-color: white; + margin: 0 auto; + padding: 0; + + font-family: 'Helvetica Neue', Helvetica, sans-serif; + font-size: 16px; + line-height: 160%; +} + +a, +a:active { + color: #0095dd; + text-decoration: none; +} + +a:hover { + text-decoration: underline +} + +p, ul, ol, blockquote { + margin-bottom: 1em; +} + +h1, h2, h3, h4, h5, h6 { + font-family: 'Montserrat', sans-serif; +} + +h1, h2, h3, h4, h5, h6 { + color: #565656; + font-weight: 400; + margin: 0; + padding-top: 1em; +} + +h1 { + font-weight: 300; + font-size: 48px; + margin: 1em 0 .5em; +} + +h1.page-title { + font-size: 48px; + margin: 1em 30px; +} + +h2 { + font-size: 30px; + margin: 1.5em 0 .3em; +} + +h3 { + font-size: 24px; + margin: 1.2em 0 .3em; +} + +h4 { + font-size: 20px; + margin: 1em 0 .2em; + padding-top: 6em; + color: #4d4e53; +} + +h5, .container-overview .subsection-title { + font-size: 120%; + letter-spacing: -0.01em; + margin: 8px 0 3px 0; +} + +h6 { + font-size: 100%; + letter-spacing: -0.01em; + margin: 6px 0 3px 0; + font-style: italic; +} + +tt, code, kbd, samp { + font-family: Consolas, Monaco, 'Andale Mono', monospace; + background: #f4f4f4; + padding: 1px 5px; + border-radius: 5px; +} + +.class-description { + font-size: 130%; + line-height: 140%; + margin-bottom: 1em; + margin-top: 1em; +} + +.class-description:empty { + margin: 0 +} + +#main { + position: fixed; + top: 50px; + left: 250px; + right: 0; + bottom: 0; + float: none; + min-width: 360px; + overflow-y: hidden; +} + +#main-container { + position: relative; + width: 100%; + height: 100%; + overflow-y: scroll; + padding-left: 16px; + padding-right: 16px; +} + +#main-container h1 { + margin-top: 100px !important; + padding-top: 0px; + border-left: 2px solid #3391FE; +} + +#main-container h4 { + padding-top: 120px; + padding-left: 16px; + margin-left: -16px; +} + +#main-container h4::before { + content: ''; + position: relative; + left: -16px; + border-left: 2px solid #3391FE; +} + +header { + display: block +} + +section, h1 { + display: block; + background-color: #fff; + padding: 2em 30px 0; +} + +#toc > h3 { + margin-bottom: 0px; +} + +#toc > .methods > li { + padding: 0px 10px; +} + +#toc > .methods > li > a { + font-size: 12px; + padding: 0px; +} + +#toc > .methods > .toc-header { + margin-top: 10px; +} + +#toc > .methods > .toc-method { + padding: 0px; + margin: 0px 10px; +} + +#toc > .methods > .toc-method > a, +#toc > .methods > .toc-method > a.active { + padding: 0px 0px 0px 20px; + border-left: 1px solid #D8DCDF; + color: #98999A; +} + +#toc > .methods > .toc-method.active { + background-color: #E8E8E8; +} + +.nav.navbar-right .navbar-form { + padding: 0; + margin: 6px 0px; +} + +.navbar-collapse.collapse { + display: block!important; +} + +.navbar-nav>li, .navbar-nav { + float: left !important; +} + +.navbar-nav.navbar-right:last-child { + margin-right: -15px !important; +} + +.navbar-right { + float: right!important; +} + +.twitter-typeahead input { + border-radius: 8px; + height: 38px; +} + +.twitter-typeahead input.tt-hint { + color: #AAA; +} + +.tt-menu { + background-color: white; + width: 100%; + box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1); + z-index: 11; + overflow-y: auto; +} + +.tt-suggestion, .tt-menu h3 { + font-size: 14px; + padding: 0.6em; + margin: 0; + cursor: pointer; +} + +.tt-menu h3 { + cursor: default; + font-weight: bold; + color: #888; +} + +.tt-suggestion:hover { + background-color: rgba(128, 128, 128, 0.2); +} + +.tt-cursor { + background-color: #D3D3D3; +} + +.search-bar-header-first { + margin: 5px 0px; + border-bottom: 1px solid #D3D3D3; +} + +.search-bar-header { + margin: 5px 0px; + border-top: 1px solid #D3D3D3; + border-bottom: 1px solid #D3D3D3; +} + +.variation { + display: none +} + +.signature-attributes { + font-size: 60%; + color: #aaa; + font-style: italic; + font-weight: lighter; +} + +nav { + float: left; + display: block; + width: 250px; + background: #FAFAFA; + overflow: auto; + position: fixed; + height: 100%; + top: 50px; + padding-left: 12px; + overflow-y: auto; + height: calc(100% - 50px); + box-shadow: 1px 0 rgba(0, 0, 0, 0.1); +} + +nav h3 { + margin-top: 12px; + font-size: 13px; + text-transform: uppercase; + letter-spacing: 1px; + font-weight: 700; + line-height: 24px; + margin: 15px 0 10px; + padding: 0; + color: #000; +} + +nav ul { + font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; + font-size: 100%; + line-height: 17px; + padding: 0; + margin: 0; + list-style-type: none; +} + +nav ul a, +nav ul a:active { + font-family: 'Montserrat', sans-serif; + line-height: 18px; + padding: 0; + display: block; + font-size: 12px; +} + +nav ul a:hover, +nav ul a:active { + color: hsl(200, 100%, 43%); + text-decoration: none; +} + +nav > ul { + padding: 0 10px; +} + +nav > ul > li > a { + color: #000; +} + +nav ul ul { + margin-bottom: 10px +} + +nav ul ul a { + color: hsl(207, 1%, 60%); + border-left: 1px solid hsl(207, 10%, 86%); +} + +nav ul ul a, +nav ul ul a:active { + padding-left: 20px +} + +nav h2 { + font-size: 12px; + margin: 0; + padding: 0; +} + +nav > h2 > a { + display: block; + margin: 10px 0 -10px; + color: hsl(202, 71%, 50%) !important; +} + + +.navbar-brand { + padding: 8px; +} + +.navbar-brand img { + height: 32px; +} + +.navbar-fixed-top { + z-index: 1; + background-color: #F0F0F0; + padding: 0px 10px; + border-left: 6px solid #3391FE; +} + +.navbar-fixed-top .navbar-right { + padding-right: 16px; +} + +.navbar .ion-social-github { + font-size: 1.5em; + float: left; + color: #3391FE; +} + +.navbar .ion-social-github:hover { + color: #3D7FC1; +} + +footer { + max-width: 800px; + margin: 0 auto 4em; + color: hsl(0, 0%, 56%); + display: block; + padding: 30px 30px 0; + font-size: 12px; + line-height: 1.4; +} + +#main section, #main h1 { + margin: 0 auto; + max-width: 800px; +} + +article img { + max-width: 100%; +} + +/* fix bootstrap's styling */ +pre { + background: #fff; + padding: 0px; +} + +code { + color: hsl(0, 0%, 35%); +} + +.ancestors { + color: #999 +} + +.ancestors a { + color: #999 !important; + text-decoration: none; +} + +.clear { + clear: both +} + +.important { + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px +} + +.type-signature { + color: #aaa; + display: none; +} + +.name, .signature { + font-family: Consolas, Monaco, 'Andale Mono', monospace +} + +.details { + margin-top: 14px; + border-left: 2px solid #DDD; + line-height: 30px; +} + +.alias-details { + margin-top: -10px; + border-left: none; +} + +.details dt { + width: 120px; + float: left; + padding-left: 10px; +} + +.alias-details dt { + padding-left: 0px; +} + +.details dd { + margin-left: 70px +} + +.details ul { + margin: 0 +} + +.details ul { + list-style-type: none +} + +.details li { + margin-left: 30px +} + +.details pre.prettyprint { + margin: 0 +} + +.details .object-value { + padding-top: 0 +} + +.description { + margin-bottom: 1em; + margin-top: 1em; +} + +.code-caption { + font-style: italic; + font-size: 107%; + margin: 0; +} + +.prettyprint { + font-size: 13px; + border: 1px solid #ddd; + border-radius: 3px; + box-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.05); + overflow: auto; +} + +.prettyprint.source { + width: inherit +} + +.prettyprint code { + font-size: 100%; + line-height: 18px; + display: block; + background-color: #fff; + color: #4D4E53; +} + +.prettyprint > code { + padding: 15px +} + +.prettyprint .linenums code { + padding: 0 1em; + min-height: 18px; +} + +.prettyprint .linenums li:first-of-type code { + padding-top: 15px +} + +.prettyprint code span.line { + display: inline-block +} + +.prettyprint.linenums { + padding-left: 70px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.prettyprint.linenums ol { + padding-left: 0 +} + +.prettyprint.linenums li { + border-left: 3px #ddd solid +} + +.prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { + background-color: lightyellow +} + +.prettyprint.linenums li * { + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +table.params { + margin-top: 1em; + box-shadow: none; + border: none; +} + +table.params td, table.params th { + border: none; + padding: 0 15px 8px 0; +} + +table.params td.type { + white-space: nowrap; +} + +.params .optional { + font-size: 80%; + color: hsl(0, 0%, 56%); +} + +.params, .props { + border-spacing: 0; + border: 1px solid #ddd; + border-collapse: collapse; + border-radius: 3px; + box-shadow: 0 1px 3px rgba(0,0,0,0.1); + width: 100%; + font-size: 14px; +} + +.params .name, .props .name, .name code { + color: #4D4E53; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 100%; +} + +.params td, .params th, .props td, .props th { + margin: 0px; + text-align: left; + vertical-align: top; + padding: 10px; + display: table-cell; +} + +.params td { + border-top: 1px solid #eee +} + +.params thead tr, .props thead tr { + background-color: #fff; + font-weight: bold; + color: hsl(0, 0%, 56%); +} + +.params .params thead tr, .props .props thead tr { + background-color: #fff; + font-weight: bold; +} + +.params td.description > p:first-child, .props td.description > p:first-child { + margin-top: 0; + padding-top: 0; +} + +.params td.description > p:last-child, .props td.description > p:last-child { + margin-bottom: 0; + padding-bottom: 0; +} + +dl.param-type { + border-bottom: 1px solid hsl(0, 0%, 87%); + margin-bottom: 30px; + padding-bottom: 30px; +} + +.param-type dt, .param-type dd { + display: inline-block +} + +.param-type dd { + font-family: Consolas, Monaco, 'Andale Mono', monospace +} + +.disabled { + color: #454545 +} + +/* navicon button */ +.navicon-button { + display: none; + position: relative; + padding: 2.0625rem 1.5rem; + transition: 0.25s; + cursor: pointer; + user-select: none; + opacity: .8; + color: #3391FE; +} +.navicon-button .navicon:before, .navicon-button .navicon:after { + transition: 0.25s; +} +.navicon-button:hover { + transition: 0.5s; + opacity: 1; +} +.navicon-button:hover .navicon:before, .navicon-button:hover .navicon:after { + transition: 0.25s; +} +.navicon-button:hover .navicon:before { + top: .825rem; +} +.navicon-button:hover .navicon:after { + top: -.825rem; +} + +/* navicon */ +.navicon { + position: relative; + width: 32px; + height: 4px; + background: #3391FE; + transition: 0.3s; + border-radius: 2px; +} +.navicon:before, .navicon:after { + display: block; + content: ""; + height: 4px; + width: 32px; + background: #3391FE; + position: absolute; + z-index: -1; + transition: 0.3s 0.25s; + border-radius: 2px; +} +.navicon:before { + top: 10px; +} +.navicon:after { + top: -10px; +} + +/* open */ +.nav-trigger:checked + label:not(.steps) .navicon:before, +.nav-trigger:checked + label:not(.steps) .navicon:after { + top: 0 !important; +} + +.nav-trigger:checked + label .navicon:before, +.nav-trigger:checked + label .navicon:after { + transition: 0.5s; +} + +/* Minus */ +.nav-trigger:checked + label { + transform: scale(0.75); +} + +/* ร— and + */ +.nav-trigger:checked + label.plus .navicon, +.nav-trigger:checked + label.x .navicon { + background: transparent; +} + +.nav-trigger:checked + label.plus .navicon:before, +.nav-trigger:checked + label.x .navicon:before { + transform: rotate(-45deg); + background: #FFF; +} + +.nav-trigger:checked + label.plus .navicon:after, +.nav-trigger:checked + label.x .navicon:after { + transform: rotate(45deg); + background: #FFF; +} + +.nav-trigger:checked + label.plus { + transform: scale(0.75) rotate(45deg); +} + +.nav-trigger:checked ~ nav { + left: 0 !important; +} + +.nav-trigger:checked ~ .overlay { + display: block; +} + +.nav-trigger { + position: fixed; + top: 0; + clip: rect(0, 0, 0, 0); +} + +.overlay { + display: none; + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 100%; + height: 100%; + background: hsla(0, 0%, 0%, 0.5); + z-index: 1; +} + +@media only screen and (min-width: 320px) and (max-width: 680px) { + body { + overflow-x: hidden; + } + + nav { + background: #FFF; + width: 250px; + height: 100%; + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: -250px; + z-index: 3; + padding: 0 10px; + transition: left 0.2s; + } + + .navicon-button { + display: inline-block; + position: fixed; + right: 0; + z-index: 2; + } + + #main { + padding: 16px; + left: 0px; + min-width: 360px; + } + + #main h1.page-title { + margin: 1em 0; + } + + #main h4 { + margin-left: -8px; + padding-left: 8px; + } + + #main section { + padding: 0; + } + + footer { + margin-left: 0; + } +} + +@media only print { + nav { + display: none; + } + + #main { + float: none; + width: 100%; + } +} diff --git a/docs/v3/styles/prettify-jsdoc.css b/docs/v3/styles/prettify-jsdoc.css new file mode 100644 index 000000000..834a866d4 --- /dev/null +++ b/docs/v3/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: hsl(104, 100%, 24%); + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/docs/v3/styles/prettify-tomorrow.css b/docs/v3/styles/prettify-tomorrow.css new file mode 100644 index 000000000..81e74d135 --- /dev/null +++ b/docs/v3/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: hsl(104, 100%, 24%); } + + /* a keyword */ + .kwd { + color: hsl(240, 100%, 50%); } + + /* a comment */ + .com { + color: hsl(0, 0%, 60%); } + + /* a type name */ + .typ { + color: hsl(240, 100%, 32%); } + + /* a literal value */ + .lit { + color: hsl(240, 100%, 40%); } + + /* punctuation */ + .pun { + color: #000000; } + + /* lisp open bracket */ + .opn { + color: #000000; } + + /* lisp close bracket */ + .clo { + color: #000000; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/docs/v3/timeout.js.html b/docs/v3/timeout.js.html new file mode 100644 index 000000000..97222f3f9 --- /dev/null +++ b/docs/v3/timeout.js.html @@ -0,0 +1,183 @@ + + + + + + + timeout.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timeout.js

+ + + + + + + +
+
+
import initialParams from './internal/initialParams.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} asyncFn - The async function to limit in time.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {AsyncFunction} Returns a wrapped function that can be used with any
+ * of the control flow functions.
+ * Invoke this function with the same parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ *     doAsyncTask(foo, function(err, data) {
+ *         // handle errors
+ *         if (err) return callback(err);
+ *
+ *         // do some stuff ...
+ *
+ *         // return processed data
+ *         return callback(null, data);
+ *     });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ *     // if `myFunction` takes < 1000 ms to execute, `err`
+ *     // and `data` will have their expected values
+ *
+ *     // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+export default function timeout(asyncFn, milliseconds, info) {
+    var fn = wrapAsync(asyncFn);
+
+    return initialParams((args, callback) => {
+        var timedOut = false;
+        var timer;
+
+        function timeoutCallback() {
+            var name = asyncFn.name || 'anonymous';
+            var error  = new Error('Callback function "' + name + '" timed out.');
+            error.code = 'ETIMEDOUT';
+            if (info) {
+                error.info = info;
+            }
+            timedOut = true;
+            callback(error);
+        }
+
+        args.push((...cbArgs) => {
+            if (!timedOut) {
+                callback(...cbArgs);
+                clearTimeout(timer);
+            }
+        });
+
+        // setup timer and call original function
+        timer = setTimeout(timeoutCallback, milliseconds);
+        fn(...args);
+    });
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/times.js.html b/docs/v3/times.js.html new file mode 100644 index 000000000..f648b82d6 --- /dev/null +++ b/docs/v3/times.js.html @@ -0,0 +1,147 @@ + + + + + + + times.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

times.js

+ + + + + + + +
+
+
import timesLimit from './timesLimit.js'
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @returns {Promise} a promise, if no callback is provided
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ *     callback(null, {
+ *         id: 'user' + id
+ *     });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ *     createUser(n, function(err, user) {
+ *         next(err, user);
+ *     });
+ * }, function(err, users) {
+ *     // we should now have 5 users
+ * });
+ */
+export default function times (n, iteratee, callback) {
+    return timesLimit(n, Infinity, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/timesLimit.js.html b/docs/v3/timesLimit.js.html new file mode 100644 index 000000000..0de8da0cc --- /dev/null +++ b/docs/v3/timesLimit.js.html @@ -0,0 +1,134 @@ + + + + + + + timesLimit.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timesLimit.js

+ + + + + + + +
+
+
import mapLimit from './mapLimit.js'
+import range from './internal/range.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ * @returns {Promise} a promise, if no callback is provided
+ */
+export default function timesLimit(count, limit, iteratee, callback) {
+    var _iteratee = wrapAsync(iteratee);
+    return mapLimit(range(count), limit, _iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/timesSeries.js.html b/docs/v3/timesSeries.js.html new file mode 100644 index 000000000..9683b399e --- /dev/null +++ b/docs/v3/timesSeries.js.html @@ -0,0 +1,129 @@ + + + + + + + timesSeries.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

timesSeries.js

+ + + + + + + +
+
+
import timesLimit from './timesLimit.js'
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @returns {Promise} a promise, if no callback is provided
+ */
+export default function timesSeries (n, iteratee, callback) {
+    return timesLimit(n, 1, iteratee, callback)
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/transform.js.html b/docs/v3/transform.js.html new file mode 100644 index 000000000..631c89fea --- /dev/null +++ b/docs/v3/transform.js.html @@ -0,0 +1,263 @@ + + + + + + + transform.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

transform.js

+ + + + + + + +
+
+
import eachOf from './eachOf.js'
+import once from './internal/once.js'
+import wrapAsync from './internal/wrapAsync.js'
+import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js'
+
+/**
+ * A relative of `reduce`.  Takes an Object or Array, and iterates over each
+ * element in parallel, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform.  If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @returns {Promise} a promise, if no callback provided
+ * @example
+ *
+ * // file1.txt is a file that is 1000 bytes in size
+ * // file2.txt is a file that is 2000 bytes in size
+ * // file3.txt is a file that is 3000 bytes in size
+ *
+ * // helper function that returns human-readable size format from bytes
+ * function formatBytes(bytes, decimals = 2) {
+ *   // implementation not included for brevity
+ *   return humanReadbleFilesize;
+ * }
+ *
+ * const fileList = ['file1.txt','file2.txt','file3.txt'];
+ *
+ * // asynchronous function that returns the file size, transformed to human-readable format
+ * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+ * function transformFileSize(acc, value, key, callback) {
+ *     fs.stat(value, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         acc[key] = formatBytes(stat.size);
+ *         callback(null);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.transform(fileList, transformFileSize, function(err, result) {
+ *     if(err) {
+ *         console.log(err);
+ *     } else {
+ *         console.log(result);
+ *         // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.transform(fileList, transformFileSize)
+ * .then(result => {
+ *     console.log(result);
+ *     // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * (async () => {
+ *     try {
+ *         let result = await async.transform(fileList, transformFileSize);
+ *         console.log(result);
+ *         // [ '1000 Bytes', '1.95 KB', '2.93 KB' ]
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * })();
+ *
+ * @example
+ *
+ * // file1.txt is a file that is 1000 bytes in size
+ * // file2.txt is a file that is 2000 bytes in size
+ * // file3.txt is a file that is 3000 bytes in size
+ *
+ * // helper function that returns human-readable size format from bytes
+ * function formatBytes(bytes, decimals = 2) {
+ *   // implementation not included for brevity
+ *   return humanReadbleFilesize;
+ * }
+ *
+ * const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' };
+ *
+ * // asynchronous function that returns the file size, transformed to human-readable format
+ * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc.
+ * function transformFileSize(acc, value, key, callback) {
+ *     fs.stat(value, function(err, stat) {
+ *         if (err) {
+ *             return callback(err);
+ *         }
+ *         acc[key] = formatBytes(stat.size);
+ *         callback(null);
+ *     });
+ * }
+ *
+ * // Using callbacks
+ * async.transform(fileMap, transformFileSize, function(err, result) {
+ *     if(err) {
+ *         console.log(err);
+ *     } else {
+ *         console.log(result);
+ *         // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+ *     }
+ * });
+ *
+ * // Using Promises
+ * async.transform(fileMap, transformFileSize)
+ * .then(result => {
+ *     console.log(result);
+ *     // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+ * }).catch(err => {
+ *     console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ *     try {
+ *         let result = await async.transform(fileMap, transformFileSize);
+ *         console.log(result);
+ *         // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' }
+ *     }
+ *     catch (err) {
+ *         console.log(err);
+ *     }
+ * }
+ *
+ */
+export default function transform (coll, accumulator, iteratee, callback) {
+    if (arguments.length <= 3 && typeof accumulator === 'function') {
+        callback = iteratee;
+        iteratee = accumulator;
+        accumulator = Array.isArray(coll) ? [] : {};
+    }
+    callback = once(callback || promiseCallback());
+    var _iteratee = wrapAsync(iteratee);
+
+    eachOf(coll, (v, k, cb) => {
+        _iteratee(accumulator, v, k, cb);
+    }, err => callback(err, accumulator));
+    return callback[PROMISE_SYMBOL]
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/tryEach.js.html b/docs/v3/tryEach.js.html new file mode 100644 index 000000000..5bf9dd36a --- /dev/null +++ b/docs/v3/tryEach.js.html @@ -0,0 +1,170 @@ + + + + + + + tryEach.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

tryEach.js

+ + + + + + + +
+
+
import eachSeries from './eachSeries.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * It runs each task in series but stops whenever any of the functions were
+ * successful. If one of the tasks were successful, the `callback` will be
+ * passed the result of the successful task. If all tasks fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name tryEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing functions to
+ * run, each function is passed a `callback(err, result)` it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback which is called when one
+ * of the tasks has succeeded, or all have failed. It receives the `err` and
+ * `result` arguments of the last attempt at completing the `task`. Invoked with
+ * (err, results).
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ * async.tryEach([
+ *     function getDataFromFirstWebsite(callback) {
+ *         // Try getting the data from the first website
+ *         callback(err, data);
+ *     },
+ *     function getDataFromSecondWebsite(callback) {
+ *         // First website failed,
+ *         // Try getting the data from the backup website
+ *         callback(err, data);
+ *     }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ *     Now do something with the data.
+ * });
+ *
+ */
+function tryEach(tasks, callback) {
+    var error = null;
+    var result;
+    return eachSeries(tasks, (task, taskCb) => {
+        wrapAsync(task)((err, ...args) => {
+            if (err === false) return taskCb(err);
+
+            if (args.length < 2) {
+                [result] = args;
+            } else {
+                result = args;
+            }
+            error = err;
+            taskCb(err ? null : {});
+        });
+    }, () => callback(error, result));
+}
+
+export default awaitify(tryEach)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/unmemoize.js.html b/docs/v3/unmemoize.js.html new file mode 100644 index 000000000..147f2f364 --- /dev/null +++ b/docs/v3/unmemoize.js.html @@ -0,0 +1,127 @@ + + + + + + + unmemoize.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

unmemoize.js

+ + + + + + + +
+
+
/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {AsyncFunction} fn - the memoized function
+ * @returns {AsyncFunction} a function that calls the original unmemoized function
+ */
+export default  function unmemoize(fn) {
+    return (...args) => {
+        return (fn.unmemoized || fn)(...args);
+    };
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/until.js.html b/docs/v3/until.js.html new file mode 100644 index 000000000..1789d755f --- /dev/null +++ b/docs/v3/until.js.html @@ -0,0 +1,155 @@ + + + + + + + until.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

until.js

+ + + + + + + +
+
+
import whilst from './whilst.js'
+import wrapAsync from './internal/wrapAsync.js'
+
+/**
+ * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `iteratee`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with (callback).
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns {Promise} a promise, if a callback is not passed
+ *
+ * @example
+ * const results = []
+ * let finished = false
+ * async.until(function test(cb) {
+ *     cb(null, finished)
+ * }, function iter(next) {
+ *     fetchPage(url, (err, body) => {
+ *         if (err) return next(err)
+ *         results = results.concat(body.objects)
+ *         finished = !!body.next
+ *         next(err)
+ *     })
+ * }, function done (err) {
+ *     // all pages have been fetched
+ * })
+ */
+export default function until(test, iteratee, callback) {
+    const _test = wrapAsync(test)
+    return whilst((cb) => _test((err, truth) => cb (err, !truth)), iteratee, callback);
+}
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/waterfall.js.html b/docs/v3/waterfall.js.html new file mode 100644 index 000000000..ee780e4d5 --- /dev/null +++ b/docs/v3/waterfall.js.html @@ -0,0 +1,194 @@ + + + + + + + waterfall.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

waterfall.js

+ + + + + + + +
+
+
import once from './internal/once.js'
+import onlyOnce from './internal/onlyOnce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
+ * to run.
+ * Each function should complete with any number of `result` values.
+ * The `result` values will be passed as arguments, in order, to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns {Promise} a promise, if a callback is omitted
+ * @example
+ *
+ * async.waterfall([
+ *     function(callback) {
+ *         callback(null, 'one', 'two');
+ *     },
+ *     function(arg1, arg2, callback) {
+ *         // arg1 now equals 'one' and arg2 now equals 'two'
+ *         callback(null, 'three');
+ *     },
+ *     function(arg1, callback) {
+ *         // arg1 now equals 'three'
+ *         callback(null, 'done');
+ *     }
+ * ], function (err, result) {
+ *     // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ *     myFirstFunction,
+ *     mySecondFunction,
+ *     myLastFunction,
+ * ], function (err, result) {
+ *     // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ *     callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ *     // arg1 now equals 'one' and arg2 now equals 'two'
+ *     callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ *     // arg1 now equals 'three'
+ *     callback(null, 'done');
+ * }
+ */
+function waterfall (tasks, callback) {
+    callback = once(callback);
+    if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+    if (!tasks.length) return callback();
+    var taskIndex = 0;
+
+    function nextTask(args) {
+        var task = wrapAsync(tasks[taskIndex++]);
+        task(...args, onlyOnce(next));
+    }
+
+    function next(err, ...args) {
+        if (err === false) return
+        if (err || taskIndex === tasks.length) {
+            return callback(err, ...args);
+        }
+        nextTask(args);
+    }
+
+    nextTask([]);
+}
+
+export default awaitify(waterfall)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/whilst.js.html b/docs/v3/whilst.js.html new file mode 100644 index 000000000..661cd3d13 --- /dev/null +++ b/docs/v3/whilst.js.html @@ -0,0 +1,170 @@ + + + + + + + whilst.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

whilst.js

+ + + + + + + +
+
+
import onlyOnce from './internal/onlyOnce.js'
+import wrapAsync from './internal/wrapAsync.js'
+import awaitify from './internal/awaitify.js'
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with (callback).
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns {Promise} a promise, if no callback is passed
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ *     function test(cb) { cb(null, count < 5); },
+ *     function iter(callback) {
+ *         count++;
+ *         setTimeout(function() {
+ *             callback(null, count);
+ *         }, 1000);
+ *     },
+ *     function (err, n) {
+ *         // 5 seconds have passed, n = 5
+ *     }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+    callback = onlyOnce(callback);
+    var _fn = wrapAsync(iteratee);
+    var _test = wrapAsync(test);
+    var results = [];
+
+    function next(err, ...rest) {
+        if (err) return callback(err);
+        results = rest;
+        if (err === false) return;
+        _test(check);
+    }
+
+    function check(err, truth) {
+        if (err) return callback(err);
+        if (err === false) return;
+        if (!truth) return callback(null, ...results);
+        _fn(next);
+    }
+
+    return _test(check);
+}
+export default awaitify(whilst, 3)
+
+
+
+ + + + +
+ Documentation generated by JSDoc 4.0.3 using the Minami theme. +
+
+ + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/intro.md b/intro.md index 25d9796b7..c8e78b4fc 100644 --- a/intro.md +++ b/intro.md @@ -9,14 +9,12 @@ 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`, +use with [Node.js](https://nodejs.org/) and installable via `npm i async`, it can also be used directly in the browser. Async is also installable via: -- [bower](http://bower.io/): `bower install async` -- [component](https://github.com/componentjs/component): `component install caolan/async` -- [jam](http://jamjs.org/): `jam install async` +- [yarn](https://yarnpkg.com/en/): `yarn add async` Async provides around 70 functions that include the usual 'functional' suspects (`map`, `reduce`, `filter`, `each`โ€ฆ) as well as some common patterns @@ -24,11 +22,13 @@ for asynchronous control flow (`parallel`, `series`, `waterfall`โ€ฆ). All these functions assume you follow the Node.js convention of providing a single callback as the last argument of your asynchronous function -- a callback which expects an Error as its first argument -- and calling the callback once. +You can also pass `async` functions to Async methods, instead of callback-accepting functions. For more information, see [AsyncFunction](global.html#AsyncFunction) + ## Quick Examples ```js -async.map(['file1','file2','file3'], fs.stat, function(err, results){ +async.map(['file1','file2','file3'], fs.stat, function(err, results) { // results is now an array of stats for each file }); @@ -36,20 +36,20 @@ async.filter(['file1','file2','file3'], function(filePath, callback) { fs.access(filePath, function(err) { callback(null, !err) }); -}, function(err, results){ +}, function(err, results) { // results now equals an array of the existing files }); async.parallel([ - function(callback){ ... }, - function(callback){ ... } + function(callback) { ... }, + function(callback) { ... } ], function(err, results) { // optional callback }); async.series([ - function(callback){ ... }, - function(callback){ ... } + function(callback) { ... }, + function(callback) { ... } ]); ``` @@ -82,7 +82,7 @@ Just change it to: ```js async.eachSeries(hugeArray, function iteratee(item, callback) { if (inCache(item)) { - async.setImmediate(function () { + async.setImmediate(function() { callback(null, cache[item]); }); } else { @@ -103,7 +103,7 @@ Make sure to always `return` when calling a callback early, otherwise you will c ```js async.waterfall([ - function (callback) { + function(callback) { getSomething(options, function (err, result) { if (err) { callback(new Error("failed getting something:" + err.message)); @@ -120,11 +120,30 @@ async.waterfall([ It is always good practice to `return callback(err, result)` whenever a callback call is not the last statement of a function. +### Using ES2017 `async` functions + +Async accepts `async` functions wherever we accept a Node-style callback function. However, we do not pass them a callback, and instead use the return value and handle any promise rejections or errors thrown. + +```js +async.mapLimit(files, 10, async file => { // <- no callback! + const text = await util.promisify(fs.readFile)(dir + file, 'utf8') + const body = JSON.parse(text) // <- a parse error here will be caught automatically + if (!(await checkValidity(body))) { + throw new Error(`${file} has invalid contents`) // <- this error will also be caught + } + return body // <- return a value! +}, (err, contents) => { + if (err) throw err + console.log(contents) +}) +``` + +We can only detect native `async` functions, not transpiled versions (e.g. with Babel). Otherwise, you can wrap `async` functions in `async.asyncify()`. ### Binding a context to an iteratee -This section is really about `bind`, not about `async`. If you are wondering how to -make `async` execute your iteratees in a given context, or are confused as to why +This section is really about `bind`, not about Async. If you are wondering how to +make Async execute your iteratees in a given context, or are confused as to why a method of another library isn't working as an iteratee, study this example: ```js @@ -139,22 +158,60 @@ var AsyncSquaringLibrary = { } }; -async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){ +async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result) { // result is [NaN, NaN, NaN] // This fails because the `this.squareExponent` expression in the square // function is not evaluated in the context of AsyncSquaringLibrary, and is // therefore undefined. }); -async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){ +async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result) { // result is [1, 4, 9] // With the help of bind we can attach a context to the iteratee before - // passing it to async. Now the square function will be executed in its + // passing it to Async. Now the square function will be executed in its // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent` // will be as expected. }); ``` +### Subtle Memory Leaks + +There are cases where you might want to exit early from async flow, when calling an Async method inside another async function: + +```javascript +function myFunction (args, outerCallback) { + async.waterfall([ + //... + function (arg, next) { + if (someImportantCondition()) { + return outerCallback(null) + } + }, + function (arg, next) {/*...*/} + ], function done (err) { + //... + }) +} +``` + +Something happened in a waterfall where you want to skip the rest of the execution, so you call an outer callack. However, Async will still wait for that inner `next` callback to be called, leaving some closure scope allocated. + +As of version 3.0, you can call any Async callback with `false` as the `error` argument, and the rest of the execution of the Async method will be stopped or ignored. + +```javascript + function (arg, next) { + if (someImportantCondition()) { + outerCallback(null) + return next(false) // โ† signal that you called an outer callback + } + }, +``` + +### Mutating collections while processing them + +If you pass an array to a collection method (such as `each`, `mapLimit`, or `filterSeries`), and then attempt to `push`, `pop`, or `splice` additional items on to the array, this could lead to unexpected or undefined behavior. Async will iterate until the original `length` of the array is met, and the indexes of items `pop()`ed or `splice()`d could already have been processed. Therefore, it is not recommended to modify the array after Async has begun iterating over it. If you do need to `push`, `pop`, or `splice`, use a `queue` instead. + + ## Download The source is available for download from @@ -162,13 +219,7 @@ The source is available for download from Alternatively, you can install using npm: ```bash -$ npm install --save async -``` - -As well as using Bower: - -```bash -$ bower install async +$ npm i async ``` You can then `require()` async as normal: @@ -188,7 +239,9 @@ __Development:__ [async.js](https://raw.githubusercontent.com/caolan/async/maste ### In the Browser -Async should work in any ES5 environment (IE9 and above). +Async should work in any ES2015 environment (Node 6+ and all modern browsers). + +If you want to use Async in an older environment, (e.g. Node 4, IE11) you will have to transpile. Usage: @@ -196,19 +249,24 @@ Usage: ``` +The portable versions of Async, including `async.js` and `async.min.js`, are +included in the `/dist` folder. Async can also be found on the [jsDelivr CDN](http://www.jsdelivr.com/projects/async). + ### ES Modules -We also provide async as a collection of ES2015 modules, in an alternative `async-es` package on npm. +Async includes a `.mjs` version that should automatically be used by compatible bundlers such as Webpack or Rollup, anything that uses the `module` field of the `package.json`. + +We also provide Async as a collection of purely ES2015 modules, in an alternative `async-es` package on npm. ```bash -$ npm install --save async-es +$ npm install async-es ``` ```js @@ -216,3 +274,28 @@ import waterfall from 'async-es/waterfall'; import async from 'async-es'; ``` +### Typescript + +There are third-party type definitions for Async. + +``` +npm i -D @types/async +``` + +It is recommended to target ES2017 or higher in your `tsconfig.json`, so `async` functions are preserved: + +```json +{ + "compilerOptions": { + "target": "es2017" + } +} +``` + +## Other Libraries + +* [`limiter`](https://www.npmjs.com/package/limiter) a package for rate-limiting based on requests per sec/hour. +* [`neo-async`](https://www.npmjs.com/package/neo-async) an altername implementation of Async, focusing on speed. +* [`co-async`](https://www.npmjs.com/package/co-async) a library inspired by Async for use with [`co`](https://www.npmjs.com/package/co) and generator functions. +* [`promise-async`](https://www.npmjs.com/package/promise-async) a version of Async where all the methods are Promisified. +* ['modern-async'](https://www.npmjs.com/package/modern-async) an alternative to Async using only async/await and promises. diff --git a/karma.conf.js b/karma.conf.js index 62b5cb83b..600894c7c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,10 +1,18 @@ module.exports = function(config) { config.set({ browsers: ['Firefox'], - files: ['mocha_test/*.js'], + files: ['test/*.js'], frameworks: ['browserify', 'mocha'], + plugins: [ + 'karma-browserify', + 'karma-mocha', + 'karma-mocha-reporter', + 'karma-firefox-launcher', + 'karma-safari-launcher' + ], preprocessors: { - 'mocha_test/*.js': ['browserify'] + 'test/*.js': ['browserify'], + 'lib/*.js': ['browserify'] }, reporters: ['mocha'], singleRun: true, diff --git a/lib/apply.js b/lib/apply.js index 9ec7e25c5..b822bc0c9 100644 --- a/lib/apply.js +++ b/lib/apply.js @@ -1,5 +1,3 @@ -import rest from 'lodash/_baseRest'; - /** * Creates a continuation function with some arguments already applied. * @@ -12,10 +10,11 @@ import rest from 'lodash/_baseRest'; * @memberOf module:Utils * @method * @category Util - * @param {Function} function - The function you want to eventually apply all + * @param {Function} fn - The function you want to eventually apply all * arguments to. Invokes with (arguments...). * @param {...*} arguments... - Any number of arguments to automatically apply * when the continuation is called. + * @returns {Function} the partially-applied function * @example * * // using apply @@ -44,8 +43,6 @@ import rest from 'lodash/_baseRest'; * two * three */ -export default rest(function(fn, args) { - return rest(function(callArgs) { - return fn.apply(null, args.concat(callArgs)); - }); -}); +export default function(fn, ...args) { + return (...callArgs) => fn(...args,...callArgs); +} diff --git a/lib/applyEach.js b/lib/applyEach.js index a776ce82d..a03dd71a1 100644 --- a/lib/applyEach.js +++ b/lib/applyEach.js @@ -1,34 +1,42 @@ -import applyEach from './internal/applyEach'; -import map from './map'; +import applyEach from './internal/applyEach.js' +import map from './map.js' /** * Applies the provided arguments to each function in the array, calling * `callback` after all functions have completed. If you only provide the first - * argument, then it will return a function which lets you pass in the - * arguments as if it were a single function call. + * argument, `fns`, then it will return a function which lets you pass in the + * arguments as if it were a single function call. If more arguments are + * provided, `callback` is required while `args` is still optional. The results + * for each of the applied async functions are passed to the final callback + * as an array. * * @name applyEach * @static * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all - * call with the same arguments + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s + * to all call with the same arguments * @param {...*} [args] - any number of separate arguments to pass to the * function. * @param {Function} [callback] - the final argument should be the callback, * called when all functions have completed processing. - * @returns {Function} - If only the first argument is provided, it will return - * a function which lets you pass in the arguments as if it were a single - * function call. + * @returns {AsyncFunction} - Returns a function that takes no args other than + * an optional callback, that is the result of applying the `args` to each + * of the functions. * @example * - * async.applyEach([enableSearch, updateSchema], 'bucket', callback); + * const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket') + * + * appliedFn((err, results) => { + * // results[0] is the results for `enableSearch` + * // results[1] is the results for `updateSchema` + * }); * * // partial application example: * async.each( * buckets, - * async.applyEach([enableSearch, updateSchema]), + * async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(), * callback * ); */ diff --git a/lib/applyEachSeries.js b/lib/applyEachSeries.js index 5a7c257bf..9dec9ece2 100644 --- a/lib/applyEachSeries.js +++ b/lib/applyEachSeries.js @@ -1,5 +1,5 @@ -import applyEach from './internal/applyEach'; -import mapSeries from './mapSeries'; +import applyEach from './internal/applyEach.js' +import mapSeries from './mapSeries.js' /** * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time. @@ -10,14 +10,14 @@ import mapSeries from './mapSeries'; * @method * @see [async.applyEach]{@link module:ControlFlow.applyEach} * @category Control Flow - * @param {Array|Iterable|Object} fns - A collection of asynchronous functions to all + * @param {Array|Iterable|AsyncIterable|Object} fns - A collection of {@link AsyncFunction}s to all * call with the same arguments * @param {...*} [args] - any number of separate arguments to pass to the * function. * @param {Function} [callback] - the final argument should be the callback, * called when all functions have completed processing. - * @returns {Function} - If only the first argument is provided, it will return - * a function which lets you pass in the arguments as if it were a single - * function call. + * @returns {AsyncFunction} - A function, that when called, is the result of + * appling the `args` to the list of functions. It takes no args, other than + * a callback. */ export default applyEach(mapSeries); diff --git a/lib/asyncify.js b/lib/asyncify.js index dec39d239..13978b8d7 100644 --- a/lib/asyncify.js +++ b/lib/asyncify.js @@ -1,5 +1,6 @@ -import isObject from 'lodash/isObject'; -import initialParams from './internal/initialParams'; +import initialParams from './internal/initialParams.js' +import setImmediate from './internal/setImmediate.js' +import { isAsync } from './internal/wrapAsync.js' /** * Take a sync function and make it async, passing its return value to a @@ -12,7 +13,7 @@ import initialParams from './internal/initialParams'; * resolved/rejected state will be used to call the callback, rather than simply * the synchronous return value. * - * This also means you can asyncify ES2016 `async` functions. + * This also means you can asyncify ES2017 `async` functions. * * @name asyncify * @static @@ -20,10 +21,10 @@ import initialParams from './internal/initialParams'; * @method * @alias wrapSync * @category Util - * @param {Function} func - The synchronous function to convert to an - * asynchronous function. - * @returns {Function} An asynchronous wrapper of the `func`. To be invoked with - * (callback). + * @param {Function} func - The synchronous function, or Promise-returning + * function to convert to an {@link AsyncFunction}. + * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be + * invoked with `(args..., callback)`. * @example * * // passing a regular synchronous function @@ -48,7 +49,8 @@ import initialParams from './internal/initialParams'; * } * ], callback); * - * // es6 example + * // es2017 example, though `asyncify` is not needed if your JS environment + * // supports async functions out of the box * var q = async.queue(async.asyncify(async function(file) { * var intermediateStep = await processFile(file); * return await somePromise(intermediateStep) @@ -57,6 +59,14 @@ import initialParams from './internal/initialParams'; * q.push(files); */ export default function asyncify(func) { + if (isAsync(func)) { + return function (...args/*, callback*/) { + const callback = args.pop() + const promise = func.apply(this, args) + return handlePromise(promise, callback) + } + } + return initialParams(function (args, callback) { var result; try { @@ -65,14 +75,26 @@ export default function asyncify(func) { return callback(e); } // if result is Promise object - if (isObject(result) && typeof result.then === 'function') { - result.then(function(value) { - callback(null, value); - }, function(err) { - callback(err.message ? err : new Error(err)); - }); + if (result && typeof result.then === 'function') { + return handlePromise(result, callback) } else { callback(null, result); } }); } + +function handlePromise(promise, callback) { + return promise.then(value => { + invokeCallback(callback, null, value); + }, err => { + invokeCallback(callback, err && (err instanceof Error || err.message) ? err : new Error(err)); + }); +} + +function invokeCallback(callback, error, value) { + try { + callback(error, value); + } catch (err) { + setImmediate(e => { throw e }, err); + } +} diff --git a/lib/auto.js b/lib/auto.js index 85135a329..82251ebd9 100644 --- a/lib/auto.js +++ b/lib/auto.js @@ -1,26 +1,20 @@ -import arrayEach from 'lodash/_arrayEach'; -import forOwn from 'lodash/_baseForOwn'; -import indexOf from 'lodash/_baseIndexOf'; -import isArray from 'lodash/isArray'; -import okeys from 'lodash/keys'; -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; - -import once from './internal/once'; -import onlyOnce from './internal/onlyOnce'; +import once from './internal/once.js' +import onlyOnce from './internal/onlyOnce.js' +import wrapAsync from './internal/wrapAsync.js' +import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js' /** - * Determines the best order for running the functions in `tasks`, based on + * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on * their requirements. Each function can optionally depend on other functions * being completed first, and each function is run as soon as its requirements * are satisfied. * - * If any of the functions pass an error to their callback, the `auto` sequence + * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence * will stop. Further tasks will not execute (so any other functions depending * on it will not run), and the main `callback` is immediately called with the * error. * - * Functions also receive an object containing the results of functions which + * {@link AsyncFunction}s also receive an object containing the results of functions which * have completed so far as the first argument, if they have dependencies. If a * task function has no dependencies, it will only be passed a callback. * @@ -30,7 +24,7 @@ import onlyOnce from './internal/onlyOnce'; * @method * @category Control Flow * @param {Object} tasks - An object. Each of its properties is either a - * function or an array of requirements, with the function itself the last item + * function or an array of requirements, with the {@link AsyncFunction} itself the last item * in the array. The object's key of a property serves as the name of the task * defined by that property, i.e. can be used when specifying requirements for * other tasks. The function receives one or two arguments: @@ -47,18 +41,43 @@ import onlyOnce from './internal/onlyOnce'; * pass an error to their callback. Results are always returned; however, if an * error occurs, no further `tasks` will be performed, and the results object * will only contain partial results. Invoked with (err, results). - * @returns undefined + * @returns {Promise} a promise, if a callback is not passed * @example * + * //Using Callbacks * async.auto({ - * // this function will just be passed a callback - * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'), - * showData: ['readData', function(results, cb) { - * // results.readData is the file's contents - * // ... + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); * }] - * }, callback); + * }, function(err, results) { + * if (err) { + * console.log('err = ', err); + * } + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }); * + * //Using Promises * async.auto({ * get_data: function(callback) { * console.log('in get_data'); @@ -72,31 +91,71 @@ import onlyOnce from './internal/onlyOnce'; * callback(null, 'folder'); * }, * write_file: ['get_data', 'make_folder', function(results, callback) { - * console.log('in write_file', JSON.stringify(results)); * // once there is some data and the directory exists, * // write the data to a file in the directory * callback(null, 'filename'); * }], * email_link: ['write_file', function(results, callback) { - * console.log('in email_link', JSON.stringify(results)); * // once the file is written let's email a link to it... - * // results.write_file contains the filename returned by write_file. * callback(null, {'file':results.write_file, 'email':'user@example.com'}); * }] - * }, function(err, results) { - * console.log('err = ', err); + * }).then(results => { * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * }).catch(err => { + * console.log('err = ', err); * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.auto({ + * get_data: function(callback) { + * // async code to get some data + * callback(null, 'data', 'converted to array'); + * }, + * make_folder: function(callback) { + * // async code to create a directory to store a file in + * // this is run at the same time as getting the data + * callback(null, 'folder'); + * }, + * write_file: ['get_data', 'make_folder', function(results, callback) { + * // once there is some data and the directory exists, + * // write the data to a file in the directory + * callback(null, 'filename'); + * }], + * email_link: ['write_file', function(results, callback) { + * // once the file is written let's email a link to it... + * callback(null, {'file':results.write_file, 'email':'user@example.com'}); + * }] + * }); + * console.log('results = ', results); + * // results = { + * // get_data: ['data', 'converted to array'] + * // make_folder; 'folder', + * // write_file: 'filename' + * // email_link: { file: 'filename', email: 'user@example.com' } + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default function (tasks, concurrency, callback) { - if (typeof concurrency === 'function') { +export default function auto(tasks, concurrency, callback) { + if (typeof concurrency !== 'number') { // concurrency is optional, shift the args. callback = concurrency; concurrency = null; } - callback = once(callback || noop); - var keys = okeys(tasks); - var numTasks = keys.length; + callback = once(callback || promiseCallback()); + var numTasks = Object.keys(tasks).length; if (!numTasks) { return callback(null); } @@ -106,9 +165,10 @@ export default function (tasks, concurrency, callback) { var results = {}; var runningTasks = 0; + var canceled = false; var hasError = false; - var listeners = {}; + var listeners = Object.create(null); var readyTasks = []; @@ -117,8 +177,9 @@ export default function (tasks, concurrency, callback) { // without the possibility of returning to an ancestor task var uncheckedDependencies = {}; - forOwn(tasks, function (task, key) { - if (!isArray(task)) { + Object.keys(tasks).forEach(key => { + var task = tasks[key] + if (!Array.isArray(task)) { // no dependencies enqueueTask(key, [task]); readyToCheck.push(key); @@ -134,13 +195,14 @@ export default function (tasks, concurrency, callback) { } uncheckedDependencies[key] = remainingDependencies; - arrayEach(dependencies, function (dependencyName) { + dependencies.forEach(dependencyName => { if (!tasks[dependencyName]) { throw new Error('async.auto task `' + key + - '` has a non-existent dependency in ' + + '` has a non-existent dependency `' + + dependencyName + '` in ' + dependencies.join(', ')); } - addListener(dependencyName, function () { + addListener(dependencyName, () => { remainingDependencies--; if (remainingDependencies === 0) { enqueueTask(key, task); @@ -153,12 +215,11 @@ export default function (tasks, concurrency, callback) { processQueue(); function enqueueTask(key, task) { - readyTasks.push(function () { - runTask(key, task); - }); + readyTasks.push(() => runTask(key, task)); } function processQueue() { + if (canceled) return if (readyTasks.length === 0 && runningTasks === 0) { return callback(null, results); } @@ -180,9 +241,7 @@ export default function (tasks, concurrency, callback) { function taskComplete(taskName) { var taskListeners = listeners[taskName] || []; - arrayEach(taskListeners, function (fn) { - fn(); - }); + taskListeners.forEach(fn => fn()); processQueue(); } @@ -190,29 +249,33 @@ export default function (tasks, concurrency, callback) { function runTask(key, task) { if (hasError) return; - var taskCallback = onlyOnce(rest(function(err, args) { + var taskCallback = onlyOnce((err, ...result) => { runningTasks--; - if (args.length <= 1) { - args = args[0]; + if (err === false) { + canceled = true + return + } + if (result.length < 2) { + [result] = result; } if (err) { var safeResults = {}; - forOwn(results, function(val, rkey) { - safeResults[rkey] = val; + Object.keys(results).forEach(rkey => { + safeResults[rkey] = results[rkey]; }); - safeResults[key] = args; + safeResults[key] = result; hasError = true; - listeners = []; - + listeners = Object.create(null); + if (canceled) return callback(err, safeResults); } else { - results[key] = args; + results[key] = result; taskComplete(key); } - })); + }); runningTasks++; - var taskFn = task[task.length - 1]; + var taskFn = wrapAsync(task[task.length - 1]); if (task.length > 1) { taskFn(results, taskCallback); } else { @@ -229,7 +292,7 @@ export default function (tasks, concurrency, callback) { while (readyToCheck.length) { currentTask = readyToCheck.pop(); counter++; - arrayEach(getDependents(currentTask), function (dependent) { + getDependents(currentTask).forEach(dependent => { if (--uncheckedDependencies[dependent] === 0) { readyToCheck.push(dependent); } @@ -245,11 +308,14 @@ export default function (tasks, concurrency, callback) { function getDependents(taskName) { var result = []; - forOwn(tasks, function (task, key) { - if (isArray(task) && indexOf(task, taskName, 0) >= 0) { + Object.keys(tasks).forEach(key => { + const task = tasks[key] + if (Array.isArray(task) && task.indexOf(taskName) >= 0) { result.push(key); } }); return result; } + + return callback[PROMISE_SYMBOL] } diff --git a/lib/autoInject.js b/lib/autoInject.js index 3bb40e230..68eb3c99c 100644 --- a/lib/autoInject.js +++ b/lib/autoInject.js @@ -1,23 +1,51 @@ -import auto from './auto'; -import forOwn from 'lodash/_baseForOwn'; -import arrayMap from 'lodash/_arrayMap'; -import clone from 'lodash/_copyArray'; -import isArray from 'lodash/isArray'; -import trim from 'lodash/trim'; +import auto from './auto.js' +import wrapAsync from './internal/wrapAsync.js' +import { isAsync } from './internal/wrapAsync.js' -var FN_ARGS = /^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m; +var FN_ARGS = /^(?:async\s)?(?:function)?\s*(?:\w+\s*)?\(([^)]+)\)(?:\s*{)/; +var ARROW_FN_ARGS = /^(?:async\s)?\s*(?:\(\s*)?((?:[^)=\s]\s*)*)(?:\)\s*)?=>/; var FN_ARG_SPLIT = /,/; var FN_ARG = /(=.+)?(\s*)$/; -var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; + +function stripComments(string) { + let stripped = ''; + let index = 0; + let endBlockComment = string.indexOf('*/'); + while (index < string.length) { + if (string[index] === '/' && string[index+1] === '/') { + // inline comment + let endIndex = string.indexOf('\n', index); + index = (endIndex === -1) ? string.length : endIndex; + } else if ((endBlockComment !== -1) && (string[index] === '/') && (string[index+1] === '*')) { + // block comment + let endIndex = string.indexOf('*/', index); + if (endIndex !== -1) { + index = endIndex + 2; + endBlockComment = string.indexOf('*/', index); + } else { + stripped += string[index]; + index++; + } + } else { + stripped += string[index]; + index++; + } + } + return stripped; +} function parseParams(func) { - func = func.toString().replace(STRIP_COMMENTS, ''); - func = func.match(FN_ARGS)[2].replace(' ', ''); - func = func ? func.split(FN_ARG_SPLIT) : []; - func = func.map(function (arg){ - return trim(arg.replace(FN_ARG, '')); - }); - return func; + const src = stripComments(func.toString()); + let match = src.match(FN_ARGS); + if (!match) { + match = src.match(ARROW_FN_ARGS); + } + if (!match) throw new Error('could not parse args in autoInject\nSource:\n' + src) + let [, args] = match + return args + .replace(/\s/g, '') + .split(FN_ARG_SPLIT) + .map((arg) => arg.replace(FN_ARG, '').trim()); } /** @@ -39,7 +67,7 @@ function parseParams(func) { * @method * @see [async.auto]{@link module:ControlFlow.auto} * @category Control Flow - * @param {Object} tasks - An object, each of whose properties is a function of + * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of * the form 'func([dependencies...], callback). The object's key of a property * serves as the name of the task defined by that property, i.e. can be used * when specifying requirements for other tasks. @@ -52,6 +80,7 @@ function parseParams(func) { * the tasks have been completed. It receives the `err` argument if any `tasks` * pass an error to their callback, and a `results` object with any completed * task results, similar to `auto`. + * @returns {Promise} a promise, if no callback is passed * @example * * // The example from `auto` can be rewritten as follows: @@ -105,36 +134,40 @@ function parseParams(func) { export default function autoInject(tasks, callback) { var newTasks = {}; - forOwn(tasks, function (taskFn, key) { + Object.keys(tasks).forEach(key => { + var taskFn = tasks[key] var params; + var fnIsAsync = isAsync(taskFn); + var hasNoDeps = + (!fnIsAsync && taskFn.length === 1) || + (fnIsAsync && taskFn.length === 0); - if (isArray(taskFn)) { - params = clone(taskFn); + if (Array.isArray(taskFn)) { + params = [...taskFn]; taskFn = params.pop(); newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn); - } else if (taskFn.length === 1) { + } else if (hasNoDeps) { // no dependencies, use the function as-is newTasks[key] = taskFn; } else { params = parseParams(taskFn); - if (taskFn.length === 0 && params.length === 0) { + if ((taskFn.length === 0 && !fnIsAsync) && params.length === 0) { throw new Error("autoInject task functions require explicit parameters."); } - params.pop(); + // remove callback param + if (!fnIsAsync) params.pop(); newTasks[key] = params.concat(newTask); } function newTask(results, taskCb) { - var newArgs = arrayMap(params, function (name) { - return results[name]; - }); + var newArgs = params.map(name => results[name]) newArgs.push(taskCb); - taskFn.apply(null, newArgs); + wrapAsync(taskFn)(...newArgs); } }); - auto(newTasks, callback); + return auto(newTasks, callback); } diff --git a/lib/cargo.js b/lib/cargo.js index d86cb67b6..ef052027b 100644 --- a/lib/cargo.js +++ b/lib/cargo.js @@ -1,34 +1,4 @@ -import queue from './internal/queue'; - -/** - * A cargo of tasks for the worker function to complete. Cargo inherits all of - * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}. - * @typedef {Object} CargoObject - * @memberOf module:ControlFlow - * @property {Function} length - A function returning the number of items - * waiting to be processed. Invoke like `cargo.length()`. - * @property {number} payload - An `integer` for determining how many tasks - * should be process per round. This property can be changed after a `cargo` is - * created to alter the payload on-the-fly. - * @property {Function} push - Adds `task` to the `queue`. The callback is - * called once the `worker` has finished processing the task. Instead of a - * single task, an array of `tasks` can be submitted. The respective callback is - * used for every task in the list. Invoke like `cargo.push(task, [callback])`. - * @property {Function} saturated - A callback that is called when the - * `queue.length()` hits the concurrency and further tasks will be queued. - * @property {Function} empty - A callback that is called when the last item - * from the `queue` is given to a `worker`. - * @property {Function} drain - A callback that is called when the last item - * from the `queue` has returned from the `worker`. - * @property {Function} idle - a function returning false if there are items - * waiting or being processed, or true if not. Invoke like `cargo.idle()`. - * @property {Function} pause - a function that pauses the processing of tasks - * until `resume()` is called. Invoke like `cargo.pause()`. - * @property {Function} resume - a function that resumes the processing of - * queued tasks when the queue is paused. Invoke like `cargo.resume()`. - * @property {Function} kill - a function that removes the `drain` callback and - * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`. - */ +import queue from './internal/queue.js' /** * Creates a `cargo` object with the specified payload. Tasks added to the @@ -48,13 +18,12 @@ import queue from './internal/queue'; * @method * @see [async.queue]{@link module:ControlFlow.queue} * @category Control Flow - * @param {Function} worker - An asynchronous function for processing an array - * of queued tasks, which must call its `callback(err)` argument when finished, - * with an optional `err` argument. Invoked with `(tasks, callback)`. + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. * @param {number} [payload=Infinity] - An optional `integer` for determining * how many tasks should be processed per round; if omitted, the default is * unlimited. - * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can + * @returns {module:ControlFlow.QueueObject} A cargo object to manage the tasks. Callbacks can * attached as certain properties to listen for specific events during the * lifecycle of the cargo and inner queue. * @example @@ -74,9 +43,8 @@ import queue from './internal/queue'; * cargo.push({name: 'bar'}, function(err) { * console.log('finished processing bar'); * }); - * cargo.push({name: 'baz'}, function(err) { - * console.log('finished processing baz'); - * }); + * await cargo.push({name: 'baz'}); + * console.log('finished processing baz'); */ export default function cargo(worker, payload) { return queue(worker, 1, payload); diff --git a/lib/cargoQueue.js b/lib/cargoQueue.js new file mode 100644 index 000000000..f4bffb908 --- /dev/null +++ b/lib/cargoQueue.js @@ -0,0 +1,59 @@ +import queue from './internal/queue.js' + +/** + * Creates a `cargoQueue` object with the specified payload. Tasks added to the + * cargoQueue will be processed together (up to the `payload` limit) in `concurrency` parallel workers. + * If the all `workers` are in progress, the task is queued until one becomes available. Once + * a `worker` has completed some tasks, each callback of those tasks is + * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966) + * for how `cargo` and `queue` work. + * + * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers + * at a time, and [`cargo`]{@link module:ControlFlow.cargo} passes an array of tasks to a single worker, + * the cargoQueue passes an array of tasks to multiple parallel workers. + * + * @name cargoQueue + * @static + * @memberOf module:ControlFlow + * @method + * @see [async.queue]{@link module:ControlFlow.queue} + * @see [async.cargo]{@link module:ControlFLow.cargo} + * @category Control Flow + * @param {AsyncFunction} worker - An asynchronous function for processing an array + * of queued tasks. Invoked with `(tasks, callback)`. + * @param {number} [concurrency=1] - An `integer` for determining how many + * `worker` functions should be run in parallel. If omitted, the concurrency + * defaults to `1`. If the concurrency is `0`, an error is thrown. + * @param {number} [payload=Infinity] - An optional `integer` for determining + * how many tasks should be processed per round; if omitted, the default is + * unlimited. + * @returns {module:ControlFlow.QueueObject} A cargoQueue object to manage the tasks. Callbacks can + * attached as certain properties to listen for specific events during the + * lifecycle of the cargoQueue and inner queue. + * @example + * + * // create a cargoQueue object with payload 2 and concurrency 2 + * var cargoQueue = async.cargoQueue(function(tasks, callback) { + * for (var i=0; i { + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * }).catch(err => { + * console.log(err); * }); + * + * // Error Handling + * async.concat(withMissingDirectoryList, fs.readdir) + * .then(results => { + * console.log(results); + * }).catch(err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.concat(directoryList, fs.readdir); + * console.log(results); + * // [ 'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', file5.txt ] + * } catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.concat(withMissingDirectoryList, fs.readdir); + * console.log(results); + * } catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4 does not exist + * } + * } + * */ -export default doParallel(concat); +function concat(coll, iteratee, callback) { + return concatLimit(coll, Infinity, iteratee, callback) +} +export default awaitify(concat, 3); diff --git a/lib/concatLimit.js b/lib/concatLimit.js new file mode 100644 index 000000000..40cb6b088 --- /dev/null +++ b/lib/concatLimit.js @@ -0,0 +1,43 @@ +import wrapAsync from './internal/wrapAsync.js' +import mapLimit from './mapLimit.js' +import awaitify from './internal/awaitify.js' + +/** + * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time. + * + * @name concatLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.concat]{@link module:Collections.concat} + * @category Collection + * @alias flatMapLimit + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`, + * which should use an array as its result. Invoked with (item, callback). + * @param {Function} [callback] - A callback which is called after all the + * `iteratee` functions have finished, or an error occurs. Results is an array + * containing the concatenated results of the `iteratee` function. Invoked with + * (err, results). + * @returns A Promise, if no callback is passed + */ +function concatLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit(coll, limit, (val, iterCb) => { + _iteratee(val, (err, ...args) => { + if (err) return iterCb(err); + return iterCb(err, args); + }); + }, (err, mapResults) => { + var result = []; + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + result = result.concat(...mapResults[i]); + } + } + + return callback(err, result); + }); +} +export default awaitify(concatLimit, 4) diff --git a/lib/concatSeries.js b/lib/concatSeries.js index 77b439bc8..34311f0e6 100644 --- a/lib/concatSeries.js +++ b/lib/concatSeries.js @@ -1,5 +1,5 @@ -import concat from './internal/concat'; -import doSeries from './internal/doSeries'; +import concatLimit from './concatLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time. @@ -10,14 +10,18 @@ import doSeries from './internal/doSeries'; * @method * @see [async.concat]{@link module:Collections.concat} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, results)` which must be called once - * it has completed with an error (which can be `null`) and an array of results. + * @alias flatMapSeries + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`. + * The iteratee should complete with an array an array of results. * Invoked with (item, callback). - * @param {Function} [callback(err)] - A callback which is called after all the + * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished, or an error occurs. Results is an array * containing the concatenated results of the `iteratee` function. Invoked with * (err, results). + * @returns A Promise, if no callback is passed */ -export default doSeries(concat); +function concatSeries(coll, iteratee, callback) { + return concatLimit(coll, 1, iteratee, callback) +} +export default awaitify(concatSeries, 3); diff --git a/lib/constant.js b/lib/constant.js index 9aa2273f8..ed839e21a 100644 --- a/lib/constant.js +++ b/lib/constant.js @@ -1,6 +1,3 @@ -import rest from 'lodash/_baseRest'; -import initialParams from './internal/initialParams'; - /** * Returns a function that when called, calls-back with the values provided. * Useful as the first function in a [`waterfall`]{@link module:ControlFlow.waterfall}, or for plugging values in to @@ -13,7 +10,7 @@ import initialParams from './internal/initialParams'; * @category Util * @param {...*} arguments... - Any number of arguments to automatically invoke * callback with. - * @returns {Function} Returns a function that when invoked, automatically + * @returns {AsyncFunction} Returns a function that when invoked, automatically * invokes the callback with the previous given arguments. * @example * @@ -43,9 +40,9 @@ import initialParams from './internal/initialParams'; * //... * }, callback); */ -export default rest(function(values) { - var args = [null].concat(values); - return initialParams(function (ignoredArgs, callback) { - return callback.apply(this, args); - }); -}); +export default function(...args) { + return function (...ignoredArgs/*, callback*/) { + var callback = ignoredArgs.pop(); + return callback(null, ...args); + }; +} diff --git a/lib/detect.js b/lib/detect.js index 8119b058f..5c8fd6e49 100644 --- a/lib/detect.js +++ b/lib/detect.js @@ -1,8 +1,6 @@ -import identity from 'lodash/identity'; - -import createTester from './internal/createTester'; -import eachOf from './eachOf'; -import findGetResult from './internal/findGetResult'; +import createTester from './internal/createTester.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * Returns the first value in `coll` that passes an async truth test. The @@ -20,23 +18,62 @@ import findGetResult from './internal/findGetResult'; * @method * @alias find * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with * (err, result). + * @returns {Promise} a promise, if a callback is omitted * @example * - * async.detect(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // dir1/file1.txt + * // result now equals the first file in the list that exists + * } + *); + * + * // Using Promises + * async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists) + * .then(result => { + * console.log(result); + * // dir1/file1.txt * // result now equals the first file in the list that exists + * }).catch(err => { + * console.log(err); * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.detect(['file3.txt','file2.txt','dir1/file1.txt'], fileExists); + * console.log(result); + * // dir1/file1.txt + * // result now equals the file in the list that exists + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default createTester(eachOf, identity, findGetResult); +function detect(coll, iteratee, callback) { + return createTester(bool => bool, (res, item) => item)(eachOf, coll, iteratee, callback) +} +export default awaitify(detect, 3) diff --git a/lib/detectLimit.js b/lib/detectLimit.js index cefff5551..0765fe810 100644 --- a/lib/detectLimit.js +++ b/lib/detectLimit.js @@ -1,8 +1,6 @@ -import identity from 'lodash/identity'; - -import createTester from './internal/createTester'; -import eachOfLimit from './eachOfLimit'; -import findGetResult from './internal/findGetResult'; +import createTester from './internal/createTester.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a @@ -15,15 +13,19 @@ import findGetResult from './internal/findGetResult'; * @see [async.detect]{@link module:Collections.detect} * @alias findLimit * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with * (err, result). + * @returns {Promise} a promise, if a callback is omitted */ -export default createTester(eachOfLimit, identity, findGetResult); +function detectLimit(coll, limit, iteratee, callback) { + return createTester(bool => bool, (res, item) => item)(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(detectLimit, 4) diff --git a/lib/detectSeries.js b/lib/detectSeries.js index 3086a6203..4cc9d2b06 100644 --- a/lib/detectSeries.js +++ b/lib/detectSeries.js @@ -1,8 +1,6 @@ -import identity from 'lodash/identity'; - -import createTester from './internal/createTester'; -import eachOfSeries from './eachOfSeries'; -import findGetResult from './internal/findGetResult'; +import createTester from './internal/createTester.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time. @@ -14,14 +12,19 @@ import findGetResult from './internal/findGetResult'; * @see [async.detect]{@link module:Collections.detect} * @alias findSeries * @category Collections - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The iteratee is passed a `callback(err, truthValue)` which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`. + * The iteratee must complete with a boolean value as its result. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the `iteratee` functions have finished. * Result will be the first item in the array that passes the truth test * (iteratee) or the value `undefined` if none passed. Invoked with * (err, result). + * @returns {Promise} a promise, if a callback is omitted */ -export default createTester(eachOfSeries, identity, findGetResult); +function detectSeries(coll, iteratee, callback) { + return createTester(bool => bool, (res, item) => item)(eachOfLimit(1), coll, iteratee, callback) +} + +export default awaitify(detectSeries, 3) diff --git a/lib/dir.js b/lib/dir.js index 912b558ae..77e03c66b 100644 --- a/lib/dir.js +++ b/lib/dir.js @@ -1,10 +1,11 @@ -import consoleFunc from './internal/consoleFunc'; +import consoleFunc from './internal/consoleFunc.js' /** - * Logs the result of an `async` function to the `console` using `console.dir` - * to display the properties of the resulting object. Only works in Node.js or - * in browsers that support `console.dir` and `console.error` (such as FF and - * Chrome). If multiple arguments are returned from the async function, + * Logs the result of an [`async` function]{@link AsyncFunction} to the + * `console` using `console.dir` to display the properties of the resulting object. + * Only works in Node.js or in browsers that support `console.dir` and + * `console.error` (such as FF and Chrome). + * If multiple arguments are returned from the async function, * `console.dir` is called on each argument in order. * * @name dir @@ -12,8 +13,8 @@ import consoleFunc from './internal/consoleFunc'; * @memberOf module:Utils * @method * @category Util - * @param {Function} function - The function you want to eventually apply all - * arguments to. + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. * @param {...*} arguments... - Any number of arguments to apply to the function. * @example * diff --git a/lib/doDuring.js b/lib/doDuring.js deleted file mode 100644 index 306f8a7dc..000000000 --- a/lib/doDuring.js +++ /dev/null @@ -1,44 +0,0 @@ -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; -import onlyOnce from './internal/onlyOnce'; - -/** - * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in - * the order of operations, the arguments `test` and `fn` are switched. - * - * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function. - * @name doDuring - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.during]{@link module:ControlFlow.during} - * @category Control Flow - * @param {Function} fn - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - asynchronous truth test to perform before each - * execution of `fn`. Invoked with (...args, callback), where `...args` are the - * non-error args from the previous callback of `fn`. - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error if one occured, otherwise `null`. - */ -export default function doDuring(fn, test, callback) { - callback = onlyOnce(callback || noop); - - var next = rest(function(err, args) { - if (err) return callback(err); - args.push(check); - test.apply(this, args); - }); - - function check(err, truth) { - if (err) return callback(err); - if (!truth) return callback(null); - fn(next); - } - - check(null, true); - -} - diff --git a/lib/doUntil.js b/lib/doUntil.js index 0c5bb7194..f888cadff 100644 --- a/lib/doUntil.js +++ b/lib/doUntil.js @@ -1,4 +1,5 @@ -import doWhilst from './doWhilst'; +import doWhilst from './doWhilst.js' +import wrapAsync from './internal/wrapAsync.js' /** * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the @@ -10,18 +11,21 @@ import doWhilst from './doWhilst'; * @method * @see [async.doWhilst]{@link module:ControlFlow.doWhilst} * @category Control Flow - * @param {Function} fn - A function which is called each time `test` fails. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - synchronous truth test to perform after each - * execution of `fn`. Invoked with the non-error callback results of `fn`. + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee` * @param {Function} [callback] - A callback which is called after the test - * function has passed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed */ -export default function doUntil(fn, test, callback) { - doWhilst(fn, function() { - return !test.apply(this, arguments); +export default function doUntil(iteratee, test, callback) { + const _test = wrapAsync(test) + return doWhilst(iteratee, (...args) => { + const cb = args.pop() + _test(...args, (err, truth) => cb (err, !truth)) }, callback); } diff --git a/lib/doWhilst.js b/lib/doWhilst.js index 584db0968..17f7d9866 100644 --- a/lib/doWhilst.js +++ b/lib/doWhilst.js @@ -1,7 +1,6 @@ -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; - -import onlyOnce from './internal/onlyOnce'; +import onlyOnce from './internal/onlyOnce.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in @@ -15,23 +14,38 @@ import onlyOnce from './internal/onlyOnce'; * @method * @see [async.whilst]{@link module:ControlFlow.whilst} * @category Control Flow - * @param {Function} iteratee - A function which is called each time `test` - * passes. The function is passed a `callback(err)`, which must be called once - * it has completed with an optional `err` argument. Invoked with (callback). - * @param {Function} test - synchronous truth test to perform after each - * execution of `iteratee`. Invoked with the non-error callback results of - * `iteratee`. + * @param {AsyncFunction} iteratee - A function which is called each time `test` + * passes. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform after each + * execution of `iteratee`. Invoked with (...args, callback), where `...args` are the + * non-error args from the previous callback of `iteratee`. * @param {Function} [callback] - A callback which is called after the test * function has failed and repeated execution of `iteratee` has stopped. * `callback` will be passed an error and any arguments passed to the final * `iteratee`'s callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if no callback is passed */ -export default function doWhilst(iteratee, test, callback) { - callback = onlyOnce(callback || noop); - var next = rest(function(err, args) { +function doWhilst(iteratee, test, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results + + function next(err, ...args) { + if (err) return callback(err); + if (err === false) return; + results = args + _test(...args, check); + } + + function check(err, truth) { if (err) return callback(err); - if (test.apply(this, args)) return iteratee(next); - callback.apply(null, [null].concat(args)); - }); - iteratee(next); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return check(null, true); } + +export default awaitify(doWhilst, 3) diff --git a/lib/during.js b/lib/during.js deleted file mode 100644 index 549ad445c..000000000 --- a/lib/during.js +++ /dev/null @@ -1,56 +0,0 @@ -import noop from 'lodash/noop'; -import onlyOnce from './internal/onlyOnce'; - -/** - * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that - * is passed a callback in the form of `function (err, truth)`. If error is - * passed to `test` or `fn`, the main callback is immediately called with the - * value of the error. - * - * @name during - * @static - * @memberOf module:ControlFlow - * @method - * @see [async.whilst]{@link module:ControlFlow.whilst} - * @category Control Flow - * @param {Function} test - asynchronous truth test to perform before each - * execution of `fn`. Invoked with (callback). - * @param {Function} fn - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). - * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error, if one occured, otherwise `null`. - * @example - * - * var count = 0; - * - * async.during( - * function (callback) { - * return callback(null, count < 5); - * }, - * function (callback) { - * count++; - * setTimeout(callback, 1000); - * }, - * function (err) { - * // 5 seconds have passed - * } - * ); - */ -export default function during(test, fn, callback) { - callback = onlyOnce(callback || noop); - - function next(err) { - if (err) return callback(err); - test(check); - } - - function check(err, truth) { - if (err) return callback(err); - if (!truth) return callback(null); - fn(next); - } - - test(check); -} diff --git a/lib/each.js b/lib/each.js index 5bf6bd4d6..476faed25 100644 --- a/lib/each.js +++ b/lib/each.js @@ -1,5 +1,7 @@ -import eachOf from './eachOf'; -import withoutIndex from './internal/withoutIndex'; +import eachOf from './eachOf.js' +import withoutIndex from './internal/withoutIndex.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Applies the function `iteratee` to each item in `coll`, in parallel. @@ -17,49 +19,91 @@ import withoutIndex from './internal/withoutIndex'; * @method * @alias forEach * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item - * in `coll`. The iteratee is passed a `callback(err)` which must be called once - * it has completed. If no error has occurred, the `callback` should be run - * without arguments or with an explicit `null` argument. The array index is not - * passed to the iteratee. Invoked with (item, callback). If you need the index, - * use `eachOf`. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to + * each item in `coll`. Invoked with (item, callback). + * The array index is not passed to the iteratee. + * If you need the index, use `eachOf`. * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted * @example * - * // assuming openFiles is an array of file names and saveFile is a function - * // to save the modified contents of that file: + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist * - * async.each(openFiles, saveFile, function(err){ - * // if any of the saves produced an error, err would equal that error - * }); - * - * // assuming openFiles is an array of file names - * async.each(openFiles, function(file, callback) { + * const fileList = [ 'dir1/file2.txt', 'dir2/file3.txt', 'dir/file5.txt']; + * const withMissingFileList = ['dir1/file1.txt', 'dir4/file2.txt']; * - * // Perform operation on file here. - * console.log('Processing file ' + file); + * // asynchronous function that deletes a file + * const deleteFile = function(file, callback) { + * fs.unlink(file, callback); + * }; * - * if( file.length > 32 ) { - * console.log('This file name is too long'); - * callback('File name too long'); - * } else { - * // Do work to process file here - * console.log('File processed'); - * callback(); - * } - * }, function(err) { - * // if any of the file processing produced an error, err would equal that error + * // Using callbacks + * async.each(fileList, deleteFile, function(err) { * if( err ) { - * // One of the iterations produced an error. - * // All processing will now stop. - * console.log('A file failed to process'); + * console.log(err); * } else { - * console.log('All files have been processed successfully'); + * console.log('All files have been deleted successfully'); * } * }); + * + * // Error Handling + * async.each(withMissingFileList, deleteFile, function(err){ + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using Promises + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.each(fileList, deleteFile) + * .then( () => { + * console.log('All files have been deleted successfully'); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * }); + * + * // Using async/await + * async () => { + * try { + * await async.each(files, deleteFile); + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * await async.each(withMissingFileList, deleteFile); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * // since dir4/file2.txt does not exist + * // dir1/file1.txt could have been deleted + * } + * } + * */ -export default function eachLimit(coll, iteratee, callback) { - eachOf(coll, withoutIndex(iteratee), callback); +function eachLimit(coll, iteratee, callback) { + return eachOf(coll, withoutIndex(wrapAsync(iteratee)), callback); } + +export default awaitify(eachLimit, 3) diff --git a/lib/eachLimit.js b/lib/eachLimit.js index c6bce8c2a..d72796ef1 100644 --- a/lib/eachLimit.js +++ b/lib/eachLimit.js @@ -1,5 +1,7 @@ -import eachOfLimit from './internal/eachOfLimit'; -import withoutIndex from './internal/withoutIndex'; +import eachOfLimit from './internal/eachOfLimit.js' +import withoutIndex from './internal/withoutIndex.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time. @@ -11,17 +13,18 @@ import withoutIndex from './internal/withoutIndex'; * @see [async.each]{@link module:Collections.each} * @alias forEachLimit * @category Collection - * @param {Array|Iterable|Object} coll - A colleciton to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each item in `coll`. The - * iteratee is passed a `callback(err)` which must be called once it has - * completed. If no error has occurred, the `callback` should be run without - * arguments or with an explicit `null` argument. The array index is not passed - * to the iteratee. Invoked with (item, callback). If you need the index, use - * `eachOfLimit`. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfLimit`. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted */ -export default function eachLimit(coll, limit, iteratee, callback) { - eachOfLimit(limit)(coll, withoutIndex(iteratee), callback); +function eachLimit(coll, limit, iteratee, callback) { + return eachOfLimit(limit)(coll, withoutIndex(wrapAsync(iteratee)), callback); } +export default awaitify(eachLimit, 4) diff --git a/lib/eachOf.js b/lib/eachOf.js index 73d1026e8..7c16ffffa 100644 --- a/lib/eachOf.js +++ b/lib/eachOf.js @@ -1,25 +1,30 @@ -import isArrayLike from 'lodash/isArrayLike'; - -import eachOfLimit from './eachOfLimit'; -import doLimit from './internal/doLimit'; -import noop from 'lodash/noop'; -import once from './internal/once'; -import onlyOnce from './internal/onlyOnce'; +import isArrayLike from './internal/isArrayLike.js' +import breakLoop from './internal/breakLoop.js' +import eachOfLimit from './eachOfLimit.js' +import once from './internal/once.js' +import onlyOnce from './internal/onlyOnce.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' // eachOf implementation optimized for array-likes function eachOfArrayLike(coll, iteratee, callback) { - callback = once(callback || noop); + callback = once(callback); var index = 0, completed = 0, - length = coll.length; + {length} = coll, + canceled = false; if (length === 0) { callback(null); } - function iteratorCallback(err) { + function iteratorCallback(err, value) { + if (err === false) { + canceled = true + } + if (canceled === true) return if (err) { callback(err); - } else if (++completed === length) { + } else if ((++completed === length) || value === breakLoop) { callback(null); } } @@ -30,7 +35,9 @@ function eachOfArrayLike(coll, iteratee, callback) { } // a generic version of eachOf which can handle array, object, and iterator cases. -var eachOfGeneric = doLimit(eachOfLimit, Infinity); +function eachOfGeneric (coll, iteratee, callback) { + return eachOfLimit(coll, Infinity, iteratee, callback); +} /** * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument @@ -43,23 +50,29 @@ var eachOfGeneric = doLimit(eachOfLimit, Infinity); * @alias forEachOf * @category Collection * @see [async.each]{@link module:Collections.each} - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each - * item in `coll`. The `key` is the item's key, or index in the case of an - * array. The iteratee is passed a `callback(err)` which must be called once it - * has completed. If no error has occurred, the callback should be run without - * arguments or with an explicit `null` argument. Invoked with - * (item, key, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - A function to apply to each + * item in `coll`. + * The `key` is the item's key, or index in the case of an array. + * Invoked with (item, key, callback). * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted * @example * - * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"}; - * var configs = {}; + * // dev.json is a file containing a valid json object config for dev environment + * // dev.json is a file containing a valid json object config for test environment + * // prod.json is a file containing a valid json object config for prod environment + * // invalid.json is a file with a malformed json object + * + * let configs = {}; //global variable + * let validConfigFileMap = {dev: 'dev.json', test: 'test.json', prod: 'prod.json'}; + * let invalidConfigFileMap = {dev: 'dev.json', test: 'test.json', invalid: 'invalid.json'}; * - * async.forEachOf(obj, function (value, key, callback) { - * fs.readFile(__dirname + value, "utf8", function (err, data) { - * if (err) return callback(err); + * // asynchronous function that reads a json file and parses the contents as json object + * function parseFile(file, key, callback) { + * fs.readFile(file, "utf8", function(err, data) { + * if (err) return calback(err); * try { * configs[key] = JSON.parse(data); * } catch (e) { @@ -67,13 +80,77 @@ var eachOfGeneric = doLimit(eachOfLimit, Infinity); * } * callback(); * }); - * }, function (err) { - * if (err) console.error(err.message); - * // configs is now a map of JSON data - * doSomethingWith(configs); + * } + * + * // Using callbacks + * async.forEachOf(validConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * } else { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile, function (err) { + * if (err) { + * console.error(err); + * // JSON parse error exception + * } else { + * console.log(configs); + * } * }); + * + * // Using Promises + * async.forEachOf(validConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * }).catch( err => { + * console.error(err); + * }); + * + * //Error handing + * async.forEachOf(invalidConfigFileMap, parseFile) + * .then( () => { + * console.log(configs); + * }).catch( err => { + * console.error(err); + * // JSON parse error exception + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.forEachOf(validConfigFileMap, parseFile); + * console.log(configs); + * // configs is now a map of JSON data, e.g. + * // { dev: //parsed dev.json, test: //parsed test.json, prod: //parsed prod.json} + * } + * catch (err) { + * console.log(err); + * } + * } + * + * //Error handing + * async () => { + * try { + * let result = await async.forEachOf(invalidConfigFileMap, parseFile); + * console.log(configs); + * } + * catch (err) { + * console.log(err); + * // JSON parse error exception + * } + * } + * */ -export default function(coll, iteratee, callback) { +function eachOf(coll, iteratee, callback) { var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric; - eachOfImplementation(coll, iteratee, callback); + return eachOfImplementation(coll, wrapAsync(iteratee), callback); } + +export default awaitify(eachOf, 3) diff --git a/lib/eachOfLimit.js b/lib/eachOfLimit.js index c3b4567fd..8932de95e 100644 --- a/lib/eachOfLimit.js +++ b/lib/eachOfLimit.js @@ -1,4 +1,6 @@ -import _eachOfLimit from './internal/eachOfLimit'; +import _eachOfLimit from './internal/eachOfLimit.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a @@ -11,17 +13,18 @@ import _eachOfLimit from './internal/eachOfLimit'; * @see [async.eachOf]{@link module:Collections.eachOf} * @alias forEachOfLimit * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each + * @param {AsyncFunction} iteratee - An async function to apply to each * item in `coll`. The `key` is the item's key, or index in the case of an - * array. The iteratee is passed a `callback(err)` which must be called once it - * has completed. If no error has occurred, the callback should be run without - * arguments or with an explicit `null` argument. Invoked with - * (item, key, callback). + * array. + * Invoked with (item, key, callback). * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted */ -export default function eachOfLimit(coll, limit, iteratee, callback) { - _eachOfLimit(limit)(coll, iteratee, callback); +function eachOfLimit(coll, limit, iteratee, callback) { + return _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback); } + +export default awaitify(eachOfLimit, 4) diff --git a/lib/eachOfSeries.js b/lib/eachOfSeries.js index 21e816d37..5dc04a851 100644 --- a/lib/eachOfSeries.js +++ b/lib/eachOfSeries.js @@ -1,5 +1,5 @@ -import eachOfLimit from './eachOfLimit'; -import doLimit from './internal/doLimit'; +import eachOfLimit from './eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time. @@ -11,13 +11,15 @@ import doLimit from './internal/doLimit'; * @see [async.eachOf]{@link module:Collections.eachOf} * @alias forEachOfSeries * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. The - * `key` is the item's key, or index in the case of an array. The iteratee is - * passed a `callback(err)` which must be called once it has completed. If no - * error has occurred, the callback should be run without arguments or with an - * explicit `null` argument. Invoked with (item, key, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * Invoked with (item, key, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` * functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted */ -export default doLimit(eachOfLimit, 1); +function eachOfSeries(coll, iteratee, callback) { + return eachOfLimit(coll, 1, iteratee, callback) +} +export default awaitify(eachOfSeries, 3); diff --git a/lib/eachSeries.js b/lib/eachSeries.js index 0839d8ca1..6c163f14c 100644 --- a/lib/eachSeries.js +++ b/lib/eachSeries.js @@ -1,9 +1,12 @@ -import eachLimit from './eachLimit'; -import doLimit from './internal/doLimit'; +import eachLimit from './eachLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time. * + * Note, that unlike [`each`]{@link module:Collections.each}, this function applies iteratee to each item + * in series and therefore the iteratee functions will complete in order. + * @name eachSeries * @static * @memberOf module:Collections @@ -11,14 +14,17 @@ import doLimit from './internal/doLimit'; * @see [async.each]{@link module:Collections.each} * @alias forEachSeries * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each - * item in `coll`. The iteratee is passed a `callback(err)` which must be called - * once it has completed. If no error has occurred, the `callback` should be run - * without arguments or with an explicit `null` argument. The array index is - * not passed to the iteratee. Invoked with (item, callback). If you need the - * index, use `eachOfSeries`. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each + * item in `coll`. + * The array index is not passed to the iteratee. + * If you need the index, use `eachOfSeries`. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called when all * `iteratee` functions have finished, or an error occurs. Invoked with (err). + * @returns {Promise} a promise, if a callback is omitted */ -export default doLimit(eachLimit, 1); +function eachSeries(coll, iteratee, callback) { + return eachLimit(coll, 1, iteratee, callback) +} +export default awaitify(eachSeries, 3); diff --git a/lib/ensureAsync.js b/lib/ensureAsync.js index c60d07e54..1b4a69598 100644 --- a/lib/ensureAsync.js +++ b/lib/ensureAsync.js @@ -1,5 +1,5 @@ -import setImmediate from './internal/setImmediate'; -import initialParams from './internal/initialParams'; +import setImmediate from './internal/setImmediate.js' +import { isAsync } from './internal/wrapAsync.js' /** * Wrap an async function and ensure it calls its callback on a later tick of @@ -7,16 +7,17 @@ import initialParams from './internal/initialParams'; * no extra deferral is added. This is useful for preventing stack overflows * (`RangeError: Maximum call stack size exceeded`) and generally keeping * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony) - * contained. + * contained. ES2017 `async` functions are returned as-is -- they are immune + * to Zalgo's corrupting influences, as they always resolve on a later tick. * * @name ensureAsync * @static * @memberOf module:Utils * @method * @category Util - * @param {Function} fn - an async function, one that expects a node-style + * @param {AsyncFunction} fn - an async function, one that expects a node-style * callback as its last argument. - * @returns {Function} Returns a wrapped function with the exact same call + * @returns {AsyncFunction} Returns a wrapped function with the exact same call * signature as the function passed in. * @example * @@ -36,19 +37,18 @@ import initialParams from './internal/initialParams'; * async.mapSeries(args, async.ensureAsync(sometimesAsync), done); */ export default function ensureAsync(fn) { - return initialParams(function (args, callback) { + if (isAsync(fn)) return fn; + return function (...args/*, callback*/) { + var callback = args.pop() var sync = true; - args.push(function () { - var innerArgs = arguments; + args.push((...innerArgs) => { if (sync) { - setImmediate(function () { - callback.apply(null, innerArgs); - }); + setImmediate(() => callback(...innerArgs)); } else { - callback.apply(null, innerArgs); + callback(...innerArgs); } }); fn.apply(this, args); sync = false; - }); + }; } diff --git a/lib/every.js b/lib/every.js index 83307184a..b035401a5 100644 --- a/lib/every.js +++ b/lib/every.js @@ -1,6 +1,6 @@ -import createTester from './internal/createTester'; -import eachOf from './eachOf'; -import notId from './internal/notId'; +import createTester from './internal/createTester.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * Returns `true` if every element in `coll` satisfies an async test. If any @@ -12,22 +12,91 @@ import notId from './internal/notId'; * @method * @alias all * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result will be either `true` or `false` * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided * @example * - * async.every(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { - * // if result is true then every file exists + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file5.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.every(fileList, fileExists, function(err, result) { + * console.log(result); + * // true + * // result is true since every file exists + * }); + * + * async.every(withMissingFileList, fileExists, function(err, result) { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }); + * + * // Using Promises + * async.every(fileList, fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since every file exists + * }).catch( err => { + * console.log(err); + * }); + * + * async.every(withMissingFileList, fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since NOT every file exists + * }).catch( err => { + * console.log(err); * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.every(fileList, fileExists); + * console.log(result); + * // true + * // result is true since every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.every(withMissingFileList, fileExists); + * console.log(result); + * // false + * // result is false since NOT every file exists + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default createTester(eachOf, notId, notId); +function every(coll, iteratee, callback) { + return createTester(bool => !bool, res => !res)(eachOf, coll, iteratee, callback) +} +export default awaitify(every, 3); diff --git a/lib/everyLimit.js b/lib/everyLimit.js index 9bcebb14b..6bb350aac 100644 --- a/lib/everyLimit.js +++ b/lib/everyLimit.js @@ -1,6 +1,6 @@ -import createTester from './internal/createTester'; -import eachOfLimit from './eachOfLimit'; -import notId from './internal/notId'; +import createTester from './internal/createTester.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time. @@ -12,14 +12,18 @@ import notId from './internal/notId'; * @see [async.every]{@link module:Collections.every} * @alias allLimit * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in parallel. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result will be either `true` or `false` * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided */ -export default createTester(eachOfLimit, notId, notId); +function everyLimit(coll, limit, iteratee, callback) { + return createTester(bool => !bool, res => !res)(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(everyLimit, 4); diff --git a/lib/everySeries.js b/lib/everySeries.js index 743474805..a9d0a4fdd 100644 --- a/lib/everySeries.js +++ b/lib/everySeries.js @@ -1,5 +1,6 @@ -import everyLimit from './everyLimit'; -import doLimit from './internal/doLimit'; +import createTester from './internal/createTester.js' +import eachOfSeries from './eachOfSeries.js' +import awaitify from './internal/awaitify.js' /** * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time. @@ -11,13 +12,17 @@ import doLimit from './internal/doLimit'; * @see [async.every]{@link module:Collections.every} * @alias allSeries * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the - * collection in parallel. The iteratee is passed a `callback(err, truthValue)` - * which must be called with a boolean argument once it has completed. Invoked - * with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collection in series. + * The iteratee must complete with a boolean result value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result will be either `true` or `false` * depending on the values of the async tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided */ -export default doLimit(everyLimit, 1); +function everySeries(coll, iteratee, callback) { + return createTester(bool => !bool, res => !res)(eachOfSeries, coll, iteratee, callback) +} +export default awaitify(everySeries, 3); diff --git a/lib/filter.js b/lib/filter.js index 4f0cbf183..5de1ab62c 100644 --- a/lib/filter.js +++ b/lib/filter.js @@ -1,5 +1,6 @@ -import filter from './internal/filter'; -import doParallel from './internal/doParallel'; +import _filter from './internal/filter.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * Returns a new array of all the values in `coll` which pass an async truth @@ -12,20 +13,64 @@ import doParallel from './internal/doParallel'; * @method * @alias select * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {Function} iteratee - A truth test to apply to each item in `coll`. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called * with a boolean argument once it has completed. Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided * @example * - * async.filter(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, results) { - * // results now equals an array of the existing files + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const files = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.filter(files, fileExists, function(err, results) { + * if(err) { + * console.log(err); + * } else { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } * }); + * + * // Using Promises + * async.filter(files, fileExists) + * .then(results => { + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.filter(files, fileExists); + * console.log(results); + * // [ 'dir1/file1.txt', 'dir2/file3.txt' ] + * // results is now an array of the existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default doParallel(filter); +function filter (coll, iteratee, callback) { + return _filter(eachOf, coll, iteratee, callback) +} +export default awaitify(filter, 3); diff --git a/lib/filterLimit.js b/lib/filterLimit.js index 2c053640d..9edd84b31 100644 --- a/lib/filterLimit.js +++ b/lib/filterLimit.js @@ -1,5 +1,6 @@ -import filter from './internal/filter'; -import doParallelLimit from './internal/doParallelLimit'; +import _filter from './internal/filter.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a @@ -12,12 +13,16 @@ import doParallelLimit from './internal/doParallelLimit'; * @see [async.filter]{@link module:Collections.filter} * @alias selectLimit * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. * @param {Function} iteratee - A truth test to apply to each item in `coll`. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called * with a boolean argument once it has completed. Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback provided */ -export default doParallelLimit(filter); +function filterLimit (coll, limit, iteratee, callback) { + return _filter(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(filterLimit, 4); diff --git a/lib/filterSeries.js b/lib/filterSeries.js index c973c148e..654951711 100644 --- a/lib/filterSeries.js +++ b/lib/filterSeries.js @@ -1,5 +1,6 @@ -import filterLimit from './filterLimit'; -import doLimit from './internal/doLimit'; +import _filter from './internal/filter.js' +import eachOfSeries from './eachOfSeries.js' +import awaitify from './internal/awaitify.js' /** * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time. @@ -11,11 +12,15 @@ import doLimit from './internal/doLimit'; * @see [async.filter]{@link module:Collections.filter} * @alias selectSeries * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {Function} iteratee - A truth test to apply to each item in `coll`. * The `iteratee` is passed a `callback(err, truthValue)`, which must be called * with a boolean argument once it has completed. Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results) + * @returns {Promise} a promise, if no callback provided */ -export default doLimit(filterLimit, 1); +function filterSeries (coll, iteratee, callback) { + return _filter(eachOfSeries, coll, iteratee, callback) +} +export default awaitify(filterSeries, 3); diff --git a/lib/forever.js b/lib/forever.js index 01473953c..2f3967c92 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -1,24 +1,26 @@ -import noop from 'lodash/noop'; - -import onlyOnce from './internal/onlyOnce'; -import ensureAsync from './ensureAsync'; +import onlyOnce from './internal/onlyOnce.js' +import ensureAsync from './ensureAsync.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Calls the asynchronous function `fn` with a callback parameter that allows it * to call itself again, in series, indefinitely. - * If an error is passed to the - * callback then `errback` is called with the error, and execution stops, - * otherwise it will never be called. + * If an error is passed to the callback then `errback` is called with the + * error, and execution stops, otherwise it will never be called. * * @name forever * @static * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Function} fn - a function to call repeatedly. Invoked with (next). + * @param {AsyncFunction} fn - an async function to call repeatedly. + * Invoked with (next). * @param {Function} [errback] - when `fn` passes an error to it's callback, * this function will be called, and execution stops. Invoked with (err). + * @returns {Promise} a promise that rejects if an error occurs and an errback + * is not passed * @example * * async.forever( @@ -32,13 +34,15 @@ import ensureAsync from './ensureAsync'; * } * ); */ -export default function forever(fn, errback) { - var done = onlyOnce(errback || noop); - var task = ensureAsync(fn); +function forever(fn, errback) { + var done = onlyOnce(errback); + var task = wrapAsync(ensureAsync(fn)); function next(err) { if (err) return done(err); + if (err === false) return; task(next); } - next(); + return next(); } +export default awaitify(forever, 2) diff --git a/lib/groupBy.js b/lib/groupBy.js new file mode 100644 index 000000000..1a9547656 --- /dev/null +++ b/lib/groupBy.js @@ -0,0 +1,96 @@ +import groupByLimit from './groupByLimit.js' + +/** + * Returns a new object, where each value corresponds to an array of items, from + * `coll`, that returned the corresponding key. That is, the keys of the object + * correspond to the values passed to the `iteratee` callback. + * + * Note: Since this function applies the `iteratee` to each item in parallel, + * there is no guarantee that the `iteratee` functions will complete in order. + * However, the values for each key in the `result` will be in the same order as + * the original `coll`. For Objects, the values will roughly be in the order of + * the original Objects' keys (but this can vary across JavaScript engines). + * + * @name groupBy + * @static + * @memberOf module:Collections + * @method + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + * @example + * + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * const files = ['dir1/file1.txt','dir2','dir4'] + * + * // asynchronous function that detects file type as none, file, or directory + * function detectFile(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(null, 'none'); + * } + * callback(null, stat.isDirectory() ? 'directory' : 'file'); + * }); + * } + * + * //Using callbacks + * async.groupBy(files, detectFile, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * }); + * + * // Using Promises + * async.groupBy(files, detectFile) + * .then( result => { + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.groupBy(files, detectFile); + * console.log(result); + * // { + * // file: [ 'dir1/file1.txt' ], + * // none: [ 'dir4' ], + * // directory: [ 'dir2'] + * // } + * // result is object containing the files grouped by type + * } + * catch (err) { + * console.log(err); + * } + * } + * + */ +export default function groupBy (coll, iteratee, callback) { + return groupByLimit(coll, Infinity, iteratee, callback) +} diff --git a/lib/groupByLimit.js b/lib/groupByLimit.js new file mode 100644 index 000000000..a5d20ccd4 --- /dev/null +++ b/lib/groupByLimit.js @@ -0,0 +1,54 @@ +import mapLimit from './mapLimit.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time. + * + * @name groupByLimit + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {number} limit - The maximum number of async operations at a time. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whoses + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ +function groupByLimit(coll, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit(coll, limit, (val, iterCb) => { + _iteratee(val, (err, key) => { + if (err) return iterCb(err); + return iterCb(err, {key, val}); + }); + }, (err, mapResults) => { + var result = {}; + // from MDN, handle object having an `hasOwnProperty` prop + var {hasOwnProperty} = Object.prototype; + + for (var i = 0; i < mapResults.length; i++) { + if (mapResults[i]) { + var {key} = mapResults[i]; + var {val} = mapResults[i]; + + if (hasOwnProperty.call(result, key)) { + result[key].push(val); + } else { + result[key] = [val]; + } + } + } + + return callback(err, result); + }); +} + +export default awaitify(groupByLimit, 4); diff --git a/lib/groupBySeries.js b/lib/groupBySeries.js new file mode 100644 index 000000000..8830133f5 --- /dev/null +++ b/lib/groupBySeries.js @@ -0,0 +1,24 @@ +import groupByLimit from './groupByLimit.js' + +/** + * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time. + * + * @name groupBySeries + * @static + * @memberOf module:Collections + * @method + * @see [async.groupBy]{@link module:Collections.groupBy} + * @category Collection + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a `key` to group the value under. + * Invoked with (value, callback). + * @param {Function} [callback] - A callback which is called when all `iteratee` + * functions have finished, or an error occurs. Result is an `Object` whose + * properties are arrays of values which returned the corresponding key. + * @returns {Promise} a promise, if no callback is passed + */ +export default function groupBySeries (coll, iteratee, callback) { + return groupByLimit(coll, 1, iteratee, callback) +} diff --git a/lib/index.js b/lib/index.js index 8a2c7cad9..8c3ddfd2c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,11 +1,52 @@ +/** + * 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. @@ -17,160 +58,179 @@ * @module ControlFlow */ - /** - * A collection of `async` utility functions. - * @module Utils - */ -import applyEach from './applyEach'; -import applyEachSeries from './applyEachSeries'; -import apply from './apply'; -import asyncify from './asyncify'; -import auto from './auto'; -import autoInject from './autoInject'; -import cargo from './cargo'; -import compose from './compose'; -import concat from './concat'; -import concatSeries from './concatSeries'; -import constant from './constant'; -import detect from './detect'; -import detectLimit from './detectLimit'; -import detectSeries from './detectSeries'; -import dir from './dir'; -import doDuring from './doDuring'; -import doUntil from './doUntil'; -import doWhilst from './doWhilst'; -import during from './during'; -import each from './each'; -import eachLimit from './eachLimit'; -import eachOf from './eachOf'; -import eachOfLimit from './eachOfLimit'; -import eachOfSeries from './eachOfSeries'; -import eachSeries from './eachSeries'; -import ensureAsync from './ensureAsync'; -import every from './every'; -import everyLimit from './everyLimit'; -import everySeries from './everySeries'; -import filter from './filter'; -import filterLimit from './filterLimit'; -import filterSeries from './filterSeries'; -import forever from './forever'; -import log from './log'; -import map from './map'; -import mapLimit from './mapLimit'; -import mapSeries from './mapSeries'; -import mapValues from './mapValues'; -import mapValuesLimit from './mapValuesLimit'; -import mapValuesSeries from './mapValuesSeries'; -import memoize from './memoize'; -import nextTick from './nextTick'; -import parallel from './parallel'; -import parallelLimit from './parallelLimit'; -import priorityQueue from './priorityQueue'; -import queue from './queue'; -import race from './race'; -import reduce from './reduce'; -import reduceRight from './reduceRight'; -import reflect from './reflect'; -import reject from './reject'; -import reflectAll from './reflectAll'; -import rejectLimit from './rejectLimit'; -import rejectSeries from './rejectSeries'; -import retry from './retry'; -import retryable from './retryable'; -import seq from './seq'; -import series from './series'; -import setImmediate from './setImmediate'; -import some from './some'; -import someLimit from './someLimit'; -import someSeries from './someSeries'; -import sortBy from './sortBy'; -import timeout from './timeout'; -import times from './times'; -import timesLimit from './timesLimit'; -import timesSeries from './timesSeries'; -import transform from './transform'; -import unmemoize from './unmemoize'; -import until from './until'; -import waterfall from './waterfall'; -import whilst from './whilst'; +/** + * A collection of `async` utility functions. + * @module Utils + */ + +import apply from './apply' +import applyEach from './applyEach' +import applyEachSeries from './applyEachSeries' +import asyncify from './asyncify' +import auto from './auto' +import autoInject from './autoInject' +import cargo from './cargo' +import cargoQueue from './cargoQueue' +import compose from './compose' +import concat from './concat' +import concatLimit from './concatLimit' +import concatSeries from './concatSeries' +import constant from './constant' +import detect from './detect' +import detectLimit from './detectLimit' +import detectSeries from './detectSeries' +import dir from './dir' +import doUntil from './doUntil' +import doWhilst from './doWhilst' +import each from './each' +import eachLimit from './eachLimit' +import eachOf from './eachOf' +import eachOfLimit from './eachOfLimit' +import eachOfSeries from './eachOfSeries' +import eachSeries from './eachSeries' +import ensureAsync from './ensureAsync' +import every from './every' +import everyLimit from './everyLimit' +import everySeries from './everySeries' +import filter from './filter' +import filterLimit from './filterLimit' +import filterSeries from './filterSeries' +import forever from './forever' +import groupBy from './groupBy' +import groupByLimit from './groupByLimit' +import groupBySeries from './groupBySeries' +import log from './log' +import map from './map' +import mapLimit from './mapLimit' +import mapSeries from './mapSeries' +import mapValues from './mapValues' +import mapValuesLimit from './mapValuesLimit' +import mapValuesSeries from './mapValuesSeries' +import memoize from './memoize' +import nextTick from './nextTick' +import parallel from './parallel' +import parallelLimit from './parallelLimit' +import priorityQueue from './priorityQueue' +import queue from './queue' +import race from './race' +import reduce from './reduce' +import reduceRight from './reduceRight' +import reflect from './reflect' +import reflectAll from './reflectAll' +import reject from './reject' +import rejectLimit from './rejectLimit' +import rejectSeries from './rejectSeries' +import retry from './retry' +import retryable from './retryable' +import seq from './seq' +import series from './series' +import setImmediate from './setImmediate' +import some from './some' +import someLimit from './someLimit' +import someSeries from './someSeries' +import sortBy from './sortBy' +import timeout from './timeout' +import times from './times' +import timesLimit from './timesLimit' +import timesSeries from './timesSeries' +import transform from './transform' +import tryEach from './tryEach' +import unmemoize from './unmemoize' +import until from './until' +import waterfall from './waterfall' +import whilst from './whilst' export default { - applyEach: applyEach, - applyEachSeries: applyEachSeries, - apply: apply, - asyncify: asyncify, - auto: auto, - autoInject: autoInject, - cargo: cargo, - compose: compose, - concat: concat, - concatSeries: concatSeries, - constant: constant, - detect: detect, - detectLimit: detectLimit, - detectSeries: detectSeries, - dir: dir, - doDuring: doDuring, - doUntil: doUntil, - doWhilst: doWhilst, - during: during, - each: each, - eachLimit: eachLimit, - eachOf: eachOf, - eachOfLimit: eachOfLimit, - eachOfSeries: eachOfSeries, - eachSeries: eachSeries, - ensureAsync: ensureAsync, - every: every, - everyLimit: everyLimit, - everySeries: everySeries, - filter: filter, - filterLimit: filterLimit, - filterSeries: filterSeries, - forever: forever, - log: log, - map: map, - mapLimit: mapLimit, - mapSeries: mapSeries, - mapValues: mapValues, - mapValuesLimit: mapValuesLimit, - mapValuesSeries: mapValuesSeries, - memoize: memoize, - nextTick: nextTick, - parallel: parallel, - parallelLimit: parallelLimit, - priorityQueue: priorityQueue, - queue: queue, - race: race, - reduce: reduce, - reduceRight: reduceRight, - reflect: reflect, - reflectAll: reflectAll, - reject: reject, - rejectLimit: rejectLimit, - rejectSeries: rejectSeries, - retry: retry, - retryable: retryable, - seq: seq, - series: series, - setImmediate: setImmediate, - some: some, - someLimit: someLimit, - someSeries: someSeries, - sortBy: sortBy, - timeout: timeout, - times: times, - timesLimit: timesLimit, - timesSeries: timesSeries, - transform: transform, - unmemoize: unmemoize, - until: until, - waterfall: waterfall, - whilst: whilst, + apply, + applyEach, + applyEachSeries, + asyncify, + auto, + autoInject, + cargo, + cargoQueue, + compose, + concat, + concatLimit, + concatSeries, + constant, + detect, + detectLimit, + detectSeries, + dir, + doUntil, + doWhilst, + each, + eachLimit, + eachOf, + eachOfLimit, + eachOfSeries, + eachSeries, + ensureAsync, + every, + everyLimit, + everySeries, + filter, + filterLimit, + filterSeries, + forever, + groupBy, + groupByLimit, + groupBySeries, + log, + map, + mapLimit, + mapSeries, + mapValues, + mapValuesLimit, + mapValuesSeries, + memoize, + nextTick, + parallel, + parallelLimit, + priorityQueue, + queue, + race, + reduce, + reduceRight, + reflect, + reflectAll, + reject, + rejectLimit, + rejectSeries, + retry, + retryable, + seq, + series, + setImmediate, + some, + someLimit, + someSeries, + sortBy, + timeout, + times, + timesLimit, + timesSeries, + transform, + tryEach, + unmemoize, + until, + waterfall, + whilst, // aliases all: every, + allLimit: everyLimit, + allSeries: everySeries, any: some, + anyLimit: someLimit, + anySeries: someSeries, + find: detect, + findLimit: detectLimit, + findSeries: detectSeries, + flatMap: concat, + flatMapLimit: concatLimit, + flatMapSeries: concatSeries, forEach: each, forEachSeries: eachSeries, forEachLimit: eachLimit, @@ -183,29 +243,31 @@ export default { select: filter, selectLimit: filterLimit, selectSeries: filterSeries, - wrapSync: asyncify + wrapSync: asyncify, + during: whilst, + doDuring: doWhilst }; export { + apply as apply, applyEach as applyEach, applyEachSeries as applyEachSeries, - apply as apply, asyncify as asyncify, auto as auto, autoInject as autoInject, cargo as cargo, + cargoQueue as cargoQueue, compose as compose, concat as concat, + concatLimit as concatLimit, concatSeries as concatSeries, constant as constant, detect as detect, detectLimit as detectLimit, detectSeries as detectSeries, dir as dir, - doDuring as doDuring, doUntil as doUntil, doWhilst as doWhilst, - during as during, each as each, eachLimit as eachLimit, eachOf as eachOf, @@ -220,6 +282,9 @@ export { filterLimit as filterLimit, filterSeries as filterSeries, forever as forever, + groupBy as groupBy, + groupByLimit as groupByLimit, + groupBySeries as groupBySeries, log as log, map as map, mapLimit as mapLimit, @@ -255,6 +320,7 @@ export { timesLimit as timesLimit, timesSeries as timesSeries, transform as transform, + tryEach as tryEach, unmemoize as unmemoize, until as until, waterfall as waterfall, @@ -270,6 +336,9 @@ export { detect as find, detectLimit as findLimit, detectSeries as findSeries, + concat as flatMap, + concatLimit as flatMapLimit, + concatSeries as flatMapSeries, each as forEach, eachSeries as forEachSeries, eachLimit as forEachLimit, @@ -282,5 +351,8 @@ export { filter as select, filterLimit as selectLimit, filterSeries as selectSeries, - asyncify as wrapSync + asyncify as wrapSync, + whilst as during, + doWhilst as doDuring }; + diff --git a/lib/internal/DoublyLinkedList.js b/lib/internal/DoublyLinkedList.js index 79c3bb50e..39f88ac6c 100644 --- a/lib/internal/DoublyLinkedList.js +++ b/lib/internal/DoublyLinkedList.js @@ -2,61 +2,91 @@ // used for queues. This implementation assumes that the node provided by the user can be modified // to adjust the next and last properties. We implement only the minimal functionality // for queue support. -export default function DLL() { - this.head = this.tail = null; - this.length = 0; -} +export default class DLL { + constructor() { + this.head = this.tail = null; + this.length = 0; + } -function setInitial(dll, node) { - dll.length = 1; - dll.head = dll.tail = node; -} + removeLink(node) { + if (node.prev) node.prev.next = node.next; + else this.head = node.next + if (node.next) node.next.prev = node.prev; + else this.tail = node.prev; -DLL.prototype.removeLink = function(node) { - if (node.prev) node.prev.next = node.next; - else this.head = node.next - if (node.next) node.next.prev = node.prev; - else this.tail = node.prev; + node.prev = node.next = null; + this.length -= 1; + return node; + } - node.prev = node.next = null; - this.length -= 1; - return node; -} + empty () { + while(this.head) this.shift(); + return this; + } -DLL.prototype.empty = DLL; + insertAfter(node, newNode) { + newNode.prev = node; + newNode.next = node.next; + if (node.next) node.next.prev = newNode; + else this.tail = newNode; + node.next = newNode; + this.length += 1; + } -DLL.prototype.insertAfter = function(node, newNode) { - newNode.prev = node; - newNode.next = node.next; - if (node.next) node.next.prev = newNode; - else this.tail = newNode; - node.next = newNode; - this.length += 1; -} + insertBefore(node, newNode) { + newNode.prev = node.prev; + newNode.next = node; + if (node.prev) node.prev.next = newNode; + else this.head = newNode; + node.prev = newNode; + this.length += 1; + } -DLL.prototype.insertBefore = function(node, newNode) { - newNode.prev = node.prev; - newNode.next = node; - if (node.prev) node.prev.next = newNode; - else this.head = newNode; - node.prev = newNode; - this.length += 1; -} + unshift(node) { + if (this.head) this.insertBefore(this.head, node); + else setInitial(this, node); + } + + push(node) { + if (this.tail) this.insertAfter(this.tail, node); + else setInitial(this, node); + } -DLL.prototype.unshift = function(node) { - if (this.head) this.insertBefore(this.head, node); - else setInitial(this, node); -}; + shift() { + return this.head && this.removeLink(this.head); + } -DLL.prototype.push = function(node) { - if (this.tail) this.insertAfter(this.tail, node); - else setInitial(this, node); -}; + pop() { + return this.tail && this.removeLink(this.tail); + } -DLL.prototype.shift = function() { - return this.head && this.removeLink(this.head); -}; + toArray() { + return [...this] + } + + *[Symbol.iterator] () { + var cur = this.head + while (cur) { + yield cur.data + cur = cur.next + } + } + + remove (testFn) { + var curr = this.head; + while(curr) { + var {next} = curr; + if (testFn(curr)) { + this.removeLink(curr); + } + curr = next; + } + return this; + } +} + +function setInitial(dll, node) { + dll.length = 1; + dll.head = dll.tail = node; +} -DLL.prototype.pop = function() { - return this.tail && this.removeLink(this.tail); -}; diff --git a/lib/internal/Heap.js b/lib/internal/Heap.js new file mode 100644 index 000000000..d9ccacf4a --- /dev/null +++ b/lib/internal/Heap.js @@ -0,0 +1,115 @@ +// Binary min-heap implementation used for priority queue. +// Implementation is stable, i.e. push time is considered for equal priorities +export default class Heap { + constructor() { + this.heap = []; + this.pushCount = Number.MIN_SAFE_INTEGER; + } + + get length() { + return this.heap.length; + } + + empty () { + this.heap = []; + return this; + } + + percUp(index) { + let p; + + while (index > 0 && smaller(this.heap[index], this.heap[p=parent(index)])) { + let t = this.heap[index]; + this.heap[index] = this.heap[p]; + this.heap[p] = t; + + index = p; + } + } + + percDown(index) { + let l; + + while ((l=leftChi(index)) < this.heap.length) { + if (l+1 < this.heap.length && smaller(this.heap[l+1], this.heap[l])) { + l = l+1; + } + + if (smaller(this.heap[index], this.heap[l])) { + break; + } + + let t = this.heap[index]; + this.heap[index] = this.heap[l]; + this.heap[l] = t; + + index = l; + } + } + + push(node) { + node.pushCount = ++this.pushCount; + this.heap.push(node); + this.percUp(this.heap.length-1); + } + + unshift(node) { + return this.heap.push(node); + } + + shift() { + let [top] = this.heap; + + this.heap[0] = this.heap[this.heap.length-1]; + this.heap.pop(); + this.percDown(0); + + return top; + } + + toArray() { + return [...this]; + } + + *[Symbol.iterator] () { + for (let i = 0; i < this.heap.length; i++) { + yield this.heap[i].data; + } + } + + remove (testFn) { + let j = 0; + for (let i = 0; i < this.heap.length; i++) { + if (!testFn(this.heap[i])) { + this.heap[j] = this.heap[i]; + j++; + } + } + + this.heap.splice(j); + + for (let i = parent(this.heap.length-1); i >= 0; i--) { + this.percDown(i); + } + + return this; + } +} + +function leftChi(i) { + return (i<<1)+1; +} + +function parent(i) { + return ((i+1)>>1)-1; +} + +function smaller(x, y) { + if (x.priority !== y.priority) { + return x.priority < y.priority; + } + else { + return x.pushCount < y.pushCount; + } +} + diff --git a/lib/internal/applyEach.js b/lib/internal/applyEach.js index 1d7a0b697..3a9ea3ab3 100644 --- a/lib/internal/applyEach.js +++ b/lib/internal/applyEach.js @@ -1,19 +1,14 @@ -import rest from 'lodash/_baseRest'; -import initialParams from './initialParams'; +import wrapAsync from './wrapAsync.js' +import awaitify from './awaitify.js' -export default function applyEach(eachfn) { - return rest(function(fns, args) { - var go = initialParams(function(args, callback) { +export default function (eachfn) { + return function applyEach(fns, ...callArgs) { + const go = awaitify(function (callback) { var that = this; - return eachfn(fns, function (fn, cb) { - fn.apply(that, args.concat([cb])); + return eachfn(fns, (fn, cb) => { + wrapAsync(fn).apply(that, callArgs.concat(cb)); }, callback); }); - if (args.length) { - return go.apply(this, args); - } - else { - return go; - } - }); + return go; + }; } diff --git a/lib/internal/asyncEachOfLimit.js b/lib/internal/asyncEachOfLimit.js new file mode 100644 index 000000000..46b08c6e0 --- /dev/null +++ b/lib/internal/asyncEachOfLimit.js @@ -0,0 +1,63 @@ +import breakLoop from './breakLoop.js' + +// for async generators +export default function asyncEachOfLimit(generator, limit, iteratee, callback) { + let done = false + let canceled = false + let awaiting = false + let running = 0 + let idx = 0 + + function replenish() { + //console.log('replenish') + if (running >= limit || awaiting || done) return + //console.log('replenish awaiting') + awaiting = true + generator.next().then(({value, done: iterDone}) => { + //console.log('got value', value) + if (canceled || done) return + awaiting = false + if (iterDone) { + done = true; + if (running <= 0) { + //console.log('done nextCb') + callback(null) + } + return; + } + running++ + iteratee(value, idx, iterateeCallback) + idx++ + replenish() + }).catch(handleError) + } + + function iterateeCallback(err, result) { + //console.log('iterateeCallback') + running -= 1; + if (canceled) return + if (err) return handleError(err) + + if (err === false) { + done = true; + canceled = true; + return + } + + if (result === breakLoop || (done && running <= 0)) { + done = true; + //console.log('done iterCb') + return callback(null); + } + replenish() + } + + function handleError(err) { + if (canceled) return + awaiting = false + done = true + callback(err) + } + + replenish() +} diff --git a/lib/internal/awaitify.js b/lib/internal/awaitify.js new file mode 100644 index 000000000..811ff61a7 --- /dev/null +++ b/lib/internal/awaitify.js @@ -0,0 +1,21 @@ +// conditionally promisify a function. +// only return a promise if a callback is omitted +export default function awaitify (asyncFn, arity) { + if (!arity) arity = asyncFn.length; + if (!arity) throw new Error('arity is undefined') + function awaitable (...args) { + if (typeof args[arity - 1] === 'function') { + return asyncFn.apply(this, args) + } + + return new Promise((resolve, reject) => { + args[arity - 1] = (err, ...cbArgs) => { + if (err) return reject(err) + resolve(cbArgs.length > 1 ? cbArgs : cbArgs[0]) + } + asyncFn.apply(this, args) + }) + } + + return awaitable +} diff --git a/lib/internal/breakLoop.js b/lib/internal/breakLoop.js new file mode 100644 index 000000000..542b1bcf4 --- /dev/null +++ b/lib/internal/breakLoop.js @@ -0,0 +1,4 @@ +// A temporary value used to identify if the loop should be broken. +// See #1064, #1293 +const breakLoop = {}; +export default breakLoop; diff --git a/lib/internal/concat.js b/lib/internal/concat.js deleted file mode 100644 index a55de2eec..000000000 --- a/lib/internal/concat.js +++ /dev/null @@ -1,11 +0,0 @@ -export default function concat(eachfn, arr, fn, callback) { - var result = []; - eachfn(arr, function (x, index, cb) { - fn(x, function (err, y) { - result = result.concat(y || []); - cb(err); - }); - }, function (err) { - callback(err, result); - }); -} diff --git a/lib/internal/consoleFunc.js b/lib/internal/consoleFunc.js index e2d615059..3c2a39f15 100644 --- a/lib/internal/consoleFunc.js +++ b/lib/internal/consoleFunc.js @@ -1,21 +1,18 @@ -import arrayEach from 'lodash/_arrayEach'; -import rest from 'lodash/_baseRest'; +import wrapAsync from './wrapAsync.js' export default function consoleFunc(name) { - return rest(function (fn, args) { - fn.apply(null, args.concat([rest(function (err, args) { - if (typeof console === 'object') { - if (err) { - if (console.error) { - console.error(err); - } - } - else if (console[name]) { - arrayEach(args, function (x) { - console[name](x); - }); + return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => { + /* istanbul ignore else */ + if (typeof console === 'object') { + /* istanbul ignore else */ + if (err) { + /* istanbul ignore else */ + if (console.error) { + console.error(err); } + } else if (console[name]) { /* istanbul ignore else */ + resultArgs.forEach(x => console[name](x)); } - })])); - }); + } + }) } diff --git a/lib/internal/createTester.js b/lib/internal/createTester.js index ac38bf75b..ce7828a4e 100644 --- a/lib/internal/createTester.js +++ b/lib/internal/createTester.js @@ -1,40 +1,25 @@ -'use strict'; -import noop from 'lodash/noop'; +import breakLoop from './breakLoop.js' +import wrapAsync from './wrapAsync.js' -export default function _createTester(eachfn, check, getResult) { - return function(arr, limit, iteratee, cb) { - function done(err) { - if (cb) { - if (err) { - cb(err); - } else { - cb(null, getResult(false)); - } - } - } - function wrappedIteratee(x, _, callback) { - if (!cb) return callback(); - iteratee(x, function (err, v) { - if (cb) { - if (err) { - cb(err); - cb = iteratee = false; - } else if (check(v)) { - cb(null, getResult(true, x)); - cb = iteratee = false; - } +export default function _createTester(check, getResult) { + return (eachfn, arr, _iteratee, cb) => { + var testPassed = false; + var testResult; + const iteratee = wrapAsync(_iteratee) + eachfn(arr, (value, _, callback) => { + iteratee(value, (err, result) => { + if (err || err === false) return callback(err); + + if (check(result) && !testResult) { + testPassed = true; + testResult = getResult(true, value); + return callback(null, breakLoop); } callback(); }); - } - if (arguments.length > 3) { - cb = cb || noop; - eachfn(arr, limit, wrappedIteratee, done); - } else { - cb = iteratee; - cb = cb || noop; - iteratee = limit; - eachfn(arr, wrappedIteratee, done); - } + }, err => { + if (err) return cb(err); + cb(null, testPassed ? testResult : getResult(false)); + }); }; } diff --git a/lib/internal/doLimit.js b/lib/internal/doLimit.js deleted file mode 100644 index 7d2f1117a..000000000 --- a/lib/internal/doLimit.js +++ /dev/null @@ -1,5 +0,0 @@ -export default function doLimit(fn, limit) { - return function (iterable, iteratee, callback) { - return fn(iterable, limit, iteratee, callback); - }; -} diff --git a/lib/internal/doParallel.js b/lib/internal/doParallel.js deleted file mode 100644 index d43620881..000000000 --- a/lib/internal/doParallel.js +++ /dev/null @@ -1,7 +0,0 @@ -import eachOf from '../eachOf'; - -export default function doParallel(fn) { - return function (obj, iteratee, callback) { - return fn(eachOf, obj, iteratee, callback); - }; -} diff --git a/lib/internal/doParallelLimit.js b/lib/internal/doParallelLimit.js deleted file mode 100644 index b29da51cd..000000000 --- a/lib/internal/doParallelLimit.js +++ /dev/null @@ -1,7 +0,0 @@ -import eachOfLimit from './eachOfLimit'; - -export default function doParallelLimit(fn) { - return function (obj, limit, iteratee, callback) { - return fn(eachOfLimit(limit), obj, iteratee, callback); - }; -} diff --git a/lib/internal/doSeries.js b/lib/internal/doSeries.js deleted file mode 100644 index 96e21ca65..000000000 --- a/lib/internal/doSeries.js +++ /dev/null @@ -1,7 +0,0 @@ -import eachOfSeries from '../eachOfSeries'; - -export default function doSeries(fn) { - return function (obj, iteratee, callback) { - return fn(eachOfSeries, obj, iteratee, callback); - }; -} diff --git a/lib/internal/eachOfLimit.js b/lib/internal/eachOfLimit.js index 61fd6a4b0..063f8e59c 100644 --- a/lib/internal/eachOfLimit.js +++ b/lib/internal/eachOfLimit.js @@ -1,34 +1,53 @@ -import noop from 'lodash/noop'; -import once from './once'; +import once from './once.js' +import iterator from './iterator.js' +import onlyOnce from './onlyOnce.js' +import {isAsyncGenerator, isAsyncIterable} from './wrapAsync.js' +import asyncEachOfLimit from './asyncEachOfLimit.js' +import breakLoop from './breakLoop.js' -import iterator from './iterator'; -import onlyOnce from './onlyOnce'; - -export default function _eachOfLimit(limit) { - return function (obj, iteratee, callback) { - callback = once(callback || noop); - if (limit <= 0 || !obj) { +export default (limit) => { + return (obj, iteratee, callback) => { + callback = once(callback); + if (limit <= 0) { + throw new RangeError('concurrency limit cannot be less than 1') + } + if (!obj) { return callback(null); } + if (isAsyncGenerator(obj)) { + return asyncEachOfLimit(obj, limit, iteratee, callback) + } + if (isAsyncIterable(obj)) { + return asyncEachOfLimit(obj[Symbol.asyncIterator](), limit, iteratee, callback) + } var nextElem = iterator(obj); var done = false; + var canceled = false; var running = 0; + var looping = false; - function iterateeCallback(err) { + function iterateeCallback(err, value) { + if (canceled) return running -= 1; if (err) { done = true; callback(err); } - else if (done && running <= 0) { + else if (err === false) { + done = true; + canceled = true; + } + else if (value === breakLoop || (done && running <= 0)) { + done = true; return callback(null); } - else { + else if (!looping) { replenish(); } } function replenish () { + looping = true; while (running < limit && !done) { var elem = nextElem(); if (elem === null) { @@ -41,6 +60,7 @@ export default function _eachOfLimit(limit) { running += 1; iteratee(elem.value, elem.key, onlyOnce(iterateeCallback)); } + looping = false; } replenish(); diff --git a/lib/internal/filter.js b/lib/internal/filter.js index 35527e20a..a0478059b 100644 --- a/lib/internal/filter.js +++ b/lib/internal/filter.js @@ -1,31 +1,42 @@ -import arrayMap from 'lodash/_arrayMap'; -import property from 'lodash/_baseProperty'; -import noop from 'lodash/noop'; -import once from './once'; +import isArrayLike from './isArrayLike.js' +import wrapAsync from './wrapAsync.js' -export default function _filter(eachfn, arr, iteratee, callback) { - callback = once(callback || noop); +function filterArray(eachfn, arr, iteratee, callback) { + var truthValues = new Array(arr.length); + eachfn(arr, (x, index, iterCb) => { + iteratee(x, (err, v) => { + truthValues[index] = !!v; + iterCb(err); + }); + }, err => { + if (err) return callback(err); + var results = []; + for (var i = 0; i < arr.length; i++) { + if (truthValues[i]) results.push(arr[i]); + } + callback(null, results); + }); +} + +function filterGeneric(eachfn, coll, iteratee, callback) { var results = []; - eachfn(arr, function (x, index, callback) { - iteratee(x, function (err, v) { - if (err) { - callback(err); - } - else { - if (v) { - results.push({index: index, value: x}); - } - callback(); + eachfn(coll, (x, index, iterCb) => { + iteratee(x, (err, v) => { + if (err) return iterCb(err); + if (v) { + results.push({index, value: x}); } + iterCb(err); }); - }, function (err) { - if (err) { - callback(err); - } - else { - callback(null, arrayMap(results.sort(function (a, b) { - return a.index - b.index; - }), property('value'))); - } + }, err => { + if (err) return callback(err); + callback(null, results + .sort((a, b) => a.index - b.index) + .map(v => v.value)); }); } + +export default function _filter(eachfn, coll, iteratee, callback) { + var filter = isArrayLike(coll) ? filterArray : filterGeneric; + return filter(eachfn, coll, wrapAsync(iteratee), callback); +} diff --git a/lib/internal/findGetResult.js b/lib/internal/findGetResult.js deleted file mode 100644 index 7345df620..000000000 --- a/lib/internal/findGetResult.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function _findGetResult(v, x) { - return x; -} diff --git a/lib/internal/getIterator.js b/lib/internal/getIterator.js index 87860f48d..99a571886 100644 --- a/lib/internal/getIterator.js +++ b/lib/internal/getIterator.js @@ -1,5 +1,3 @@ -var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator; - export default function (coll) { - return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol](); + return coll[Symbol.iterator] && coll[Symbol.iterator](); } diff --git a/lib/internal/initialParams.js b/lib/internal/initialParams.js index 304fd2382..9ea253a7c 100644 --- a/lib/internal/initialParams.js +++ b/lib/internal/initialParams.js @@ -1,8 +1,6 @@ -import rest from 'lodash/_baseRest'; - export default function (fn) { - return rest(function (args/*..., callback*/) { + return function (...args/*, callback*/) { var callback = args.pop(); - fn.call(this, args, callback); - }); + return fn.call(this, args, callback); + }; } diff --git a/lib/internal/isArrayLike.js b/lib/internal/isArrayLike.js new file mode 100644 index 000000000..f3d0f5e17 --- /dev/null +++ b/lib/internal/isArrayLike.js @@ -0,0 +1,6 @@ +export default function isArrayLike(value) { + return value && + typeof value.length === 'number' && + value.length >= 0 && + value.length % 1 === 0; +} diff --git a/lib/internal/iterator.js b/lib/internal/iterator.js index 15c6fddb4..2fe85c3d0 100644 --- a/lib/internal/iterator.js +++ b/lib/internal/iterator.js @@ -1,6 +1,5 @@ -import isArrayLike from 'lodash/isArrayLike'; -import getIterator from './getIterator'; -import keys from 'lodash/keys'; +import isArrayLike from './isArrayLike.js' +import getIterator from './getIterator.js' function createArrayIterator(coll) { var i = -1; @@ -22,16 +21,19 @@ function createES2015Iterator(iterator) { } function createObjectIterator(obj) { - var okeys = keys(obj); + var okeys = obj ? Object.keys(obj) : []; var i = -1; var len = okeys.length; return function next() { var key = okeys[++i]; - return i < len ? {value: obj[key], key: key} : null; + if (key === '__proto__') { + return next(); + } + return i < len ? {value: obj[key], key} : null; }; } -export default function iterator(coll) { +export default function createIterator(coll) { if (isArrayLike(coll)) { return createArrayIterator(coll); } diff --git a/lib/internal/map.js b/lib/internal/map.js index 2c2a75016..ca995793c 100644 --- a/lib/internal/map.js +++ b/lib/internal/map.js @@ -1,19 +1,18 @@ -import noop from 'lodash/noop'; -import once from './once'; +import wrapAsync from './wrapAsync.js' export default function _asyncMap(eachfn, arr, iteratee, callback) { - callback = once(callback || noop); arr = arr || []; var results = []; var counter = 0; + var _iteratee = wrapAsync(iteratee); - eachfn(arr, function (value, _, callback) { + return eachfn(arr, (value, _, iterCb) => { var index = counter++; - iteratee(value, function (err, v) { + _iteratee(value, (err, v) => { results[index] = v; - callback(err); + iterCb(err); }); - }, function (err) { + }, err => { callback(err, results); }); } diff --git a/lib/internal/notId.js b/lib/internal/notId.js deleted file mode 100644 index 65a676e13..000000000 --- a/lib/internal/notId.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function notId(v) { - return !v; -} diff --git a/lib/internal/once.js b/lib/internal/once.js index f601185b9..10ab26b6c 100644 --- a/lib/internal/once.js +++ b/lib/internal/once.js @@ -1,8 +1,10 @@ export default function once(fn) { - return function () { + function wrapper (...args) { if (fn === null) return; var callFn = fn; fn = null; - callFn.apply(this, arguments); - }; + callFn.apply(this, args); + } + Object.assign(wrapper, fn) + return wrapper } diff --git a/lib/internal/onlyOnce.js b/lib/internal/onlyOnce.js index bb1979ab2..07664a451 100644 --- a/lib/internal/onlyOnce.js +++ b/lib/internal/onlyOnce.js @@ -1,8 +1,8 @@ export default function onlyOnce(fn) { - return function() { + return function (...args) { if (fn === null) throw new Error("Callback was already called."); var callFn = fn; fn = null; - callFn.apply(this, arguments); + callFn.apply(this, args); }; } diff --git a/lib/internal/parallel.js b/lib/internal/parallel.js index 1b91b608e..f4f91ea78 100644 --- a/lib/internal/parallel.js +++ b/lib/internal/parallel.js @@ -1,20 +1,17 @@ -import noop from 'lodash/noop'; -import isArrayLike from 'lodash/isArrayLike'; -import rest from 'lodash/_baseRest'; +import isArrayLike from './isArrayLike.js' +import wrapAsync from './wrapAsync.js' +import awaitify from './awaitify.js' -export default function _parallel(eachfn, tasks, callback) { - callback = callback || noop; +export default awaitify((eachfn, tasks, callback) => { var results = isArrayLike(tasks) ? [] : {}; - eachfn(tasks, function (task, key, callback) { - task(rest(function (err, args) { - if (args.length <= 1) { - args = args[0]; + eachfn(tasks, (task, key, taskCb) => { + wrapAsync(task)((err, ...result) => { + if (result.length < 2) { + [result] = result; } - results[key] = args; - callback(err); - })); - }, function (err) { - callback(err, results); - }); -} + results[key] = result; + taskCb(err); + }); + }, err => callback(err, results)); +}, 3) diff --git a/lib/internal/promiseCallback.js b/lib/internal/promiseCallback.js new file mode 100644 index 000000000..685dd7aa1 --- /dev/null +++ b/lib/internal/promiseCallback.js @@ -0,0 +1,19 @@ +const PROMISE_SYMBOL = Symbol('promiseCallback') + +function promiseCallback () { + let resolve, reject + function callback (err, ...args) { + if (err) return reject(err) + resolve(args.length > 1 ? args : args[0]) + } + + callback[PROMISE_SYMBOL] = new Promise((res, rej) => { + resolve = res, + reject = rej + }) + + return callback +} + + +export { promiseCallback, PROMISE_SYMBOL } diff --git a/lib/internal/queue.js b/lib/internal/queue.js index 067aaf6db..75712c274 100644 --- a/lib/internal/queue.js +++ b/lib/internal/queue.js @@ -1,153 +1,276 @@ -import indexOf from 'lodash/_baseIndexOf'; -import isArray from 'lodash/isArray'; -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; - -import onlyOnce from './onlyOnce'; -import setImmediate from './setImmediate'; -import DLL from './DoublyLinkedList'; +import onlyOnce from './onlyOnce.js' +import setImmediate from './setImmediate.js' +import DLL from './DoublyLinkedList.js' +import wrapAsync from './wrapAsync.js' export default function queue(worker, concurrency, payload) { if (concurrency == null) { concurrency = 1; } else if(concurrency === 0) { - throw new Error('Concurrency must not be zero'); + throw new RangeError('Concurrency must not be zero'); + } + + var _worker = wrapAsync(worker); + var numRunning = 0; + var workersList = []; + const events = { + error: [], + drain: [], + saturated: [], + unsaturated: [], + empty: [] + } + + function on (event, handler) { + events[event].push(handler) + } + + function once (event, handler) { + const handleAndRemove = (...args) => { + off(event, handleAndRemove) + handler(...args) + } + events[event].push(handleAndRemove) + } + + function off (event, handler) { + if (!event) return Object.keys(events).forEach(ev => events[ev] = []) + if (!handler) return events[event] = [] + events[event] = events[event].filter(ev => ev !== handler) + } + + function trigger (event, ...args) { + events[event].forEach(handler => handler(...args)) } - function _insert(data, insertAtFront, callback) { + var processingScheduled = false; + function _insert(data, insertAtFront, rejectOnError, callback) { if (callback != null && typeof callback !== 'function') { throw new Error('task callback must be a function'); } q.started = true; - if (!isArray(data)) { - data = [data]; + + var res, rej; + function promiseCallback (err, ...args) { + // we don't care about the error, let the global error handler + // deal with it + if (err) return rejectOnError ? rej(err) : res() + if (args.length <= 1) return res(args[0]) + res(args) } - if (data.length === 0 && q.idle()) { - // call drain immediately if there are no tasks - return setImmediate(function() { - q.drain(); - }); + + var item = q._createTaskItem( + data, + rejectOnError ? promiseCallback : + (callback || promiseCallback) + ); + + if (insertAtFront) { + q._tasks.unshift(item); + } else { + q._tasks.push(item); } - for (var i = 0, l = data.length; i < l; i++) { - var item = { - data: data[i], - callback: callback || noop - }; + if (!processingScheduled) { + processingScheduled = true; + setImmediate(() => { + processingScheduled = false; + q.process(); + }); + } - if (insertAtFront) { - q._tasks.unshift(item); - } else { - q._tasks.push(item); - } + if (rejectOnError || !callback) { + return new Promise((resolve, reject) => { + res = resolve + rej = reject + }) } - setImmediate(q.process); } - function _next(tasks) { - return rest(function(args){ - workers -= 1; + function _createCB(tasks) { + return function (err, ...args) { + numRunning -= 1; for (var i = 0, l = tasks.length; i < l; i++) { var task = tasks[i]; - var index = indexOf(workersList, task, 0); - if (index >= 0) { - workersList.splice(index) + + var index = workersList.indexOf(task); + if (index === 0) { + workersList.shift(); + } else if (index > 0) { + workersList.splice(index, 1); } - task.callback.apply(task, args); + task.callback(err, ...args); - if (args[0] != null) { - q.error(args[0], task.data); + if (err != null) { + trigger('error', err, task.data); } } - if (workers <= (q.concurrency - q.buffer) ) { - q.unsaturated(); + if (numRunning <= (q.concurrency - q.buffer) ) { + trigger('unsaturated') } if (q.idle()) { - q.drain(); + trigger('drain') } q.process(); - }); + }; } - var workers = 0; - var workersList = []; + function _maybeDrain(data) { + if (data.length === 0 && q.idle()) { + // call drain immediately if there are no tasks + setImmediate(() => trigger('drain')); + return true + } + return false + } + + const eventMethod = (name) => (handler) => { + if (!handler) { + return new Promise((resolve, reject) => { + once(name, (err, data) => { + if (err) return reject(err) + resolve(data) + }) + }) + } + off(name) + on(name, handler) + + } + + var isProcessing = false; var q = { _tasks: new DLL(), - concurrency: concurrency, - payload: payload, - saturated: noop, - unsaturated:noop, + _createTaskItem (data, callback) { + return { + data, + callback + }; + }, + *[Symbol.iterator] () { + yield* q._tasks[Symbol.iterator]() + }, + concurrency, + payload, buffer: concurrency / 4, - empty: noop, - drain: noop, - error: noop, started: false, paused: false, - push: function (data, callback) { - _insert(data, false, callback); + push (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, false, callback)) + } + return _insert(data, false, false, callback); + }, + pushAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, false, true, callback)) + } + return _insert(data, false, true, callback); }, - kill: function () { - q.drain = noop; + kill () { + off() q._tasks.empty(); }, - unshift: function (data, callback) { - _insert(data, true, callback); + unshift (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, false, callback)) + } + return _insert(data, true, false, callback); + }, + unshiftAsync (data, callback) { + if (Array.isArray(data)) { + if (_maybeDrain(data)) return + return data.map(datum => _insert(datum, true, true, callback)) + } + return _insert(data, true, true, callback); }, - process: function () { - while(!q.paused && workers < q.concurrency && q._tasks.length){ + remove (testFn) { + q._tasks.remove(testFn); + }, + process () { + // Avoid trying to start too many processing operations. This can occur + // when callbacks resolve synchronously (#1267). + if (isProcessing) { + return; + } + isProcessing = true; + while(!q.paused && numRunning < q.concurrency && q._tasks.length){ var tasks = [], data = []; var l = q._tasks.length; if (q.payload) l = Math.min(l, q.payload); for (var i = 0; i < l; i++) { var node = q._tasks.shift(); tasks.push(node); + workersList.push(node); data.push(node.data); } + numRunning += 1; + if (q._tasks.length === 0) { - q.empty(); + trigger('empty'); } - workers += 1; - workersList.push(tasks[0]); - if (workers === q.concurrency) { - q.saturated(); + if (numRunning === q.concurrency) { + trigger('saturated'); } - var cb = onlyOnce(_next(tasks)); - worker(data, cb); + var cb = onlyOnce(_createCB(tasks)); + _worker(data, cb); } + isProcessing = false; }, - length: function () { + length () { return q._tasks.length; }, - running: function () { - return workers; + running () { + return numRunning; }, - workersList: function () { + workersList () { return workersList; }, - idle: function() { - return q._tasks.length + workers === 0; + idle() { + return q._tasks.length + numRunning === 0; }, - pause: function () { + pause () { q.paused = true; }, - resume: function () { + resume () { if (q.paused === false) { return; } q.paused = false; - var resumeCount = Math.min(q.concurrency, q._tasks.length); - // Need to call q.process once per concurrent - // worker to preserve full concurrency after pause - for (var w = 1; w <= resumeCount; w++) { - setImmediate(q.process); - } + setImmediate(q.process); } }; + // define these as fixed properties, so people get useful errors when updating + Object.defineProperties(q, { + saturated: { + writable: false, + value: eventMethod('saturated') + }, + unsaturated: { + writable: false, + value: eventMethod('unsaturated') + }, + empty: { + writable: false, + value: eventMethod('empty') + }, + drain: { + writable: false, + value: eventMethod('drain') + }, + error: { + writable: false, + value: eventMethod('error') + }, + }) return q; } diff --git a/lib/internal/range.js b/lib/internal/range.js new file mode 100644 index 000000000..c9033e58a --- /dev/null +++ b/lib/internal/range.js @@ -0,0 +1,7 @@ +export default function range(size) { + var result = Array(size); + while (size--) { + result[size] = size; + } + return result; +} diff --git a/lib/internal/reject.js b/lib/internal/reject.js index b6d7343ad..59b07863c 100644 --- a/lib/internal/reject.js +++ b/lib/internal/reject.js @@ -1,13 +1,11 @@ -import filter from './filter'; +import filter from './filter.js' +import wrapAsync from './wrapAsync.js' -export default function reject(eachfn, arr, iteratee, callback) { - filter(eachfn, arr, function(value, cb) { - iteratee(value, function(err, v) { - if (err) { - cb(err); - } else { - cb(null, !v); - } +export default function reject(eachfn, arr, _iteratee, callback) { + const iteratee = wrapAsync(_iteratee) + return filter(eachfn, arr, (value, cb) => { + iteratee(value, (err, v) => { + cb(err, !v); }); }, callback); } diff --git a/lib/internal/setImmediate.js b/lib/internal/setImmediate.js index 228c45cc1..bafd40c0a 100644 --- a/lib/internal/setImmediate.js +++ b/lib/internal/setImmediate.js @@ -1,7 +1,6 @@ -'use strict'; - -import rest from 'lodash/_baseRest'; +/* istanbul ignore file */ +export var hasQueueMicrotask = typeof queueMicrotask === 'function' && queueMicrotask; export var hasSetImmediate = typeof setImmediate === 'function' && setImmediate; export var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function'; @@ -10,16 +9,14 @@ export function fallback(fn) { } export function wrap(defer) { - return rest(function (fn, args) { - defer(function () { - fn.apply(null, args); - }); - }); + return (fn, ...args) => defer(() => fn(...args)); } var _defer; -if (hasSetImmediate) { +if (hasQueueMicrotask) { + _defer = queueMicrotask; +} else if (hasSetImmediate) { _defer = setImmediate; } else if (hasNextTick) { _defer = process.nextTick; diff --git a/lib/internal/withoutIndex.js b/lib/internal/withoutIndex.js index 2d70dd4a8..4de0f31db 100644 --- a/lib/internal/withoutIndex.js +++ b/lib/internal/withoutIndex.js @@ -1,5 +1,3 @@ export default function _withoutIndex(iteratee) { - return function (value, index, callback) { - return iteratee(value, callback); - }; + return (value, index, callback) => iteratee(value, callback); } diff --git a/lib/internal/wrapAsync.js b/lib/internal/wrapAsync.js new file mode 100644 index 000000000..4e21f822b --- /dev/null +++ b/lib/internal/wrapAsync.js @@ -0,0 +1,22 @@ +import asyncify from '../asyncify.js' + +function isAsync(fn) { + return fn[Symbol.toStringTag] === 'AsyncFunction'; +} + +function isAsyncGenerator(fn) { + return fn[Symbol.toStringTag] === 'AsyncGenerator'; +} + +function isAsyncIterable(obj) { + return typeof obj[Symbol.asyncIterator] === 'function'; +} + +function wrapAsync(asyncFn) { + if (typeof asyncFn !== 'function') throw new Error('expected a function') + return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn; +} + +export default wrapAsync; + +export { isAsync, isAsyncGenerator, isAsyncIterable }; diff --git a/lib/log.js b/lib/log.js index 848661da5..158ff168c 100644 --- a/lib/log.js +++ b/lib/log.js @@ -1,4 +1,4 @@ -import consoleFunc from './internal/consoleFunc'; +import consoleFunc from './internal/consoleFunc.js' /** * Logs the result of an `async` function to the `console`. Only works in @@ -11,8 +11,8 @@ import consoleFunc from './internal/consoleFunc'; * @memberOf module:Utils * @method * @category Util - * @param {Function} function - The function you want to eventually apply all - * arguments to. + * @param {AsyncFunction} function - The function you want to eventually apply + * all arguments to. * @param {...*} arguments... - Any number of arguments to apply to the function. * @example * diff --git a/lib/map.js b/lib/map.js index 4c0b22685..68f71edfd 100644 --- a/lib/map.js +++ b/lib/map.js @@ -1,10 +1,11 @@ -import doParallel from './internal/doParallel'; -import map from './internal/map'; +import _map from './internal/map.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * Produces a new collection of values by mapping each value in `coll` through * the `iteratee` function. The `iteratee` is called with an item from `coll` - * and a callback for when it has finished processing. Each of these callback + * and a callback for when it has finished processing. Each of these callbacks * takes 2 arguments: an `error`, and the transformed item from `coll`. If * `iteratee` passes an error to its callback, the main `callback` (for the * `map` function) is immediately called with the error. @@ -16,25 +17,109 @@ import map from './internal/map'; * * If `map` is passed an Object, the results will be an Array. The results * will roughly be in the order of the original Objects' keys (but this can - * vary across JavaScript engines) + * vary across JavaScript engines). * * @name map * @static * @memberOf module:Collections * @method * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed item. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` * functions have finished, or an error occurs. Results is an Array of the * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed * @example * - * async.map(['file1','file2','file3'], fs.stat, function(err, results) { - * // results is now an array of stats for each file + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file4.txt']; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.map(fileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes, function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * }); + * + * // Using Promises + * async.map(fileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.map(withMissingFileList, getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.map(fileList, getFileSizeInBytes); + * console.log(results); + * // results is now an array of the file size in bytes for each file, e.g. + * // [ 1000, 2000, 3000] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let results = await async.map(withMissingFileList, getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * */ -export default doParallel(map); +function map (coll, iteratee, callback) { + return _map(eachOf, coll, iteratee, callback) +} +export default awaitify(map, 3); diff --git a/lib/mapLimit.js b/lib/mapLimit.js index a54922d3b..0717ff137 100644 --- a/lib/mapLimit.js +++ b/lib/mapLimit.js @@ -1,5 +1,6 @@ -import doParallelLimit from './internal/doParallelLimit'; -import map from './internal/map'; +import _map from './internal/map.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time. @@ -10,14 +11,18 @@ import map from './internal/map'; * @method * @see [async.map]{@link module:Collections.map} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a transformed - * item. Invoked with (item, callback). + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` * functions have finished, or an error occurs. Results is an array of the * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed */ -export default doParallelLimit(map); +function mapLimit (coll, limit, iteratee, callback) { + return _map(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(mapLimit, 4); diff --git a/lib/mapSeries.js b/lib/mapSeries.js index e1f3d0d5d..a77157be7 100644 --- a/lib/mapSeries.js +++ b/lib/mapSeries.js @@ -1,5 +1,6 @@ -import mapLimit from './mapLimit'; -import doLimit from './internal/doLimit'; +import _map from './internal/map.js' +import eachOfSeries from './eachOfSeries.js' +import awaitify from './internal/awaitify.js' /** * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time. @@ -10,13 +11,17 @@ import doLimit from './internal/doLimit'; * @method * @see [async.map]{@link module:Collections.map} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed item. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with the transformed item. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` * functions have finished, or an error occurs. Results is an array of the * transformed items from the `coll`. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed */ -export default doLimit(mapLimit, 1); +function mapSeries (coll, iteratee, callback) { + return _map(eachOfSeries, coll, iteratee, callback) +} +export default awaitify(mapSeries, 3); diff --git a/lib/mapValues.js b/lib/mapValues.js index a0a947092..9cebf58a1 100644 --- a/lib/mapValues.js +++ b/lib/mapValues.js @@ -1,6 +1,4 @@ -import mapValuesLimit from './mapValuesLimit'; -import doLimit from './internal/doLimit'; - +import mapValuesLimit from './mapValuesLimit.js' /** * A relative of [`map`]{@link module:Collections.map}, designed for use with objects. @@ -21,29 +19,122 @@ import doLimit from './internal/doLimit'; * @method * @category Collection * @param {Object} obj - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each value and key in - * `coll`. The iteratee is passed a `callback(err, transformed)` which must be - * called once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Results is an array of the - * transformed items from the `obj`. Invoked with (err, result). + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed * @example * - * async.mapValues({ - * f1: 'file1', - * f2: 'file2', - * f3: 'file3' - * }, function (file, key, callback) { - * fs.stat(file, callback); - * }, function(err, result) { - * // results is now a map of stats for each file, e.g. + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file3.txt' + * }; + * + * const withMissingFileMap = { + * f1: 'file1.txt', + * f2: 'file2.txt', + * f3: 'file4.txt' + * }; + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, key, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); + * }); + * } + * + * // Using callbacks + * async.mapValues(fileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * } else { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * }); + * + * // Error handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(result); + * } + * }); + * + * // Using Promises + * async.mapValues(fileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. * // { - * // f1: [stats for file1], - * // f2: [stats for file2], - * // f3: [stats for file3] + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 * // } + * }).catch (err => { + * console.log(err); + * }); + * + * // Error Handling + * async.mapValues(withMissingFileMap, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch (err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.mapValues(fileMap, getFileSizeInBytes); + * console.log(result); + * // result is now a map of file size in bytes for each file, e.g. + * // { + * // f1: 1000, + * // f2: 2000, + * // f3: 3000 + * // } + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.mapValues(withMissingFileMap, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * */ - -export default doLimit(mapValuesLimit, Infinity); +export default function mapValues(obj, iteratee, callback) { + return mapValuesLimit(obj, Infinity, iteratee, callback) +} diff --git a/lib/mapValuesLimit.js b/lib/mapValuesLimit.js index f6e72ff43..001375e35 100644 --- a/lib/mapValuesLimit.js +++ b/lib/mapValuesLimit.js @@ -1,7 +1,7 @@ -import eachOfLimit from './eachOfLimit'; - -import noop from 'lodash/noop'; -import once from './internal/once'; +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' +import once from './internal/once.js' +import wrapAsync from './internal/wrapAsync.js' /** * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a @@ -15,24 +15,27 @@ import once from './internal/once'; * @category Collection * @param {Object} obj - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A function to apply to each value in `obj`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Result is an object of the - * transformed values from the `obj`. Invoked with (err, result). + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed */ -export default function mapValuesLimit(obj, limit, iteratee, callback) { - callback = once(callback || noop); +function mapValuesLimit(obj, limit, iteratee, callback) { + callback = once(callback); var newObj = {}; - eachOfLimit(obj, limit, function(val, key, next) { - iteratee(val, key, function (err, result) { + var _iteratee = wrapAsync(iteratee) + return eachOfLimit(limit)(obj, (val, key, next) => { + _iteratee(val, key, (err, result) => { if (err) return next(err); newObj[key] = result; - next(); + next(err); }); - }, function (err) { - callback(err, newObj); - }); + }, err => callback(err, newObj)); } + +export default awaitify(mapValuesLimit, 4) diff --git a/lib/mapValuesSeries.js b/lib/mapValuesSeries.js index b97fcd13b..35c46c6d7 100644 --- a/lib/mapValuesSeries.js +++ b/lib/mapValuesSeries.js @@ -1,5 +1,4 @@ -import mapValuesLimit from './mapValuesLimit'; -import doLimit from './internal/doLimit'; +import mapValuesLimit from './mapValuesLimit.js' /** * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time. @@ -11,12 +10,16 @@ import doLimit from './internal/doLimit'; * @see [async.mapValues]{@link module:Collections.mapValues} * @category Collection * @param {Object} obj - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each value in `obj`. - * The iteratee is passed a `callback(err, transformed)` which must be called - * once it has completed with an error (which can be `null`) and a - * transformed value. Invoked with (value, key, callback). + * @param {AsyncFunction} iteratee - A function to apply to each value and key + * in `coll`. + * The iteratee should complete with the transformed value as its result. + * Invoked with (value, key, callback). * @param {Function} [callback] - A callback which is called when all `iteratee` - * functions have finished, or an error occurs. Result is an object of the - * transformed values from the `obj`. Invoked with (err, result). + * functions have finished, or an error occurs. `result` is a new object consisting + * of each key from `obj`, with each transformed value on the right-hand side. + * Invoked with (err, result). + * @returns {Promise} a promise, if no callback is passed */ -export default doLimit(mapValuesLimit, 1); +export default function mapValuesSeries(obj, iteratee, callback) { + return mapValuesLimit(obj, 1, iteratee, callback) +} diff --git a/lib/memoize.js b/lib/memoize.js index b273153ee..56b2368e6 100644 --- a/lib/memoize.js +++ b/lib/memoize.js @@ -1,18 +1,15 @@ -import identity from 'lodash/identity'; -import rest from 'lodash/_baseRest'; - -import setImmediate from './internal/setImmediate'; -import initialParams from './internal/initialParams'; - -function has(obj, key) { - return key in obj; -} +import setImmediate from './internal/setImmediate.js' +import initialParams from './internal/initialParams.js' +import wrapAsync from './internal/wrapAsync.js' /** - * Caches the results of an `async` function. When creating a hash to store + * Caches the results of an async function. When creating a hash to store * function results against, the callback is omitted from the hash and an * optional hash function can be used. * + * **Note: if the async function errs, the result will not be cached and + * subsequent calls will call the wrapped function.** + * * If no hash function is specified, the first argument is used as a hash key, * which may work reasonably if it is a string or a data type that converts to a * distinct string. Note that objects and arrays will not behave reasonably. @@ -27,11 +24,11 @@ function has(obj, key) { * @memberOf module:Utils * @method * @category Util - * @param {Function} fn - The function to proxy and cache results from. + * @param {AsyncFunction} fn - The async function to proxy and cache results from. * @param {Function} hasher - An optional function for generating a custom hash * for storing results. It has all the arguments applied to it apart from the * callback, and must be synchronous. - * @returns {Function} a memoized version of `fn` + * @returns {AsyncFunction} a memoized version of `fn` * @example * * var slow_fn = function(name, callback) { @@ -45,28 +42,29 @@ function has(obj, key) { * // callback * }); */ -export default function memoize(fn, hasher) { +export default function memoize(fn, hasher = v => v) { var memo = Object.create(null); var queues = Object.create(null); - hasher = hasher || identity; - var memoized = initialParams(function memoized(args, callback) { - var key = hasher.apply(null, args); - if (has(memo, key)) { - setImmediate(function() { - callback.apply(null, memo[key]); - }); - } else if (has(queues, key)) { + var _fn = wrapAsync(fn); + var memoized = initialParams((args, callback) => { + var key = hasher(...args); + if (key in memo) { + setImmediate(() => callback(null, ...memo[key])); + } else if (key in queues) { queues[key].push(callback); } else { queues[key] = [callback]; - fn.apply(null, args.concat([rest(function(args) { - memo[key] = args; + _fn(...args, (err, ...resultArgs) => { + // #1465 don't memoize if an error occurred + if (!err) { + memo[key] = resultArgs; + } var q = queues[key]; delete queues[key]; for (var i = 0, l = q.length; i < l; i++) { - q[i].apply(null, args); + q[i](err, ...resultArgs); } - })])); + }); } }); memoized.memo = memo; diff --git a/lib/nextTick.js b/lib/nextTick.js index 62d20def0..a7965a214 100644 --- a/lib/nextTick.js +++ b/lib/nextTick.js @@ -1,10 +1,9 @@ -'use strict'; - -import { hasNextTick, hasSetImmediate, fallback, wrap } from './internal/setImmediate'; +/* istanbul ignore file */ +import { hasNextTick, hasSetImmediate, fallback, wrap } from './internal/setImmediate.js' /** * Calls `callback` on a later loop around the event loop. In Node.js this just - * calls `setImmediate`. In the browser it will use `setImmediate` if + * calls `process.nextTick`. In the browser it will use `setImmediate` if * available, otherwise `setTimeout(callback, 0)`, which means other higher * priority events may precede the execution of `callback`. * @@ -14,7 +13,7 @@ import { hasNextTick, hasSetImmediate, fallback, wrap } from './internal/setImm * @static * @memberOf module:Utils * @method - * @alias setImmediate + * @see [async.setImmediate]{@link module:Utils.setImmediate} * @category Util * @param {Function} callback - The function to call on a later loop around * the event loop. Invoked with (args...). diff --git a/lib/parallel.js b/lib/parallel.js index 506f47545..d50a0df00 100644 --- a/lib/parallel.js +++ b/lib/parallel.js @@ -1,5 +1,5 @@ -import eachOf from './eachOf'; -import parallel from './internal/parallel'; +import eachOf from './eachOf.js' +import _parallel from './internal/parallel.js' /** * Run the `tasks` collection of functions in parallel, without waiting until @@ -14,6 +14,9 @@ import parallel from './internal/parallel'; * sections for each task will happen one after the other. JavaScript remains * single-threaded. * + * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the + * execution of other tasks when a task fails. + * * It is also possible to use an object instead of an array. Each property will * be run as a function and the results will be passed to the final `callback` * as an object instead of an array. This can be a more readable way of handling @@ -24,15 +27,18 @@ import parallel from './internal/parallel'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Array|Iterable|Object} tasks - A collection containing functions to run. - * Each function is passed a `callback(err, result)` which it must call on - * completion with an error `err` (which can be `null`) and an optional `result` - * value. + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. * @param {Function} [callback] - An optional callback to run once all the * functions have completed successfully. This function gets a results array * (or object) containing all the result arguments passed to the task callbacks. * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed + * * @example + * + * //Using Callbacks * async.parallel([ * function(callback) { * setTimeout(function() { @@ -44,10 +50,9 @@ import parallel from './internal/parallel'; * callback(null, 'two'); * }, 100); * } - * ], - * // optional callback - * function(err, results) { - * // the results array will equal ['one','two'] even though + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] even though * // the second function had a shorter timeout. * }); * @@ -64,9 +69,97 @@ import parallel from './internal/parallel'; * }, 100); * } * }, function(err, results) { - * // results is now equals to: {one: 1, two: 2} + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * }).catch(err => { + * console.log(err); * }); + * + * // an example using an object instead of an array + * async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.parallel([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] even though + * // the second function had a shorter timeout. + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default function parallelLimit(tasks, callback) { - parallel(eachOf, tasks, callback); +export default function parallel(tasks, callback) { + return _parallel(eachOf, tasks, callback); } diff --git a/lib/parallelLimit.js b/lib/parallelLimit.js index 926fa853a..4f87403f0 100644 --- a/lib/parallelLimit.js +++ b/lib/parallelLimit.js @@ -1,5 +1,5 @@ -import eachOfLimit from './internal/eachOfLimit'; -import parallel from './internal/parallel'; +import eachOfLimit from './internal/eachOfLimit.js' +import parallel from './internal/parallel.js' /** * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a @@ -11,16 +11,16 @@ import parallel from './internal/parallel'; * @method * @see [async.parallel]{@link module:ControlFlow.parallel} * @category Control Flow - * @param {Array|Collection} tasks - A collection containing functions to run. - * Each function is passed a `callback(err, result)` which it must call on - * completion with an error `err` (which can be `null`) and an optional `result` - * value. + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection of + * [async functions]{@link AsyncFunction} to run. + * Each async function can complete with any number of optional `result` values. * @param {number} limit - The maximum number of async operations at a time. * @param {Function} [callback] - An optional callback to run once all the * functions have completed successfully. This function gets a results array * (or object) containing all the result arguments passed to the task callbacks. * Invoked with (err, results). + * @returns {Promise} a promise, if a callback is not passed */ export default function parallelLimit(tasks, limit, callback) { - parallel(eachOfLimit(limit), tasks, callback); + return parallel(eachOfLimit(limit), tasks, callback); } diff --git a/lib/priorityQueue.js b/lib/priorityQueue.js index 0af01577c..e418e488d 100644 --- a/lib/priorityQueue.js +++ b/lib/priorityQueue.js @@ -1,9 +1,5 @@ -import isArray from 'lodash/isArray'; -import noop from 'lodash/noop'; - -import setImmediate from './setImmediate'; - -import queue from './queue'; +import queue from './queue.js' +import Heap from './internal/Heap.js' /** * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and @@ -15,65 +11,58 @@ import queue from './queue'; * @method * @see [async.queue]{@link module:ControlFlow.queue} * @category Control Flow - * @param {Function} worker - An asynchronous function for processing a queued - * task, which must call its `callback(err)` argument when finished, with an - * optional `error` as an argument. If you want to handle errors from an - * individual task, pass a callback to `q.push()`. Invoked with - * (task, callback). + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. + * Invoked with (task, callback). * @param {number} concurrency - An `integer` for determining how many `worker` * functions should be run in parallel. If omitted, the concurrency defaults to * `1`. If the concurrency is `0`, an error is thrown. - * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two + * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are three * differences between `queue` and `priorityQueue` objects: * * `push(task, priority, [callback])` - `priority` should be a number. If an * array of `tasks` is given, all tasks will be assigned the same priority. - * * The `unshift` method was removed. + * * `pushAsync(task, priority, [callback])` - the same as `priorityQueue.push`, + * except this returns a promise that rejects if an error occurs. + * * The `unshift` and `unshiftAsync` methods were removed. */ export default function(worker, concurrency) { // Start with a normal queue var q = queue(worker, concurrency); - // Override push to accept second parameter representing priority - q.push = function(data, priority, callback) { - if (callback == null) callback = noop; - if (typeof callback !== 'function') { - throw new Error('task callback must be a function'); - } - q.started = true; - if (!isArray(data)) { - data = [data]; - } - if (data.length === 0) { - // call drain immediately if there are no tasks - return setImmediate(function() { - q.drain(); - }); - } + var { + push, + pushAsync + } = q; - priority = priority || 0; - var nextNode = q._tasks.head; - while (nextNode && priority >= nextNode.priority) { - nextNode = nextNode.next; + q._tasks = new Heap(); + q._createTaskItem = ({data, priority}, callback) => { + return { + data, + priority, + callback + }; + }; + + function createDataItems(tasks, priority) { + if (!Array.isArray(tasks)) { + return {data: tasks, priority}; } + return tasks.map(data => { return {data, priority}; }); + } - for (var i = 0, l = data.length; i < l; i++) { - var item = { - data: data[i], - priority: priority, - callback: callback - }; + // Override push to accept second parameter representing priority + q.push = function(data, priority = 0, callback) { + return push(createDataItems(data, priority), callback); + }; - if (nextNode) { - q._tasks.insertBefore(nextNode, item); - } else { - q._tasks.push(item); - } - } - setImmediate(q.process); + q.pushAsync = function(data, priority = 0, callback) { + return pushAsync(createDataItems(data, priority), callback); }; - // Remove unshift function + // Remove unshift functions delete q.unshift; + delete q.unshiftAsync; return q; } diff --git a/lib/queue.js b/lib/queue.js index 5666843a5..0884b3b91 100644 --- a/lib/queue.js +++ b/lib/queue.js @@ -1,8 +1,9 @@ -import queue from './internal/queue'; +import queue from './internal/queue.js' +import wrapAsync from './internal/wrapAsync.js' /** * A queue of tasks for the worker function to complete. - * @typedef {Object} QueueObject + * @typedef {Iterable} QueueObject * @memberOf module:ControlFlow * @property {Function} length - a function returning the number of items * waiting to be processed. Invoke with `queue.length()`. @@ -17,26 +18,45 @@ import queue from './internal/queue'; * @property {number} concurrency - an integer for determining how many `worker` * functions should be run in parallel. This property can be changed after a * `queue` is created to alter the concurrency on-the-fly. - * @property {Function} push - add a new task to the `queue`. Calls `callback` + * @property {number} payload - an integer that specifies how many items are + * passed to the worker function at a time. only applies if this is a + * [cargo]{@link module:ControlFlow.cargo} object + * @property {AsyncFunction} push - add a new task to the `queue`. Calls `callback` * once the `worker` has finished processing the task. Instead of a single task, * a `tasks` array can be submitted. The respective callback is used for every * task in the list. Invoke with `queue.push(task, [callback])`, - * @property {Function} unshift - add a new task to the front of the `queue`. + * @property {AsyncFunction} unshift - add a new task to the front of the `queue`. * Invoke with `queue.unshift(task, [callback])`. - * @property {Function} saturated - a callback that is called when the number of - * running workers hits the `concurrency` limit, and further tasks will be - * queued. - * @property {Function} unsaturated - a callback that is called when the number - * of running workers is less than the `concurrency` & `buffer` limits, and - * further tasks will not be queued. + * @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns + * a promise that rejects if an error occurs. + * @property {AsyncFunction} unshiftAsync - the same as `q.unshift`, except this returns + * a promise that rejects if an error occurs. + * @property {Function} remove - remove items from the queue that match a test + * function. The test function will be passed an object with a `data` property, + * and a `priority` property, if this is a + * [priorityQueue]{@link module:ControlFlow.priorityQueue} object. + * Invoked with `queue.remove(testFn)`, where `testFn` is of the form + * `function ({data, priority}) {}` and returns a Boolean. + * @property {Function} saturated - a function that sets a callback that is + * called when the number of running workers hits the `concurrency` limit, and + * further tasks will be queued. If the callback is omitted, `q.saturated()` + * returns a promise for the next occurrence. + * @property {Function} unsaturated - a function that sets a callback that is + * called when the number of running workers is less than the `concurrency` & + * `buffer` limits, and further tasks will not be queued. If the callback is + * omitted, `q.unsaturated()` returns a promise for the next occurrence. * @property {number} buffer - A minimum threshold buffer in order to say that * the `queue` is `unsaturated`. - * @property {Function} empty - a callback that is called when the last item - * from the `queue` is given to a `worker`. - * @property {Function} drain - a callback that is called when the last item - * from the `queue` has returned from the `worker`. - * @property {Function} error - a callback that is called when a task errors. - * Has the signature `function(error, task)`. + * @property {Function} empty - a function that sets a callback that is called + * when the last item from the `queue` is given to a `worker`. If the callback + * is omitted, `q.empty()` returns a promise for the next occurrence. + * @property {Function} drain - a function that sets a callback that is called + * when the last item from the `queue` has returned from the `worker`. If the + * callback is omitted, `q.drain()` returns a promise for the next occurrence. + * @property {Function} error - a function that sets a callback that is called + * when a task errors. Has the signature `function(error, task)`. If the + * callback is omitted, `error()` returns a promise that rejects on the next + * error. * @property {boolean} paused - a boolean for determining whether the queue is * in a paused state. * @property {Function} pause - a function that pauses the processing of tasks @@ -44,7 +64,26 @@ import queue from './internal/queue'; * @property {Function} resume - a function that resumes the processing of * queued tasks when the queue is paused. Invoke with `queue.resume()`. * @property {Function} kill - a function that removes the `drain` callback and - * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`. + * empties remaining tasks from the queue forcing it to go idle. No more tasks + * should be pushed to the queue after calling this function. Invoke with `queue.kill()`. + * + * @example + * const q = async.queue(worker, 2) + * q.push(item1) + * q.push(item2) + * q.push(item3) + * // queues are iterable, spread into an array to inspect + * const items = [...q] // [item1, item2, item3] + * // or use for of + * for (let item of q) { + * console.log(item) + * } + * + * q.drain(() => { + * console.log('all done') + * }) + * // or + * await q.drain() */ /** @@ -58,15 +97,13 @@ import queue from './internal/queue'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Function} worker - An asynchronous function for processing a queued - * task, which must call its `callback(err)` argument when finished, with an - * optional `error` as an argument. If you want to handle errors from an - * individual task, pass a callback to `q.push()`. Invoked with - * (task, callback). + * @param {AsyncFunction} worker - An async function for processing a queued task. + * If you want to handle errors from an individual task, pass a callback to + * `q.push()`. Invoked with (task, callback). * @param {number} [concurrency=1] - An `integer` for determining how many * `worker` functions should be run in parallel. If omitted, the concurrency * defaults to `1`. If the concurrency is `0`, an error is thrown. - * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can + * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can be * attached as certain properties to listen for specific events during the * lifecycle of the queue. * @example @@ -78,17 +115,23 @@ import queue from './internal/queue'; * }, 2); * * // assign a callback - * q.drain = function() { + * q.drain(function() { * console.log('all items have been processed'); - * }; + * }); + * // or await the end + * await q.drain() + * + * // assign an error callback + * q.error(function(err, task) { + * console.error('task experienced an error'); + * }); * * // add some items to the queue * q.push({name: 'foo'}, function(err) { * console.log('finished processing foo'); * }); - * q.push({name: 'bar'}, function (err) { - * console.log('finished processing bar'); - * }); + * // callback is optional + * q.push({name: 'bar'}); * * // add some items to the queue (batch-wise) * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) { @@ -101,7 +144,8 @@ import queue from './internal/queue'; * }); */ export default function (worker, concurrency) { - return queue(function (items, cb) { - worker(items[0], cb); + var _worker = wrapAsync(worker); + return queue((items, cb) => { + _worker(items[0], cb); }, concurrency, 1); } diff --git a/lib/race.js b/lib/race.js index 693762787..6cbe51395 100644 --- a/lib/race.js +++ b/lib/race.js @@ -1,10 +1,10 @@ -import isArray from 'lodash/isArray'; -import noop from 'lodash/noop'; -import once from './internal/once'; +import once from './internal/once.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Runs the `tasks` array of functions in parallel, without waiting until the - * previous function has completed. Once any the `tasks` completed or pass an + * previous function has completed. Once any of the `tasks` complete or pass an * error to its callback, the main `callback` is immediately called. It's * equivalent to `Promise.race()`. * @@ -13,13 +13,12 @@ import once from './internal/once'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Array} tasks - An array containing functions to run. Each function - * is passed a `callback(err, result)` which it must call on completion with an - * error `err` (which can be `null`) and an optional `result` value. + * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction} + * to run. Each function can complete with an optional `result` value. * @param {Function} callback - A callback to run once any of the functions have * completed. This function gets an error or result from the first function that * completed. Invoked with (err, result). - * @returns undefined + * @returns {Promise} a promise, if a callback is omitted * @example * * async.race([ @@ -39,11 +38,13 @@ import once from './internal/once'; * // the result will be equal to 'two' as it finishes earlier * }); */ -export default function race(tasks, callback) { - callback = once(callback || noop); - if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); +function race(tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions')); if (!tasks.length) return callback(); for (var i = 0, l = tasks.length; i < l; i++) { - tasks[i](callback); + wrapAsync(tasks[i])(callback); } } + +export default awaitify(race, 2) diff --git a/lib/reduce.js b/lib/reduce.js index d2fe1c2fc..15a7ba40c 100644 --- a/lib/reduce.js +++ b/lib/reduce.js @@ -1,6 +1,7 @@ -import eachOfSeries from './eachOfSeries'; -import noop from 'lodash/noop'; -import once from './internal/once'; +import eachOfSeries from './eachOfSeries.js' +import once from './internal/once.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Reduces `coll` into a single value using an async `iteratee` to return each @@ -20,36 +21,113 @@ import once from './internal/once'; * @alias inject * @alias foldl * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {*} memo - The initial state of the reduction. - * @param {Function} iteratee - A function applied to each item in the - * array to produce the next step in the reduction. The `iteratee` is passed a - * `callback(err, reduction)` which accepts an optional error as its first - * argument, and the state of the reduction as the second. If an error is - * passed to the callback, the reduction is stopped and the main `callback` is - * immediately called with the error. Invoked with (memo, item, callback). + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee completes with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result is the reduced value. Invoked with * (err, result). + * @returns {Promise} a promise, if no callback is passed * @example * - * async.reduce([1,2,3], 0, function(memo, item, callback) { - * // pointless async: - * process.nextTick(function() { - * callback(null, memo + item) + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * // file4.txt does not exist + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * const withMissingFileList = ['file1.txt','file2.txt','file3.txt', 'file4.txt']; + * + * // asynchronous function that computes the file size in bytes + * // file size is added to the memoized value, then returned + * function getFileSizeInBytes(memo, file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, memo + stat.size); * }); - * }, function(err, result) { - * // result is now equal to the last value of memo, which is 6 + * } + * + * // Using callbacks + * async.reduce(fileList, 0, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * } else { + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * } + * }); + * + * // Error Handling + * async.reduce(withMissingFileList, 0, getFileSizeInBytes, function(err, result) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(result); + * } + * }); + * + * // Using Promises + * async.reduce(fileList, 0, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * }).catch( err => { + * console.log(err); + * }); + * + * // Error Handling + * async.reduce(withMissingFileList, 0, getFileSizeInBytes) + * .then( result => { + * console.log(result); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.reduce(fileList, 0, getFileSizeInBytes); + * console.log(result); + * // 6000 + * // which is the sum of the file sizes of the three files + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // Error Handling + * async () => { + * try { + * let result = await async.reduce(withMissingFileList, 0, getFileSizeInBytes); + * console.log(result); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * */ -export default function reduce(coll, memo, iteratee, callback) { - callback = once(callback || noop); - eachOfSeries(coll, function(x, i, callback) { - iteratee(memo, x, function(err, v) { +function reduce(coll, memo, iteratee, callback) { + callback = once(callback); + var _iteratee = wrapAsync(iteratee); + return eachOfSeries(coll, (x, i, iterCb) => { + _iteratee(memo, x, (err, v) => { memo = v; - callback(err); + iterCb(err); }); - }, function(err) { - callback(err, memo); - }); + }, err => callback(err, memo)); } +export default awaitify(reduce, 4) diff --git a/lib/reduceRight.js b/lib/reduceRight.js index 844c94f93..f58e37cc2 100644 --- a/lib/reduceRight.js +++ b/lib/reduceRight.js @@ -1,6 +1,4 @@ -import reduce from './reduce'; - -var slice = Array.prototype.slice; +import reduce from './reduce.js' /** * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order. @@ -14,17 +12,18 @@ var slice = Array.prototype.slice; * @category Collection * @param {Array} array - A collection to iterate over. * @param {*} memo - The initial state of the reduction. - * @param {Function} iteratee - A function applied to each item in the - * array to produce the next step in the reduction. The `iteratee` is passed a - * `callback(err, reduction)` which accepts an optional error as its first - * argument, and the state of the reduction as the second. If an error is - * passed to the callback, the reduction is stopped and the main `callback` is - * immediately called with the error. Invoked with (memo, item, callback). + * @param {AsyncFunction} iteratee - A function applied to each item in the + * array to produce the next step in the reduction. + * The `iteratee` should complete with the next state of the reduction. + * If the iteratee completes with an error, the reduction is stopped and the + * main `callback` is immediately called with the error. + * Invoked with (memo, item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result is the reduced value. Invoked with * (err, result). + * @returns {Promise} a promise, if no callback is passed */ export default function reduceRight (array, memo, iteratee, callback) { - var reversed = slice.call(array).reverse(); - reduce(reversed, memo, iteratee, callback); + var reversed = [...array].reverse(); + return reduce(reversed, memo, iteratee, callback); } diff --git a/lib/reflect.js b/lib/reflect.js index a5ab9d9a1..2bd6ef2c4 100644 --- a/lib/reflect.js +++ b/lib/reflect.js @@ -1,18 +1,18 @@ -import initialParams from './internal/initialParams'; -import rest from 'lodash/_baseRest'; +import initialParams from './internal/initialParams.js' +import wrapAsync from './internal/wrapAsync.js' /** - * Wraps the function in another function that always returns data even when it - * errors. + * Wraps the async function in another function that always completes with a + * result object, even when it errors. * - * The object returned has either the property `error` or `value`. + * The result object has either the property `error` or `value`. * * @name reflect * @static * @memberOf module:Utils * @method * @category Util - * @param {Function} fn - The function you want to wrap + * @param {AsyncFunction} fn - The async function you want to wrap * @returns {Function} - A function that always passes null to it's callback as * the error. The second argument to the callback will be an `object` with * either an `error` or a `value` property. @@ -41,25 +41,23 @@ import rest from 'lodash/_baseRest'; * }); */ export default function reflect(fn) { + var _fn = wrapAsync(fn); return initialParams(function reflectOn(args, reflectCallback) { - args.push(rest(function callback(err, cbArgs) { - if (err) { - reflectCallback(null, { - error: err - }); - } else { - var value = null; - if (cbArgs.length === 1) { - value = cbArgs[0]; - } else if (cbArgs.length > 1) { - value = cbArgs; + args.push((error, ...cbArgs) => { + let retVal = {}; + if (error) { + retVal.error = error; + } + if (cbArgs.length > 0){ + var value = cbArgs; + if (cbArgs.length <= 1) { + [value] = cbArgs; } - reflectCallback(null, { - value: value - }); + retVal.value = value; } - })); + reflectCallback(null, retVal); + }); - return fn.apply(this, args); + return _fn.apply(this, args); }); } diff --git a/lib/reflectAll.js b/lib/reflectAll.js index dbeba8d81..77fb49687 100644 --- a/lib/reflectAll.js +++ b/lib/reflectAll.js @@ -1,10 +1,7 @@ -import reflect from './reflect'; -import isArray from 'lodash/isArray'; -import _arrayMap from 'lodash/_arrayMap'; -import forOwn from 'lodash/_baseForOwn'; +import reflect from './reflect.js' /** - * A helper function that wraps an array or an object of functions with reflect. + * A helper function that wraps an array or an object of functions with `reflect`. * * @name reflectAll * @static @@ -12,8 +9,9 @@ import forOwn from 'lodash/_baseForOwn'; * @method * @see [async.reflect]{@link module:Utils.reflect} * @category Util - * @param {Array} tasks - The array of functions to wrap in `async.reflect`. - * @returns {Array} Returns an array of functions, each function wrapped in + * @param {Array|Object|Iterable} tasks - The collection of + * [async functions]{@link AsyncFunction} to wrap in `async.reflect`. + * @returns {Array} Returns an array of async functions, each wrapped in * `async.reflect` * @example * @@ -71,12 +69,12 @@ import forOwn from 'lodash/_baseForOwn'; */ export default function reflectAll(tasks) { var results; - if (isArray(tasks)) { - results = _arrayMap(tasks, reflect); + if (Array.isArray(tasks)) { + results = tasks.map(reflect); } else { results = {}; - forOwn(tasks, function(task, key) { - results[key] = reflect.call(this, task); + Object.keys(tasks).forEach(key => { + results[key] = reflect.call(this, tasks[key]); }); } return results; diff --git a/lib/reject.js b/lib/reject.js index 0ddbaf0ac..f1355ced1 100644 --- a/lib/reject.js +++ b/lib/reject.js @@ -1,5 +1,6 @@ -import reject from './internal/reject'; -import doParallel from './internal/doParallel'; +import _reject from './internal/reject.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test. @@ -10,21 +11,60 @@ import doParallel from './internal/doParallel'; * @method * @see [async.filter]{@link module:Collections.filter} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed * @example * - * async.reject(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, results) { - * // results now equals an array of missing files - * createFiles(results); + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * + * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt']; + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.reject(fileList, fileExists, function(err, results) { + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files * }); + * + * // Using Promises + * async.reject(fileList, fileExists) + * .then( results => { + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let results = await async.reject(fileList, fileExists); + * console.log(results); + * // [ 'dir3/file6.txt' ] + * // results now equals an array of the non-existing files + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default doParallel(reject); +function reject (coll, iteratee, callback) { + return _reject(eachOf, coll, iteratee, callback) +} +export default awaitify(reject, 3); diff --git a/lib/rejectLimit.js b/lib/rejectLimit.js index 977bc4c83..c695c505e 100644 --- a/lib/rejectLimit.js +++ b/lib/rejectLimit.js @@ -1,6 +1,6 @@ -import reject from './internal/reject'; -import doParallelLimit from './internal/doParallelLimit'; - +import _reject from './internal/reject.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a * time. @@ -11,12 +11,17 @@ import doParallelLimit from './internal/doParallelLimit'; * @method * @see [async.reject]{@link module:Collections.reject} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed */ -export default doParallelLimit(reject); +function rejectLimit (coll, limit, iteratee, callback) { + return _reject(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(rejectLimit, 4); diff --git a/lib/rejectSeries.js b/lib/rejectSeries.js index 0bb925e97..c7b8d6709 100644 --- a/lib/rejectSeries.js +++ b/lib/rejectSeries.js @@ -1,5 +1,6 @@ -import rejectLimit from './rejectLimit'; -import doLimit from './internal/doLimit'; +import _reject from './internal/reject.js' +import eachOfSeries from './eachOfSeries.js' +import awaitify from './internal/awaitify.js' /** * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time. @@ -10,11 +11,16 @@ import doLimit from './internal/doLimit'; * @method * @see [async.reject]{@link module:Collections.reject} * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in `coll`. - * The `iteratee` is passed a `callback(err, truthValue)`, which must be called - * with a boolean argument once it has completed. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {Function} iteratee - An async truth test to apply to each item in + * `coll`. + * The should complete with a boolean value as its `result`. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Invoked with (err, results). + * @returns {Promise} a promise, if no callback is passed */ -export default doLimit(rejectLimit, 1); +function rejectSeries (coll, iteratee, callback) { + return _reject(eachOfSeries, coll, iteratee, callback) +} +export default awaitify(rejectSeries, 3); diff --git a/lib/retry.js b/lib/retry.js index a5ad866bf..e7c78e27a 100644 --- a/lib/retry.js +++ b/lib/retry.js @@ -1,5 +1,11 @@ -import noop from 'lodash/noop'; -import constant from 'lodash/constant'; +import wrapAsync from './internal/wrapAsync.js' +import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js' + +function constant(value) { + return function () { + return value; + } +} /** * Attempts to get a successful response from `task` no more than `times` times @@ -12,6 +18,7 @@ import constant from 'lodash/constant'; * @memberOf module:ControlFlow * @method * @category Control Flow + * @see [async.retryable]{@link module:ControlFlow.retryable} * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an * object with `times` and `interval` or a number. * * `times` - The number of attempts to make before giving up. The default @@ -26,16 +33,14 @@ import constant from 'lodash/constant'; * Invoked with (err). * * If `opts` is a number, the number specifies the number of times to retry, * with the default interval of `0`. - * @param {Function} task - A function which receives two arguments: (1) a - * `callback(err, result)` which must be called when finished, passing `err` - * (which can be `null`) and the `result` of the function's execution, and (2) - * a `results` object, containing the results of the previously executed - * functions (if nested inside another control flow). Invoked with - * (callback, results). + * @param {AsyncFunction} task - An async function to retry. + * Invoked with (callback). * @param {Function} [callback] - An optional callback which is called when the * task has succeeded, or after the final failed attempt. It receives the `err` * and `result` arguments of the last attempt at completing the `task`. Invoked * with (err, results). + * @returns {Promise} a promise if no callback provided + * * @example * * // The `retry` function can be used as a stand-alone control flow by passing @@ -77,65 +82,69 @@ import constant from 'lodash/constant'; * // do something with the result * }); * - * // It can also be embedded within other control flow functions to retry - * // individual methods that are not as reliable, like this: + * // to retry individual methods that are not as reliable within other + * // control flow functions, use the `retryable` wrapper: * async.auto({ * users: api.getUsers.bind(api), - * payments: async.retry(3, api.getPayments.bind(api)) + * payments: async.retryable(3, api.getPayments.bind(api)) * }, function(err, results) { * // do something with the results * }); * */ -export default function retry(opts, task, callback) { - var DEFAULT_TIMES = 5; - var DEFAULT_INTERVAL = 0; +const DEFAULT_TIMES = 5; +const DEFAULT_INTERVAL = 0; +export default function retry(opts, task, callback) { var options = { times: DEFAULT_TIMES, intervalFunc: constant(DEFAULT_INTERVAL) }; - function parseTimes(acc, t) { - if (typeof t === 'object') { - acc.times = +t.times || DEFAULT_TIMES; - - acc.intervalFunc = typeof t.interval === 'function' ? - t.interval : - constant(+t.interval || DEFAULT_INTERVAL); - - acc.errorFilter = t.errorFilter; - } else if (typeof t === 'number' || typeof t === 'string') { - acc.times = +t || DEFAULT_TIMES; - } else { - throw new Error("Invalid arguments for async.retry"); - } - } - if (arguments.length < 3 && typeof opts === 'function') { - callback = task || noop; + callback = task || promiseCallback(); task = opts; } else { parseTimes(options, opts); - callback = callback || noop; + callback = callback || promiseCallback(); } if (typeof task !== 'function') { throw new Error("Invalid arguments for async.retry"); } + var _task = wrapAsync(task); + var attempt = 1; function retryAttempt() { - task(function(err) { + _task((err, ...args) => { + if (err === false) return if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) { - setTimeout(retryAttempt, options.intervalFunc(attempt)); + setTimeout(retryAttempt, options.intervalFunc(attempt - 1)); } else { - callback.apply(null, arguments); + callback(err, ...args); } }); } retryAttempt(); + return callback[PROMISE_SYMBOL] +} + +function parseTimes(acc, t) { + if (typeof t === 'object') { + acc.times = +t.times || DEFAULT_TIMES; + + acc.intervalFunc = typeof t.interval === 'function' ? + t.interval : + constant(+t.interval || DEFAULT_INTERVAL); + + acc.errorFilter = t.errorFilter; + } else if (typeof t === 'number' || typeof t === 'string') { + acc.times = +t || DEFAULT_TIMES; + } else { + throw new Error("Invalid arguments for async.retry"); + } } diff --git a/lib/retryable.js b/lib/retryable.js index 00fd8f27c..cc7d636fc 100644 --- a/lib/retryable.js +++ b/lib/retryable.js @@ -1,9 +1,12 @@ -import retry from './retry'; -import initialParams from './internal/initialParams'; +import retry from './retry.js' +import initialParams from './internal/initialParams.js' +import {default as wrapAsync, isAsync} from './internal/wrapAsync.js' +import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js' /** - * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method wraps a task and makes it - * retryable, rather than immediately calling it with retries. + * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method + * wraps a task and makes it retryable, rather than immediately calling it + * with retries. * * @name retryable * @static @@ -12,10 +15,14 @@ import initialParams from './internal/initialParams'; * @see [async.retry]{@link module:ControlFlow.retry} * @category Control Flow * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional - * options, exactly the same as from `retry` - * @param {Function} task - the asynchronous function to wrap - * @returns {Functions} The wrapped function, which when invoked, will retry on - * an error, based on the parameters specified in `opts`. + * options, exactly the same as from `retry`, except for a `opts.arity` that + * is the arity of the `task` function, defaulting to `task.length` + * @param {AsyncFunction} task - the asynchronous function to wrap. + * This function will be passed any arguments passed to the returned wrapper. + * Invoked with (...args, callback). + * @returns {AsyncFunction} The wrapped function, which when invoked, will + * retry on an error, based on the parameters specified in `opts`. + * This function will accept the same parameters as `task`. * @example * * async.auto({ @@ -25,18 +32,28 @@ import initialParams from './internal/initialParams'; * })] * }, callback); */ -export default function (opts, task) { +export default function retryable (opts, task) { if (!task) { task = opts; opts = null; } - return initialParams(function (args, callback) { + let arity = (opts && opts.arity) || task.length + if (isAsync(task)) { + arity += 1 + } + var _task = wrapAsync(task); + return initialParams((args, callback) => { + if (args.length < arity - 1 || callback == null) { + args.push(callback) + callback = promiseCallback() + } function taskFn(cb) { - task.apply(null, args.concat([cb])); + _task(...args, cb); } if (opts) retry(opts, taskFn, callback); else retry(taskFn, callback); + return callback[PROMISE_SYMBOL] }); } diff --git a/lib/seq.js b/lib/seq.js index ae4d5c28c..4d9faabcc 100644 --- a/lib/seq.js +++ b/lib/seq.js @@ -1,6 +1,6 @@ -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; -import reduce from './reduce'; +import reduce from './reduce.js' +import wrapAsync from './internal/wrapAsync.js' +import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js' /** * Version of the compose function that is more natural to read. Each function @@ -15,7 +15,7 @@ import reduce from './reduce'; * @method * @see [async.compose]{@link module:ControlFlow.compose} * @category Control Flow - * @param {...Function} functions - the asynchronous functions to compose + * @param {...AsyncFunction} functions - the asynchronous functions to compose * @returns {Function} a function that composes the `functions` in order * @example * @@ -26,7 +26,7 @@ import reduce from './reduce'; * app.get('/cats', function(request, response) { * var User = request.models.User; * async.seq( - * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data)) + * User.get.bind(User), // 'User.get' has signature (id, callback(err, data)) * function(user, fn) { * user.getCats(fn); // 'getCats' has signature (callback(err, data)) * } @@ -40,24 +40,25 @@ import reduce from './reduce'; * }); * }); */ -export default rest(function seq(functions) { - return rest(function(args) { +export default function seq(...functions) { + var _functions = functions.map(wrapAsync); + return function (...args) { var that = this; var cb = args[args.length - 1]; if (typeof cb == 'function') { args.pop(); } else { - cb = noop; + cb = promiseCallback(); } - reduce(functions, args, function(newargs, fn, cb) { - fn.apply(that, newargs.concat([rest(function(err, nextargs) { - cb(err, nextargs); - })])); + reduce(_functions, args, (newargs, fn, iterCb) => { + fn.apply(that, newargs.concat((err, ...nextargs) => { + iterCb(err, nextargs); + })); }, - function(err, results) { - cb.apply(that, [err].concat(results)); - }); - }); -}) + (err, results) => cb(err, ...results)); + + return cb[PROMISE_SYMBOL] + }; +} diff --git a/lib/series.js b/lib/series.js index 7955cf251..7518e6212 100644 --- a/lib/series.js +++ b/lib/series.js @@ -1,5 +1,5 @@ -import parallel from './internal/parallel'; -import eachOfSeries from './eachOfSeries'; +import _parallel from './internal/parallel.js' +import eachOfSeries from './eachOfSeries.js' /** * Run the functions in the `tasks` collection in series, each one running once @@ -27,44 +27,145 @@ import eachOfSeries from './eachOfSeries'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Array|Iterable|Object} tasks - A collection containing functions to run, each - * function is passed a `callback(err, result)` it must call on completion with - * an error `err` (which can be `null`) and an optional `result` value. + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing + * [async functions]{@link AsyncFunction} to run in series. + * Each function can complete with any number of optional `result` values. * @param {Function} [callback] - An optional callback to run once all the * functions have completed. This function gets a results array (or object) * containing all the result arguments passed to the `task` callbacks. Invoked * with (err, result). + * @return {Promise} a promise, if no callback is passed * @example + * + * //Using Callbacks * async.series([ * function(callback) { - * // do some stuff ... - * callback(null, 'one'); + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); * }, * function(callback) { - * // do some more stuff ... - * callback(null, 'two'); + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); * } - * ], - * // optional callback - * function(err, results) { - * // results is now equal to ['one', 'two'] + * ], function(err, results) { + * console.log(results); + * // results is equal to ['one','two'] * }); * + * // an example using objects instead of arrays * async.series({ * one: function(callback) { * setTimeout(function() { + * // do some async task * callback(null, 1); * }, 200); * }, - * two: function(callback){ + * two: function(callback) { * setTimeout(function() { + * // then do another async task * callback(null, 2); * }, 100); * } * }, function(err, results) { - * // results is now equal to: {one: 1, two: 2} + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }); + * + * //Using Promises + * async.series([ + * function(callback) { + * setTimeout(function() { + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * callback(null, 'two'); + * }, 100); + * } + * ]).then(results => { + * console.log(results); + * // results is equal to ['one','two'] + * }).catch(err => { + * console.log(err); * }); + * + * // an example using an object instead of an array + * async.series({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }).then(results => { + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * }).catch(err => { + * console.log(err); + * }); + * + * //Using async/await + * async () => { + * try { + * let results = await async.series([ + * function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 'one'); + * }, 200); + * }, + * function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 'two'); + * }, 100); + * } + * ]); + * console.log(results); + * // results is equal to ['one','two'] + * } + * catch (err) { + * console.log(err); + * } + * } + * + * // an example using an object instead of an array + * async () => { + * try { + * let results = await async.parallel({ + * one: function(callback) { + * setTimeout(function() { + * // do some async task + * callback(null, 1); + * }, 200); + * }, + * two: function(callback) { + * setTimeout(function() { + * // then do another async task + * callback(null, 2); + * }, 100); + * } + * }); + * console.log(results); + * // results is equal to: { one: 1, two: 2 } + * } + * catch (err) { + * console.log(err); + * } + * } + * */ export default function series(tasks, callback) { - parallel(eachOfSeries, tasks, callback); + return _parallel(eachOfSeries, tasks, callback); } diff --git a/lib/setImmediate.js b/lib/setImmediate.js index f820b46d7..8b32339e5 100644 --- a/lib/setImmediate.js +++ b/lib/setImmediate.js @@ -1,4 +1,4 @@ -import setImmediate from './internal/setImmediate'; +import setImmediate from './internal/setImmediate.js' /** * Calls `callback` on a later loop around the event loop. In Node.js this just @@ -12,7 +12,7 @@ import setImmediate from './internal/setImmediate'; * @static * @memberOf module:Utils * @method - * @alias nextTick + * @see [async.nextTick]{@link module:Utils.nextTick} * @category Util * @param {Function} callback - The function to call on a later loop around * the event loop. Invoked with (args...). diff --git a/lib/some.js b/lib/some.js index fd1780f35..0420ea8a1 100644 --- a/lib/some.js +++ b/lib/some.js @@ -1,6 +1,6 @@ -import createTester from './internal/createTester'; -import eachOf from './eachOf'; -import identity from 'lodash/identity'; +import createTester from './internal/createTester.js' +import eachOf from './eachOf.js' +import awaitify from './internal/awaitify.js' /** * Returns `true` if at least one element in the `coll` satisfies an async test. @@ -13,23 +13,93 @@ import identity from 'lodash/identity'; * @method * @alias any * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided * @example * - * async.some(['file1','file2','file3'], function(filePath, callback) { - * fs.access(filePath, function(err) { - * callback(null, !err) - * }); - * }, function(err, result) { - * // if result is true then at least one of the files exists + * // dir1 is a directory that contains file1.txt, file2.txt + * // dir2 is a directory that contains file3.txt, file4.txt + * // dir3 is a directory that contains file5.txt + * // dir4 does not exist + * + * // asynchronous function that checks if a file exists + * function fileExists(file, callback) { + * fs.access(file, fs.constants.F_OK, (err) => { + * callback(null, !err); + * }); + * } + * + * // Using callbacks + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + *); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists, + * function(err, result) { + * console.log(result); + * // false + * // result is false since none of the files exists + * } + *); + * + * // Using Promises + * async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists) + * .then( result => { + * console.log(result); + * // true + * // result is true since some file in the list exists + * }).catch( err => { + * console.log(err); * }); + * + * async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists) + * .then( result => { + * console.log(result); + * // false + * // result is false since none of the files exists + * }).catch( err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir3/file5.txt'], fileExists); + * console.log(result); + * // true + * // result is true since some file in the list exists + * } + * catch (err) { + * console.log(err); + * } + * } + * + * async () => { + * try { + * let result = await async.some(['dir1/missing.txt','dir2/missing.txt','dir4/missing.txt'], fileExists); + * console.log(result); + * // false + * // result is false since none of the files exists + * } + * catch (err) { + * console.log(err); + * } + * } + * */ -export default createTester(eachOf, Boolean, identity); +function some(coll, iteratee, callback) { + return createTester(Boolean, res => res)(eachOf, coll, iteratee, callback) +} +export default awaitify(some, 3); diff --git a/lib/someLimit.js b/lib/someLimit.js index 2ef4f78ed..db0c94be1 100644 --- a/lib/someLimit.js +++ b/lib/someLimit.js @@ -1,6 +1,6 @@ -import createTester from './internal/createTester'; -import eachOfLimit from './eachOfLimit'; -import identity from 'lodash/identity'; +import createTester from './internal/createTester.js' +import eachOfLimit from './internal/eachOfLimit.js' +import awaitify from './internal/awaitify.js' /** * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time. @@ -12,15 +12,19 @@ import identity from 'lodash/identity'; * @see [async.some]{@link module:Collections.some} * @alias anyLimit * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in parallel. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided */ -export default createTester(eachOfLimit, Boolean, identity); +function someLimit(coll, limit, iteratee, callback) { + return createTester(Boolean, res => res)(eachOfLimit(limit), coll, iteratee, callback) +} +export default awaitify(someLimit, 4); diff --git a/lib/someSeries.js b/lib/someSeries.js index 8357a8b16..5f83a12e7 100644 --- a/lib/someSeries.js +++ b/lib/someSeries.js @@ -1,5 +1,6 @@ -import someLimit from './someLimit'; -import doLimit from './internal/doLimit'; +import createTester from './internal/createTester.js' +import eachOfSeries from './eachOfSeries.js' +import awaitify from './internal/awaitify.js' /** * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time. @@ -11,14 +12,18 @@ import doLimit from './internal/doLimit'; * @see [async.some]{@link module:Collections.some} * @alias anySeries * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A truth test to apply to each item in the array - * in parallel. The iteratee is passed a `callback(err, truthValue)` which must - * be called with a boolean argument once it has completed. Invoked with - * (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async truth test to apply to each item + * in the collections in series. + * The iteratee should complete with a boolean `result` value. + * Invoked with (item, callback). * @param {Function} [callback] - A callback which is called as soon as any * iteratee returns `true`, or after all the iteratee functions have finished. * Result will be either `true` or `false` depending on the values of the async * tests. Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided */ -export default doLimit(someLimit, 1); +function someSeries(coll, iteratee, callback) { + return createTester(Boolean, res => res)(eachOfSeries, coll, iteratee, callback) +} +export default awaitify(someSeries, 3); diff --git a/lib/sortBy.js b/lib/sortBy.js index c82920027..bcb347315 100644 --- a/lib/sortBy.js +++ b/lib/sortBy.js @@ -1,7 +1,6 @@ -import arrayMap from 'lodash/_arrayMap'; -import property from 'lodash/_baseProperty'; - -import map from './map'; +import map from './map.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Sorts a list by the results of running each `coll` value through an async @@ -12,52 +11,157 @@ import map from './map'; * @memberOf module:Collections * @method * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. - * @param {Function} iteratee - A function to apply to each item in `coll`. - * The iteratee is passed a `callback(err, sortValue)` which must be called once - * it has completed with an error (which can be `null`) and a value to use as - * the sort criteria. Invoked with (item, callback). + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. + * @param {AsyncFunction} iteratee - An async function to apply to each item in + * `coll`. + * The iteratee should complete with a value to use as the sort criteria as + * its `result`. + * Invoked with (item, callback). * @param {Function} callback - A callback which is called after all the * `iteratee` functions have finished, or an error occurs. Results is the items * from the original `coll` sorted by the values returned by the `iteratee` * calls. Invoked with (err, results). + * @returns {Promise} a promise, if no callback passed * @example * - * async.sortBy(['file1','file2','file3'], function(file, callback) { - * fs.stat(file, function(err, stats) { - * callback(err, stats.mtime); + * // bigfile.txt is a file that is 251100 bytes in size + * // mediumfile.txt is a file that is 11000 bytes in size + * // smallfile.txt is a file that is 121 bytes in size + * + * // asynchronous function that returns the file size in bytes + * function getFileSizeInBytes(file, callback) { + * fs.stat(file, function(err, stat) { + * if (err) { + * return callback(err); + * } + * callback(null, stat.size); * }); - * }, function(err, results) { - * // results is now the original array of files sorted by - * // modified date - * }); + * } + * + * // Using callbacks + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); * * // By modifying the callback parameter the * // sorting order can be influenced: * * // ascending order - * async.sortBy([1,9,3,5], function(x, callback) { - * callback(null, x); - * }, function(err,result) { - * // result callback - * }); + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) return callback(getFileSizeErr); + * callback(null, fileSize); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * } + * ); * * // descending order - * async.sortBy([1,9,3,5], function(x, callback) { - * callback(null, x*-1); //<- x*-1 instead of x, turns the order around - * }, function(err,result) { - * // result callback + * async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], function(file, callback) { + * getFileSizeInBytes(file, function(getFileSizeErr, fileSize) { + * if (getFileSizeErr) { + * return callback(getFileSizeErr); + * } + * callback(null, fileSize * -1); + * }); + * }, function(err, results) { + * if (err) { + * console.log(err); + * } else { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'bigfile.txt', 'mediumfile.txt', 'smallfile.txt'] + * } + * } + * ); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes, + * function(err, results) { + * if (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } else { + * console.log(results); + * } + * } + * ); + * + * // Using Promises + * async.sortBy(['mediumfile.txt','smallfile.txt','bigfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * }).catch( err => { + * console.log(err); * }); + * + * // Error handling + * async.sortBy(['mediumfile.txt','smallfile.txt','missingfile.txt'], getFileSizeInBytes) + * .then( results => { + * console.log(results); + * }).catch( err => { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * }); + * + * // Using async/await + * (async () => { + * try { + * let results = await async.sortBy(['bigfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * // results is now the original array of files sorted by + * // file size (ascending by default), e.g. + * // [ 'smallfile.txt', 'mediumfile.txt', 'bigfile.txt'] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * + * // Error handling + * async () => { + * try { + * let results = await async.sortBy(['missingfile.txt','mediumfile.txt','smallfile.txt'], getFileSizeInBytes); + * console.log(results); + * } + * catch (err) { + * console.log(err); + * // [ Error: ENOENT: no such file or directory ] + * } + * } + * */ -export default function sortBy (coll, iteratee, callback) { - map(coll, function (x, callback) { - iteratee(x, function (err, criteria) { - if (err) return callback(err); - callback(null, {value: x, criteria: criteria}); +function sortBy (coll, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return map(coll, (x, iterCb) => { + _iteratee(x, (err, criteria) => { + if (err) return iterCb(err); + iterCb(err, {value: x, criteria}); }); - }, function (err, results) { + }, (err, results) => { if (err) return callback(err); - callback(null, arrayMap(results.sort(comparator), property('value'))); + callback(null, results.sort(comparator).map(v => v.value)); }); function comparator(left, right) { @@ -65,3 +169,4 @@ export default function sortBy (coll, iteratee, callback) { return a < b ? -1 : a > b ? 1 : 0; } } +export default awaitify(sortBy, 3) diff --git a/lib/timeout.js b/lib/timeout.js index 93fe2e1c5..35ef497d3 100644 --- a/lib/timeout.js +++ b/lib/timeout.js @@ -1,4 +1,5 @@ -import initialParams from './internal/initialParams'; +import initialParams from './internal/initialParams.js' +import wrapAsync from './internal/wrapAsync.js' /** * Sets a time limit on an asynchronous function. If the function does not call @@ -10,14 +11,13 @@ import initialParams from './internal/initialParams'; * @memberOf module:Utils * @method * @category Util - * @param {Function} asyncFn - The asynchronous function you want to set the - * time limit. + * @param {AsyncFunction} asyncFn - The async function to limit in time. * @param {number} milliseconds - The specified time limit. * @param {*} [info] - Any variable you want attached (`string`, `object`, etc) * to timeout Error for more information.. - * @returns {Function} Returns a wrapped function that can be used with any of - * the control flow functions. Invoke this function with the same - * parameters as you would `asyncFunc`. + * @returns {AsyncFunction} Returns a wrapped function that can be used with any + * of the control flow functions. + * Invoke this function with the same parameters as you would `asyncFunc`. * @example * * function myFunction(foo, callback) { @@ -43,31 +43,32 @@ import initialParams from './internal/initialParams'; * }); */ export default function timeout(asyncFn, milliseconds, info) { - var originalCallback, timer; - var timedOut = false; + var fn = wrapAsync(asyncFn); - function injectedCallback() { - if (!timedOut) { - originalCallback.apply(null, arguments); - clearTimeout(timer); - } - } + return initialParams((args, callback) => { + var timedOut = false; + var timer; - function timeoutCallback() { - var name = asyncFn.name || 'anonymous'; - var error = new Error('Callback function "' + name + '" timed out.'); - error.code = 'ETIMEDOUT'; - if (info) { - error.info = info; + function timeoutCallback() { + var name = asyncFn.name || 'anonymous'; + var error = new Error('Callback function "' + name + '" timed out.'); + error.code = 'ETIMEDOUT'; + if (info) { + error.info = info; + } + timedOut = true; + callback(error); } - timedOut = true; - originalCallback(error); - } - return initialParams(function (args, origCallback) { - originalCallback = origCallback; + args.push((...cbArgs) => { + if (!timedOut) { + callback(...cbArgs); + clearTimeout(timer); + } + }); + // setup timer and call original function timer = setTimeout(timeoutCallback, milliseconds); - asyncFn.apply(null, args.concat(injectedCallback)); + fn(...args); }); } diff --git a/lib/times.js b/lib/times.js index bdd2e6b34..beba1e4e8 100644 --- a/lib/times.js +++ b/lib/times.js @@ -1,5 +1,4 @@ -import timesLimit from './timesLimit'; -import doLimit from './internal/doLimit'; +import timesLimit from './timesLimit.js' /** * Calls the `iteratee` function `n` times, and accumulates results in the same @@ -12,9 +11,10 @@ import doLimit from './internal/doLimit'; * @see [async.map]{@link module:Collections.map} * @category Control Flow * @param {number} n - The number of times to run the function. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided * @example * * // Pretend this is some complicated async factory @@ -33,4 +33,6 @@ import doLimit from './internal/doLimit'; * // we should now have 5 users * }); */ -export default doLimit(timesLimit, Infinity); +export default function times (n, iteratee, callback) { + return timesLimit(n, Infinity, iteratee, callback) +} diff --git a/lib/timesLimit.js b/lib/timesLimit.js index 68d5edee4..4d8d23779 100644 --- a/lib/timesLimit.js +++ b/lib/timesLimit.js @@ -1,5 +1,6 @@ -import mapLimit from './mapLimit'; -import range from 'lodash/_baseRange'; +import mapLimit from './mapLimit.js' +import range from './internal/range.js' +import wrapAsync from './internal/wrapAsync.js' /** * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a @@ -13,10 +14,12 @@ import range from 'lodash/_baseRange'; * @category Control Flow * @param {number} count - The number of times to run the function. * @param {number} limit - The maximum number of async operations at a time. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). * @param {Function} callback - see [async.map]{@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided */ -export default function timeLimit(count, limit, iteratee, callback) { - mapLimit(range(0, count, 1), limit, iteratee, callback); +export default function timesLimit(count, limit, iteratee, callback) { + var _iteratee = wrapAsync(iteratee); + return mapLimit(range(count), limit, _iteratee, callback); } diff --git a/lib/timesSeries.js b/lib/timesSeries.js index 672428d18..d16b1a252 100644 --- a/lib/timesSeries.js +++ b/lib/timesSeries.js @@ -1,5 +1,4 @@ -import timesLimit from './timesLimit'; -import doLimit from './internal/doLimit'; +import timesLimit from './timesLimit.js' /** * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time. @@ -11,8 +10,11 @@ import doLimit from './internal/doLimit'; * @see [async.times]{@link module:ControlFlow.times} * @category Control Flow * @param {number} n - The number of times to run the function. - * @param {Function} iteratee - The function to call `n` times. Invoked with the - * iteration index and a callback (n, next). + * @param {AsyncFunction} iteratee - The async function to call `n` times. + * Invoked with the iteration index and a callback: (n, next). * @param {Function} callback - see {@link module:Collections.map}. + * @returns {Promise} a promise, if no callback is provided */ -export default doLimit(timesLimit, 1); +export default function timesSeries (n, iteratee, callback) { + return timesLimit(n, 1, iteratee, callback) +} diff --git a/lib/transform.js b/lib/transform.js index 5d1342a06..a835103e8 100644 --- a/lib/transform.js +++ b/lib/transform.js @@ -1,12 +1,11 @@ -import isArray from 'lodash/isArray'; -import noop from 'lodash/noop'; - -import eachOf from './eachOf'; -import once from './internal/once'; +import eachOf from './eachOf.js' +import once from './internal/once.js' +import wrapAsync from './internal/wrapAsync.js' +import { promiseCallback, PROMISE_SYMBOL } from './internal/promiseCallback.js' /** * A relative of `reduce`. Takes an Object or Array, and iterates over each - * element in series, each step potentially mutating an `accumulator` value. + * element in parallel, each step potentially mutating an `accumulator` value. * The type of the accumulator defaults to the type of collection passed in. * * @name transform @@ -14,52 +13,142 @@ import once from './internal/once'; * @memberOf module:Collections * @method * @category Collection - * @param {Array|Iterable|Object} coll - A collection to iterate over. + * @param {Array|Iterable|AsyncIterable|Object} coll - A collection to iterate over. * @param {*} [accumulator] - The initial state of the transform. If omitted, * it will default to an empty Object or Array, depending on the type of `coll` - * @param {Function} iteratee - A function applied to each item in the - * collection that potentially modifies the accumulator. The `iteratee` is - * passed a `callback(err)` which accepts an optional error as its first - * argument. If an error is passed to the callback, the transform is stopped - * and the main `callback` is immediately called with the error. + * @param {AsyncFunction} iteratee - A function applied to each item in the + * collection that potentially modifies the accumulator. * Invoked with (accumulator, item, key, callback). * @param {Function} [callback] - A callback which is called after all the * `iteratee` functions have finished. Result is the transformed accumulator. * Invoked with (err, result). + * @returns {Promise} a promise, if no callback provided * @example * - * async.transform([1,2,3], function(acc, item, index, callback) { - * // pointless async: - * process.nextTick(function() { - * acc.push(item * 2) - * callback(null) + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileList = ['file1.txt','file2.txt','file3.txt']; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); * }); - * }, function(err, result) { - * // result is now equal to [2, 4, 6] + * } + * + * // Using callbacks + * async.transform(fileList, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } * }); * + * // Using Promises + * async.transform(fileList, transformFileSize) + * .then(result => { + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * (async () => { + * try { + * let result = await async.transform(fileList, transformFileSize); + * console.log(result); + * // [ '1000 Bytes', '1.95 KB', '2.93 KB' ] + * } + * catch (err) { + * console.log(err); + * } + * })(); + * * @example * - * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) { - * setImmediate(function () { - * obj[key] = val * 2; - * callback(); - * }) - * }, function (err, result) { - * // result is equal to {a: 2, b: 4, c: 6} - * }) + * // file1.txt is a file that is 1000 bytes in size + * // file2.txt is a file that is 2000 bytes in size + * // file3.txt is a file that is 3000 bytes in size + * + * // helper function that returns human-readable size format from bytes + * function formatBytes(bytes, decimals = 2) { + * // implementation not included for brevity + * return humanReadbleFilesize; + * } + * + * const fileMap = { f1: 'file1.txt', f2: 'file2.txt', f3: 'file3.txt' }; + * + * // asynchronous function that returns the file size, transformed to human-readable format + * // e.g. 1024 bytes = 1KB, 1234 bytes = 1.21 KB, 1048576 bytes = 1MB, etc. + * function transformFileSize(acc, value, key, callback) { + * fs.stat(value, function(err, stat) { + * if (err) { + * return callback(err); + * } + * acc[key] = formatBytes(stat.size); + * callback(null); + * }); + * } + * + * // Using callbacks + * async.transform(fileMap, transformFileSize, function(err, result) { + * if(err) { + * console.log(err); + * } else { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * }); + * + * // Using Promises + * async.transform(fileMap, transformFileSize) + * .then(result => { + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * }).catch(err => { + * console.log(err); + * }); + * + * // Using async/await + * async () => { + * try { + * let result = await async.transform(fileMap, transformFileSize); + * console.log(result); + * // { f1: '1000 Bytes', f2: '1.95 KB', f3: '2.93 KB' } + * } + * catch (err) { + * console.log(err); + * } + * } + * */ export default function transform (coll, accumulator, iteratee, callback) { - if (arguments.length === 3) { + if (arguments.length <= 3 && typeof accumulator === 'function') { callback = iteratee; iteratee = accumulator; - accumulator = isArray(coll) ? [] : {}; + accumulator = Array.isArray(coll) ? [] : {}; } - callback = once(callback || noop); + callback = once(callback || promiseCallback()); + var _iteratee = wrapAsync(iteratee); - eachOf(coll, function(v, k, cb) { - iteratee(accumulator, v, k, cb); - }, function(err) { - callback(err, accumulator); - }); + eachOf(coll, (v, k, cb) => { + _iteratee(accumulator, v, k, cb); + }, err => callback(err, accumulator)); + return callback[PROMISE_SYMBOL] } diff --git a/lib/tryEach.js b/lib/tryEach.js new file mode 100644 index 000000000..8fa314b1f --- /dev/null +++ b/lib/tryEach.js @@ -0,0 +1,61 @@ +import eachSeries from './eachSeries.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' + +/** + * It runs each task in series but stops whenever any of the functions were + * successful. If one of the tasks were successful, the `callback` will be + * passed the result of the successful task. If all tasks fail, the callback + * will be passed the error and result (if any) of the final attempt. + * + * @name tryEach + * @static + * @memberOf module:ControlFlow + * @method + * @category Control Flow + * @param {Array|Iterable|AsyncIterable|Object} tasks - A collection containing functions to + * run, each function is passed a `callback(err, result)` it must call on + * completion with an error `err` (which can be `null`) and an optional `result` + * value. + * @param {Function} [callback] - An optional callback which is called when one + * of the tasks has succeeded, or all have failed. It receives the `err` and + * `result` arguments of the last attempt at completing the `task`. Invoked with + * (err, results). + * @returns {Promise} a promise, if no callback is passed + * @example + * async.tryEach([ + * function getDataFromFirstWebsite(callback) { + * // Try getting the data from the first website + * callback(err, data); + * }, + * function getDataFromSecondWebsite(callback) { + * // First website failed, + * // Try getting the data from the backup website + * callback(err, data); + * } + * ], + * // optional callback + * function(err, results) { + * Now do something with the data. + * }); + * + */ +function tryEach(tasks, callback) { + var error = null; + var result; + return eachSeries(tasks, (task, taskCb) => { + wrapAsync(task)((err, ...args) => { + if (err === false) return taskCb(err); + + if (args.length < 2) { + [result] = args; + } else { + result = args; + } + error = err; + taskCb(err ? null : {}); + }); + }, () => callback(error, result)); +} + +export default awaitify(tryEach) diff --git a/lib/unmemoize.js b/lib/unmemoize.js index 4b2db4dc8..62966c0e8 100644 --- a/lib/unmemoize.js +++ b/lib/unmemoize.js @@ -8,11 +8,11 @@ * @method * @see [async.memoize]{@link module:Utils.memoize} * @category Util - * @param {Function} fn - the memoized function - * @returns {Function} a function that calls the original unmemoized function + * @param {AsyncFunction} fn - the memoized function + * @returns {AsyncFunction} a function that calls the original unmemoized function */ export default function unmemoize(fn) { - return function () { - return (fn.unmemoized || fn).apply(null, arguments); + return (...args) => { + return (fn.unmemoized || fn)(...args); }; } diff --git a/lib/until.js b/lib/until.js index 7b0b0b5ec..fb6ce1731 100644 --- a/lib/until.js +++ b/lib/until.js @@ -1,9 +1,10 @@ -import whilst from './whilst'; +import whilst from './whilst.js' +import wrapAsync from './internal/wrapAsync.js' /** - * Repeatedly call `fn` until `test` returns `true`. Calls `callback` when + * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when * stopped, or an error occurs. `callback` will be passed an error and any - * arguments passed to the final `fn`'s callback. + * arguments passed to the final `iteratee`'s callback. * * The inverse of [whilst]{@link module:ControlFlow.whilst}. * @@ -13,18 +14,33 @@ import whilst from './whilst'; * @method * @see [async.whilst]{@link module:ControlFlow.whilst} * @category Control Flow - * @param {Function} test - synchronous truth test to perform before each - * execution of `fn`. Invoked with (). - * @param {Function} fn - A function which is called each time `test` fails. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` fails. Invoked with (callback). * @param {Function} [callback] - A callback which is called after the test - * function has passed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s + * function has passed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s * callback. Invoked with (err, [results]); + * @returns {Promise} a promise, if a callback is not passed + * + * @example + * const results = [] + * let finished = false + * async.until(function test(cb) { + * cb(null, finished) + * }, function iter(next) { + * fetchPage(url, (err, body) => { + * if (err) return next(err) + * results = results.concat(body.objects) + * finished = !!body.next + * next(err) + * }) + * }, function done (err) { + * // all pages have been fetched + * }) */ -export default function until(test, fn, callback) { - whilst(function() { - return !test.apply(this, arguments); - }, fn, callback); +export default function until(test, iteratee, callback) { + const _test = wrapAsync(test) + return whilst((cb) => _test((err, truth) => cb (err, !truth)), iteratee, callback); } diff --git a/lib/waterfall.js b/lib/waterfall.js index 3d2ba55af..e29ea42de 100644 --- a/lib/waterfall.js +++ b/lib/waterfall.js @@ -1,9 +1,7 @@ -import isArray from 'lodash/isArray'; -import noop from 'lodash/noop'; -import once from './internal/once'; -import rest from 'lodash/_baseRest'; - -import onlyOnce from './internal/onlyOnce'; +import once from './internal/once.js' +import onlyOnce from './internal/onlyOnce.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** * Runs the `tasks` array of functions in series, each passing their results to @@ -16,14 +14,14 @@ import onlyOnce from './internal/onlyOnce'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Array} tasks - An array of functions to run, each function is passed - * a `callback(err, result1, result2, ...)` it must call on completion. The - * first argument is an error (which can be `null`) and any further arguments - * will be passed as arguments in order to the next task. + * @param {Array} tasks - An array of [async functions]{@link AsyncFunction} + * to run. + * Each function should complete with any number of `result` values. + * The `result` values will be passed as arguments, in order, to the next task. * @param {Function} [callback] - An optional callback to run once all the * functions have completed. This will be passed the results of the last task's * callback. Invoked with (err, [results]). - * @returns undefined + * @returns {Promise} a promise, if a callback is omitted * @example * * async.waterfall([ @@ -62,29 +60,26 @@ import onlyOnce from './internal/onlyOnce'; * callback(null, 'done'); * } */ -export default function(tasks, callback) { - callback = once(callback || noop); - if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); +function waterfall (tasks, callback) { + callback = once(callback); + if (!Array.isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions')); if (!tasks.length) return callback(); var taskIndex = 0; function nextTask(args) { - if (taskIndex === tasks.length) { - return callback.apply(null, [null].concat(args)); - } - - var taskCallback = onlyOnce(rest(function(err, args) { - if (err) { - return callback.apply(null, [err].concat(args)); - } - nextTask(args); - })); - - args.push(taskCallback); + var task = wrapAsync(tasks[taskIndex++]); + task(...args, onlyOnce(next)); + } - var task = tasks[taskIndex++]; - task.apply(null, args); + function next(err, ...args) { + if (err === false) return + if (err || taskIndex === tasks.length) { + return callback(err, ...args); + } + nextTask(args); } nextTask([]); } + +export default awaitify(waterfall) diff --git a/lib/whilst.js b/lib/whilst.js index 31c5c8261..5bc5067ee 100644 --- a/lib/whilst.js +++ b/lib/whilst.js @@ -1,10 +1,9 @@ -import noop from 'lodash/noop'; -import rest from 'lodash/_baseRest'; - -import onlyOnce from './internal/onlyOnce'; +import onlyOnce from './internal/onlyOnce.js' +import wrapAsync from './internal/wrapAsync.js' +import awaitify from './internal/awaitify.js' /** - * Repeatedly call `fn`, while `test` returns `true`. Calls `callback` when + * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when * stopped, or an error occurs. * * @name whilst @@ -12,22 +11,21 @@ import onlyOnce from './internal/onlyOnce'; * @memberOf module:ControlFlow * @method * @category Control Flow - * @param {Function} test - synchronous truth test to perform before each - * execution of `fn`. Invoked with (). - * @param {Function} iteratee - A function which is called each time `test` passes. - * The function is passed a `callback(err)`, which must be called once it has - * completed with an optional `err` argument. Invoked with (callback). + * @param {AsyncFunction} test - asynchronous truth test to perform before each + * execution of `iteratee`. Invoked with (callback). + * @param {AsyncFunction} iteratee - An async function which is called each time + * `test` passes. Invoked with (callback). * @param {Function} [callback] - A callback which is called after the test - * function has failed and repeated execution of `fn` has stopped. `callback` - * will be passed an error and any arguments passed to the final `fn`'s + * function has failed and repeated execution of `iteratee` has stopped. `callback` + * will be passed an error and any arguments passed to the final `iteratee`'s * callback. Invoked with (err, [results]); - * @returns undefined + * @returns {Promise} a promise, if no callback is passed * @example * * var count = 0; * async.whilst( - * function() { return count < 5; }, - * function(callback) { + * function test(cb) { cb(null, count < 5); }, + * function iter(callback) { * count++; * setTimeout(function() { * callback(null, count); @@ -38,13 +36,26 @@ import onlyOnce from './internal/onlyOnce'; * } * ); */ -export default function whilst(test, iteratee, callback) { - callback = onlyOnce(callback || noop); - if (!test()) return callback(null); - var next = rest(function(err, args) { +function whilst(test, iteratee, callback) { + callback = onlyOnce(callback); + var _fn = wrapAsync(iteratee); + var _test = wrapAsync(test); + var results = []; + + function next(err, ...rest) { if (err) return callback(err); - if (test()) return iteratee(next); - callback.apply(null, [null].concat(args)); - }); - iteratee(next); + results = rest; + if (err === false) return; + _test(check); + } + + function check(err, truth) { + if (err) return callback(err); + if (err === false) return; + if (!truth) return callback(null, ...results); + _fn(next); + } + + return _test(check); } +export default awaitify(whilst, 3) diff --git a/mocha_test/applyEach.js b/mocha_test/applyEach.js deleted file mode 100644 index 6138d3fce..000000000 --- a/mocha_test/applyEach.js +++ /dev/null @@ -1,99 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('applyEach', function () { - - it('applyEach', function (done) { - var call_order = []; - var one = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('one'); - cb(null, 1); - }, 10); - }; - var two = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('two'); - cb(null, 2); - }, 5); - }; - var three = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('three'); - cb(null, 3); - }, 15); - }; - async.applyEach([one, two, three], 5, function (err, results) { - assert(err === null, err + " passed instead of 'null'"); - expect(call_order).to.eql(['two', 'one', 'three']); - expect(results).to.eql([1, 2, 3]); - done(); - }); - }); - - it('applyEachSeries', function (done) { - var call_order = []; - var one = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('one'); - cb(null, 1); - }, 10); - }; - var two = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('two'); - cb(null, 2); - }, 5); - }; - var three = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('three'); - cb(null, 3); - }, 15); - }; - async.applyEachSeries([one, two, three], 5, function (err, results) { - assert(err === null, err + " passed instead of 'null'"); - expect(call_order).to.eql(['one', 'two', 'three']); - expect(results).to.eql([1, 2, 3]); - done(); - }); - }); - - it('applyEach partial application', function (done) { - var call_order = []; - var one = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('one'); - cb(null, 1); - }, 10); - }; - var two = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('two'); - cb(null, 2); - }, 5); - }; - var three = function (val, cb) { - expect(val).to.equal(5); - setTimeout(function () { - call_order.push('three'); - cb(null, 3); - }, 15); - }; - async.applyEach([one, two, three])(5, function (err, results) { - if (err) throw err; - expect(call_order).to.eql(['two', 'one', 'three']); - expect(results).to.eql([1, 2, 3]); - done(); - }); - }); -}); diff --git a/mocha_test/asyncify.js b/mocha_test/asyncify.js deleted file mode 100644 index a98826cd5..000000000 --- a/mocha_test/asyncify.js +++ /dev/null @@ -1,138 +0,0 @@ -var async = require('../lib'); -var assert = require('assert'); -var expect = require('chai').expect; - -describe('asyncify', function(){ - - it('asyncify', function(done) { - var parse = async.asyncify(JSON.parse); - parse("{\"a\":1}", function (err, result) { - assert(!err); - expect(result.a).to.equal(1); - done(); - }); - }); - - it('asyncify null', function(done) { - var parse = async.asyncify(function() { - return null; - }); - parse("{\"a\":1}", function (err, result) { - assert(!err); - expect(result).to.equal(null); - done(); - }); - }); - - it('variable numbers of arguments', function(done) { - async.asyncify(function (/*x, y, z*/) { - return arguments; - })(1, 2, 3, function (err, result) { - expect(result.length).to.equal(3); - expect(result[0]).to.equal(1); - expect(result[1]).to.equal(2); - expect(result[2]).to.equal(3); - done(); - }); - }); - - it('catch errors', function(done) { - async.asyncify(function () { - throw new Error("foo"); - })(function (err) { - assert(err); - expect(err.message).to.equal("foo"); - done(); - }); - }); - - it('dont catch errors in the callback', function(done) { - try { - async.asyncify(function () {})(function (err) { - if (err) { - return done(new Error("should not get an error here")); - } - throw new Error("callback error"); - }); - } catch (err) { - expect(err.message).to.equal("callback error"); - done(); - } - }); - - describe('promisified', function() { - function promisifiedTests(Promise) { - it('resolve', function(done) { - var promisified = function(argument) { - return new Promise(function (resolve) { - setTimeout(function () { - resolve(argument + " resolved"); - }, 15); - }); - }; - async.asyncify(promisified)("argument", function (err, value) { - if (err) { - return done(new Error("should not get an error here")); - } - expect(value).to.equal("argument resolved"); - done(); - }); - }); - - it('reject', function(done) { - var promisified = function(argument) { - return new Promise(function (resolve, reject) { - reject(argument + " rejected"); - }); - }; - async.asyncify(promisified)("argument", function (err) { - assert(err); - expect(err.message).to.equal("argument rejected"); - done(); - }); - }); - - it('callback error', function(done) { - var promisified = function(argument) { - return new Promise(function (resolve) { - resolve(argument + " resolved"); - }); - }; - var call_count = 0; - async.asyncify(promisified)("argument", function () { - call_count++; - if (call_count === 1) { - throw new Error("error in callback"); - } - }); - setTimeout(function () { - expect(call_count).to.equal(1); - done(); - }, 15); - }); - } - - describe('native-promise-only', function() { - var Promise = require('native-promise-only'); - promisifiedTests.call(this, Promise); - }); - - describe('bluebird', function() { - var Promise = require('bluebird'); - // Bluebird reports unhandled rejections to stderr. We handle it because we expect - // unhandled rejections: - Promise.onPossiblyUnhandledRejection(function ignoreRejections() {}); - promisifiedTests.call(this, Promise); - }); - - describe('es6-promise', function() { - var Promise = require('es6-promise').Promise; - promisifiedTests.call(this, Promise); - }); - - describe('rsvp', function() { - var Promise = require('rsvp').Promise; - promisifiedTests.call(this, Promise); - }); - }); -}); diff --git a/mocha_test/autoInject.js b/mocha_test/autoInject.js deleted file mode 100644 index 9c2d1fbe4..000000000 --- a/mocha_test/autoInject.js +++ /dev/null @@ -1,160 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe('autoInject', function () { - - it("basics", function (done) { - var callOrder = []; - async.autoInject({ - task1: function(task2, callback){ - expect(task2).to.equal(2); - setTimeout(function(){ - callOrder.push('task1'); - callback(null, 1); - }, 25); - }, - task2: function(callback){ - setTimeout(function(){ - callOrder.push('task2'); - callback(null, 2); - }, 50); - }, - task3: function(task2, callback){ - expect(task2).to.equal(2); - callOrder.push('task3'); - callback(null, 3); - }, - task4: function(task1, task2, callback){ - expect(task1).to.equal(1); - expect(task2).to.equal(2); - callOrder.push('task4'); - callback(null, 4); - }, - task5: function(task2, callback){ - expect(task2).to.equal(2); - setTimeout(function(){ - callOrder.push('task5'); - callback(null, 5); - }, 0); - }, - task6: function(task2, callback){ - expect(task2).to.equal(2); - callOrder.push('task6'); - callback(null, 6); - } - }, - function(err, results){ - expect(results.task6).to.equal(6); - expect(callOrder).to.eql(['task2','task3','task6','task5','task1','task4']); - done(); - }); - }); - - it('should work with array tasks', function (done) { - var callOrder = []; - - async.autoInject({ - task1: function (cb) { - callOrder.push('task1'); - cb(null, 1); - }, - task2: ['task3', function ( task3 , cb ) { - expect(task3).to.equal(3); - callOrder.push('task2'); - cb(null, 2); - }], - task3: function (cb) { - callOrder.push('task3'); - cb(null, 3); - } - }, function () { - expect(callOrder).to.eql(['task1','task3','task2']); - done(); - }); - }); - - it('should handle array tasks with just a function', function (done) { - async.autoInject({ - a: [function (cb) { - cb(null, 1); - }], - b: ["a", function (a, cb) { - expect(a).to.equal(1); - cb(); - }] - }, done); - }); - - it('should throw error for function without explicit parameters', function (done) { - try { - async.autoInject({ - a: function (){} - }); - } catch (e) { - // It's ok. It detected a void function - return done(); - } - - // If didn't catch error, then it's a failed test - done(true) - }); - - var arrowSupport = true; - try { - new Function('x => x'); - } catch (e) { - arrowSupport = false; - } - - if (arrowSupport) { - // Needs to be run on ES6 only - - /* eslint {no-eval: 0}*/ - eval("(function() { " + - " it('should work with es6 arrow syntax', function (done) { " + - " async.autoInject({ " + - " task1: (cb) => cb(null, 1), " + - " task2: ( task3 , cb ) => cb(null, 2), " + - " task3: cb => cb(null, 3) " + - " }, (err, results) => { " + - " expect(results.task1).to.equal(1); " + - " expect(results.task3).to.equal(3); " + - " done(); " + - " }); " + - " }); " + - "}) " - )(); - } - - - var defaultSupport = true; - try { - eval('function x(y = 1){ return y }'); - }catch (e){ - defaultSupport = false; - } - - if(arrowSupport && defaultSupport){ - // Needs to be run on ES6 only - - /* eslint {no-eval: 0}*/ - eval("(function() { " + - " it('should work with es6 obj method syntax', function (done) { " + - " async.autoInject({ " + - " task1 (cb){ cb(null, 1) }, " + - " task2 ( task3 , cb ) { cb(null, 2) }, " + - " task3 (cb) { cb(null, 3) }, " + - " task4 ( task2 , cb ) { cb(null) }, " + - " task5 ( task4 = 4 , cb ) { cb(null, task4 + 1) } " + - " }, (err, results) => { " + - " expect(results.task1).to.equal(1); " + - " expect(results.task3).to.equal(3); " + - " expect(results.task4).to.equal(undefined); " + - " expect(results.task5).to.equal(5); " + - " done(); " + - " }); " + - " }); " + - "}) " - )(); - } -}); diff --git a/mocha_test/concat.js b/mocha_test/concat.js deleted file mode 100644 index 389b2de75..000000000 --- a/mocha_test/concat.js +++ /dev/null @@ -1,57 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('concat', function() { - it('concat', function(done) { - var call_order = []; - var iteratee = function (x, cb) { - setTimeout(function(){ - call_order.push(x); - var r = []; - while (x > 0) { - r.push(x); - x--; - } - cb(null, r); - }, x*25); - }; - async.concat([1,3,2], iteratee, function(err, results){ - expect(results).to.eql([1,2,1,3,2,1]); - expect(call_order).to.eql([1,2,3]); - assert(err === null, err + " passed instead of 'null'"); - done(); - }); - }); - - it('concat error', function(done) { - var iteratee = function (x, cb) { - cb(new Error('test error')); - }; - async.concat([1,2,3], iteratee, function(err){ - assert(err); - done(); - }); - }); - - it('concatSeries', function(done) { - var call_order = []; - var iteratee = function (x, cb) { - setTimeout(function(){ - call_order.push(x); - var r = []; - while (x > 0) { - r.push(x); - x--; - } - cb(null, r); - }, x*25); - }; - async.concatSeries([1,3,2], iteratee, function(err, results){ - expect(results).to.eql([1,3,2,1,2,1]); - expect(call_order).to.eql([1,3,2]); - assert(err === null, err + " passed instead of 'null'"); - done(); - }); - }); -}); diff --git a/mocha_test/detect.js b/mocha_test/detect.js deleted file mode 100644 index f30848520..000000000 --- a/mocha_test/detect.js +++ /dev/null @@ -1,151 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe("detect", function () { - - function detectIteratee(call_order, x, callback) { - setTimeout(function(){ - call_order.push(x); - callback(null, x == 2); - }, x*5); - } - - it('detect', function(done){ - var call_order = []; - async.detect([3,2,1], detectIteratee.bind(this, call_order), function(err, result){ - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function(){ - expect(call_order).to.eql([1,2,'callback',3]); - done(); - }, 25); - }); - - it('detect - mulitple matches', function(done){ - var call_order = []; - async.detect([3,2,2,1,2], detectIteratee.bind(this, call_order), function(err, result){ - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function(){ - expect(call_order).to.eql([1,2,'callback',2,2,3]); - done(); - }, 25); - }); - - it('detect error', function(done){ - async.detect([3,2,1], function(x, callback) { - setTimeout(function(){callback('error');}, 0); - }, function(err, result){ - expect(err).to.equal('error'); - expect(result).to.not.exist; - done(); - }); - }); - - it('detectSeries', function(done){ - var call_order = []; - async.detectSeries([3,2,1], detectIteratee.bind(this, call_order), function(err, result){ - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function(){ - expect(call_order).to.eql([3,2,'callback']); - done(); - }, 50); - }); - - it('detectSeries - multiple matches', function(done){ - var call_order = []; - async.detectSeries([3,2,2,1,2], detectIteratee.bind(this, call_order), function(err, result){ - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function(){ - expect(call_order).to.eql([3,2,'callback']); - done(); - }, 50); - }); - - it('detect no callback', function(done) { - var calls = []; - - async.detect([1, 2, 3], function (val, cb) { - calls.push(val); - cb(); - }); - - setTimeout(function () { - expect(calls).to.eql([1, 2, 3]); - done(); - }, 10); - }); - - it('detectSeries - ensure stop', function (done) { - async.detectSeries([1, 2, 3, 4, 5], function (num, cb) { - if (num > 3) throw new Error("detectSeries did not stop iterating"); - cb(null, num === 3); - }, function (err, result) { - expect(err).to.equal(null); - expect(result).to.equal(3); - done(); - }); - }); - - it('detectLimit', function(done){ - var call_order = []; - async.detectLimit([3, 2, 1], 2, detectIteratee.bind(this, call_order), function(err, result) { - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function() { - expect(call_order).to.eql([2, 'callback', 3]); - done(); - }, 50); - }); - - it('detectLimit - multiple matches', function(done){ - var call_order = []; - async.detectLimit([3,2,2,1,2], 2, detectIteratee.bind(this, call_order), function(err, result){ - call_order.push('callback'); - expect(err).to.equal(null); - expect(result).to.equal(2); - }); - setTimeout(function(){ - expect(call_order).to.eql([2, 'callback', 3]); - done(); - }, 50); - }); - - it('detectLimit - ensure stop', function (done) { - async.detectLimit([1, 2, 3, 4, 5], 2, function (num, cb) { - if (num > 4) throw new Error("detectLimit did not stop iterating"); - cb(null, num === 3); - }, function (err, result) { - expect(err).to.equal(null); - expect(result).to.equal(3); - done(); - }); - }); - - - it('find alias', function(){ - expect(async.find).to.equal(async.detect); - }); - - it('findLimit alias', function(){ - expect(async.findLimit).to.equal(async.detectLimit); - }); - - it('findSeries alias', function(){ - expect(async.findSeries).to.be.a('function'); - expect(async.findSeries).to.equal(async.detectSeries); - }); - -}); diff --git a/mocha_test/during.js b/mocha_test/during.js deleted file mode 100644 index 13db8b327..000000000 --- a/mocha_test/during.js +++ /dev/null @@ -1,98 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('during', function() { - - it('during', function(done) { - var call_order = []; - - var count = 0; - async.during( - function (cb) { - call_order.push(['test', count]); - cb(null, count < 5); - }, - function (cb) { - call_order.push(['iteratee', count]); - count++; - cb(null, count); - }, - function (err) { - assert(err === null, err + " passed instead of 'null'"); - expect(call_order).to.eql([ - ['test', 0], - ['iteratee', 0], ['test', 1], - ['iteratee', 1], ['test', 2], - ['iteratee', 2], ['test', 3], - ['iteratee', 3], ['test', 4], - ['iteratee', 4], ['test', 5], - ]); - expect(count).to.equal(5); - done(); - } - ); - }); - - it('doDuring', function(done) { - var call_order = []; - - var count = 0; - async.doDuring( - function (cb) { - call_order.push(['iteratee', count]); - count++; - cb(null, count); - }, - function (c, cb) { - expect(c).to.equal(count); - call_order.push(['test', count]); - cb(null, count < 5); - }, - function (err) { - assert(err === null, err + " passed instead of 'null'"); - expect(call_order).to.eql([ - ['iteratee', 0], ['test', 1], - ['iteratee', 1], ['test', 2], - ['iteratee', 2], ['test', 3], - ['iteratee', 3], ['test', 4], - ['iteratee', 4], ['test', 5], - ]); - expect(count).to.equal(5); - done(); - } - ); - }); - - it('doDuring - error test', function(done) { - var error = new Error('asdas'); - - async.doDuring( - function (cb) { - cb(error); - }, - function () {}, - function (err) { - expect(err).to.equal(error); - done(); - } - ); - }); - - it('doDuring - error iteratee', function(done) { - var error = new Error('asdas'); - - async.doDuring( - function (cb) { - cb(null); - }, - function (cb) { - cb(error); - }, - function (err) { - expect(err).to.equal(error); - done(); - } - ); - }); -}); diff --git a/mocha_test/every.js b/mocha_test/every.js deleted file mode 100644 index ed4693ebe..000000000 --- a/mocha_test/every.js +++ /dev/null @@ -1,99 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe("every", function () { - - it('everyLimit true', function(done){ - async.everyLimit([3,1,2], 1, function(x, callback){ - setTimeout(function(){callback(null, x >= 1);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(true); - done(); - }); - }); - - it('everyLimit false', function(done){ - async.everyLimit([3,1,2], 2, function(x, callback){ - setTimeout(function(){callback(null, x === 2);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(false); - done(); - }); - }); - - it('everyLimit short-circuit', function(done){ - var calls = 0; - async.everyLimit([3,1,2], 1, function(x, callback){ - calls++; - callback(null, x === 1); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(false); - expect(calls).to.equal(1); - done(); - }); - }); - - - it('true', function(done){ - async.every([1,2,3], function(x, callback){ - setTimeout(function(){callback(null, true);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(true); - done(); - }); - }); - - it('false', function(done){ - async.every([1,2,3], function(x, callback){ - setTimeout(function(){callback(null, x % 2);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(false); - done(); - }); - }); - - it('early return', function(done){ - var call_order = []; - async.every([1,2,3], function(x, callback){ - setTimeout(function(){ - call_order.push(x); - callback(null, x === 1); - }, x*5); - }, function(){ - call_order.push('callback'); - }); - setTimeout(function(){ - expect(call_order).to.eql([1,2,'callback',3]); - done(); - }, 25); - }); - - it('error', function(done){ - async.every([1,2,3], function(x, callback){ - setTimeout(function(){callback('error');}, 0); - }, function(err, result){ - expect(err).to.equal('error'); - expect(result).to.not.exist; - done(); - }); - }); - - it('all alias', function(){ - expect(async.all).to.equal(async.every); - }); - - it('allLimit alias', function(){ - expect(async.allLimit).to.equal(async.everyLimit); - }); - - it('allSeries alias', function(){ - expect(async.allSeries).to.be.a('function'); - expect(async.allSeries).to.equal(async.everySeries); - }); - -}); diff --git a/mocha_test/filter.js b/mocha_test/filter.js deleted file mode 100644 index 8b4b2681d..000000000 --- a/mocha_test/filter.js +++ /dev/null @@ -1,132 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -function filterIteratee(x, callback) { - setTimeout(function(){ - callback(null, x % 2); - }, x*5); -} - -function testLimit(arr, limitFunc, limit, iter, done) { - var args = []; - - limitFunc(arr, limit, function(x) { - args.push(x); - iter.apply(this, arguments); - }, function() { - expect(args).to.eql(arr); - done.apply(this, arguments); - }); -} - -describe("filter", function () { - - it('filter', function(done){ - async.filter([3,1,2], filterIteratee, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([3,1]); - done(); - }); - }); - - it('filter original untouched', function(done){ - var a = [3,1,2]; - async.filter(a, function(x, callback){ - callback(null, x % 2); - }, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([3,1]); - expect(a).to.eql([3,1,2]); - done(); - }); - }); - - it('filter error', function(done){ - async.filter([3,1,2], function(x, callback){ - callback('error'); - } , function(err, results){ - expect(err).to.equal('error'); - expect(results).to.not.exist; - done(); - }); - }); - - it('filterSeries', function(done){ - async.filterSeries([3,1,2], filterIteratee, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([3,1]); - done(); - }); - }); - - it('select alias', function(){ - expect(async.select).to.equal(async.filter); - }); - - it('selectSeries alias', function(){ - expect(async.selectSeries).to.equal(async.filterSeries); - }); - - it('filterLimit', function(done) { - testLimit([5, 4, 3, 2, 1], async.filterLimit, 2, function(v, next) { - next(null, v % 2); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.eql([5, 3, 1]); - done(); - }); - }); - -}); - -describe("reject", function () { - - it('reject', function(done){ - async.reject([3,1,2], filterIteratee, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([2]); - done(); - }); - }); - - it('reject original untouched', function(done){ - var a = [3,1,2]; - async.reject(a, function(x, callback){ - callback(null, x % 2); - }, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([2]); - expect(a).to.eql([3,1,2]); - done(); - }); - }); - - it('reject error', function(done){ - async.reject([3,1,2], function(x, callback){ - callback('error'); - } , function(err, results){ - expect(err).to.equal('error'); - expect(results).to.not.exist; - done(); - }); - }); - - it('rejectSeries', function(done){ - async.rejectSeries([3,1,2], filterIteratee, function(err, results){ - expect(err).to.equal(null); - expect(results).to.eql([2]); - done(); - }); - }); - - it('rejectLimit', function(done) { - testLimit([5, 4, 3, 2, 1], async.rejectLimit, 2, function(v, next) { - next(null, v % 2); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.eql([4, 2]); - done(); - }); - }); - -}); diff --git a/mocha_test/mapValues.js b/mocha_test/mapValues.js deleted file mode 100644 index 612feffcb..000000000 --- a/mocha_test/mapValues.js +++ /dev/null @@ -1,91 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe('mapValues', function () { - var obj = {a: 1, b: 2, c: 3}; - - context('mapValuesLimit', function () { - it('basics', function (done) { - var running = 0; - var concurrency = { - a: 2, - b: 2, - c: 1 - }; - async.mapValuesLimit(obj, 2, function (val, key, next) { - running++; - async.setImmediate(function () { - expect(running).to.equal(concurrency[key]); - running--; - next(null, key + val); - }); - }, function (err, result) { - expect(running).to.equal(0); - expect(err).to.eql(null); - expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); - done(); - }); - }); - - it('error', function (done) { - async.mapValuesLimit(obj, 1, function(val, key, next) { - if (key === 'b') { - return next(new Error("fail")); - } - next(null, val); - }, function (err, result) { - expect(err).to.not.eql(null); - expect(result).to.eql({a: 1}); - done(); - }); - }); - }); - - context('mapValues', function () { - it('basics', function (done) { - var running = 0; - var concurrency = { - a: 3, - b: 2, - c: 1 - }; - async.mapValues(obj, function (val, key, next) { - running++; - async.setImmediate(function () { - expect(running).to.equal(concurrency[key]); - running--; - next(null, key + val); - }); - }, function (err, result) { - expect(running).to.equal(0); - expect(err).to.eql(null); - expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); - done(); - }); - }); - }); - - context('mapValuesSeries', function () { - it('basics', function (done) { - var running = 0; - var concurrency = { - a: 1, - b: 1, - c: 1 - }; - async.mapValuesSeries(obj, function (val, key, next) { - running++; - async.setImmediate(function () { - expect(running).to.equal(concurrency[key]); - running--; - next(null, key + val); - }); - }, function (err, result) { - expect(running).to.equal(0); - expect(err).to.eql(null); - expect(result).to.eql({a: 'a1', b: 'b2', c: 'c3'}); - done(); - }); - }); - }); -}); diff --git a/mocha_test/mocha.opts b/mocha_test/mocha.opts deleted file mode 100644 index f39ac0a75..000000000 --- a/mocha_test/mocha.opts +++ /dev/null @@ -1,4 +0,0 @@ ---compilers js:babel-core/register ---recursive ---growl ---ui bdd diff --git a/mocha_test/priorityQueue.js b/mocha_test/priorityQueue.js deleted file mode 100644 index f71e665cc..000000000 --- a/mocha_test/priorityQueue.js +++ /dev/null @@ -1,243 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe('priorityQueue', function() { - - it('priorityQueue', function (done) { - var call_order = []; - - // order of completion: 2,1,4,3 - - var q = async.priorityQueue(function (task, callback) { - call_order.push('process ' + task); - callback('error', 'arg'); - }, 1); - - q.push(1, 1.4, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(2); - call_order.push('callback ' + 1); - }); - q.push(2, 0.2, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(3); - call_order.push('callback ' + 2); - }); - q.push(3, 3.8, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(0); - call_order.push('callback ' + 3); - }); - q.push(4, 2.9, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(1); - call_order.push('callback ' + 4); - }); - expect(q.length()).to.equal(4); - expect(q.concurrency).to.equal(1); - - q.drain = function () { - expect(call_order).to.eql([ - 'process 2', 'callback 2', - 'process 1', 'callback 1', - 'process 4', 'callback 4', - 'process 3', 'callback 3' - ]); - expect(q.concurrency).to.equal(1); - expect(q.length()).to.equal(0); - done(); - }; - }); - - it('concurrency', function (done) { - var call_order = [], - delays = [160,80,240,80]; - - // worker1: --2-3 - // worker2: -1---4 - // order of completion: 1,2,3,4 - - var q = async.priorityQueue(function (task, callback) { - setTimeout(function () { - call_order.push('process ' + task); - callback('error', 'arg'); - }, delays.splice(0,1)[0]); - }, 2); - - q.push(1, 1.4, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(2); - call_order.push('callback ' + 1); - }); - q.push(2, 0.2, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(1); - call_order.push('callback ' + 2); - }); - q.push(3, 3.8, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(0); - call_order.push('callback ' + 3); - }); - q.push(4, 2.9, function (err, arg) { - expect(err).to.equal('error'); - expect(arg).to.equal('arg'); - expect(q.length()).to.equal(0); - call_order.push('callback ' + 4); - }); - expect(q.length()).to.equal(4); - expect(q.concurrency).to.equal(2); - - q.drain = function () { - expect(call_order).to.eql([ - 'process 1', 'callback 1', - 'process 2', 'callback 2', - 'process 3', 'callback 3', - 'process 4', 'callback 4' - ]); - expect(q.concurrency).to.equal(2); - expect(q.length()).to.equal(0); - done(); - }; - }); - - it('pause in worker with concurrency', function(done) { - var call_order = []; - var q = async.priorityQueue(function (task, callback) { - if (task.isLongRunning) { - q.pause(); - setTimeout(function () { - call_order.push(task.id); - q.resume(); - callback(); - }, 50); - } - else { - call_order.push(task.id); - setTimeout(callback, 10); - } - }, 10); - - q.push({ id: 1, isLongRunning: true}); - q.push({ id: 2 }); - q.push({ id: 3 }); - q.push({ id: 4 }); - q.push({ id: 5 }); - - q.drain = function () { - expect(call_order).to.eql([1, 2, 3, 4, 5]); - done(); - }; - }); - - context('q.saturated(): ', function() { - it('should call the saturated callback if tasks length is concurrency', function(done) { - var calls = []; - var q = async.priorityQueue(function(task, cb) { - calls.push('process ' + task); - async.setImmediate(cb); - }, 4); - q.saturated = function() { - calls.push('saturated'); - }; - q.empty = function() { - expect(calls.indexOf('saturated')).to.be.above(-1); - setTimeout(function() { - expect(calls).eql([ - 'process foo4', - 'process foo3', - 'process foo2', - "saturated", - 'process foo1', - 'foo4 cb', - "saturated", - 'process foo0', - 'foo3 cb', - 'foo2 cb', - 'foo1 cb', - 'foo0 cb' - ]); - done(); - }, 50); - }; - q.push('foo0', 5, function () {calls.push('foo0 cb');}); - q.push('foo1', 4, function () {calls.push('foo1 cb');}); - q.push('foo2', 3, function () {calls.push('foo2 cb');}); - q.push('foo3', 2, function () {calls.push('foo3 cb');}); - q.push('foo4', 1, function () {calls.push('foo4 cb');}); - }); - }); - - context('q.unsaturated(): ',function() { - it('should have a default buffer property that equals 25% of the concurrenct rate', function(done) { - var calls = []; - var q = async.priorityQueue(function(task, cb) { - // nop - calls.push('process ' + task); - async.setImmediate(cb); - }, 10); - expect(q.buffer).to.equal(2.5); - done(); - }); - - it('should allow a user to change the buffer property', function(done) { - var calls = []; - var q = async.priorityQueue(function(task, cb) { - // nop - calls.push('process ' + task); - async.setImmediate(cb); - }, 10); - q.buffer = 4; - expect(q.buffer).to.not.equal(2.5); - expect(q.buffer).to.equal(4); - done(); - }); - - it('should call the unsaturated callback if tasks length is less than concurrency minus buffer', function(done) { - var calls = []; - var q = async.priorityQueue(function(task, cb) { - calls.push('process ' + task); - setTimeout(cb, 10); - }, 4); - q.unsaturated = function() { - calls.push('unsaturated'); - }; - q.empty = function() { - expect(calls.indexOf('unsaturated')).to.be.above(-1); - setTimeout(function() { - expect(calls).eql([ - 'process foo4', - 'process foo3', - 'process foo2', - 'process foo1', - 'foo4 cb', - 'unsaturated', - 'process foo0', - 'foo3 cb', - 'unsaturated', - 'foo2 cb', - 'unsaturated', - 'foo1 cb', - 'unsaturated', - 'foo0 cb', - 'unsaturated' - ]); - done(); - }, 50); - }; - q.push('foo0', 5, function () {calls.push('foo0 cb');}); - q.push('foo1', 4, function () {calls.push('foo1 cb');}); - q.push('foo2', 3, function () {calls.push('foo2 cb');}); - q.push('foo3', 2, function () {calls.push('foo3 cb');}); - q.push('foo4', 1, function () {calls.push('foo4 cb');}); - }); - }); -}); - diff --git a/mocha_test/reduce.js b/mocha_test/reduce.js deleted file mode 100644 index f5dce59d8..000000000 --- a/mocha_test/reduce.js +++ /dev/null @@ -1,66 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('reduce', function() { - - it('reduce', function(done) { - var call_order = []; - async.reduce([1,2,3], 0, function(a, x, callback){ - call_order.push(x); - callback(null, a + x); - }, function(err, result){ - assert(err === null, err + " passed instead of 'null'"); - expect(result).to.equal(6); - expect(call_order).to.eql([1,2,3]); - done(); - }); - }); - - it('reduce async with non-reference memo', function(done) { - async.reduce([1,3,2], 0, function(a, x, callback){ - setTimeout(function(){callback(null, a + x);}, Math.random()*100); - }, function(err, result){ - expect(result).to.equal(6); - done(); - }); - }); - - it('reduce error', function(done) { - async.reduce([1,2,3], 0, function(a, x, callback){ - callback('error'); - }, function(err){ - expect(err).to.equal('error'); - }); - setTimeout(done, 50); - }); - - it('inject alias', function(done) { - expect(async.inject).to.equal(async.reduce); - done(); - }); - - it('foldl alias', function(done) { - expect(async.foldl).to.equal(async.reduce); - done(); - }); - - it('reduceRight', function(done) { - var call_order = []; - var a = [1,2,3]; - async.reduceRight(a, 0, function(a, x, callback){ - call_order.push(x); - callback(null, a + x); - }, function(err, result){ - expect(result).to.equal(6); - expect(call_order).to.eql([3,2,1]); - expect(a).to.eql([1,2,3]); - done(); - }); - }); - - it('foldr alias', function(done) { - expect(async.foldr).to.equal(async.reduceRight); - done(); - }); -}); diff --git a/mocha_test/some.js b/mocha_test/some.js deleted file mode 100644 index 0a5a8da44..000000000 --- a/mocha_test/some.js +++ /dev/null @@ -1,114 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe("some", function () { - - it('some true', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback(null, x === 1);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(true); - done(); - }); - }); - - it('some false', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback(null, x === 10);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(false); - done(); - }); - }); - - it('some early return', function(done){ - var call_order = []; - async.some([1,2,3], function(x, callback){ - setTimeout(function(){ - call_order.push(x); - callback(null, x === 1); - }, x*5); - }, function(){ - call_order.push('callback'); - }); - setTimeout(function(){ - expect(call_order).to.eql([1,'callback',2,3]); - done(); - }, 25); - }); - - it('some error', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback('error');}, 0); - }, function(err, result){ - expect(err).to.equal('error'); - expect(result).to.not.exist; - done(); - }); - }); - - it('some no callback', function(done) { - var calls = []; - - async.some([1, 2, 3], function (val, cb) { - calls.push(val); - cb(); - }); - - setTimeout(function () { - expect(calls).to.eql([1, 2, 3]); - done(); - }, 10); - }); - - it('someLimit true', function(done){ - async.someLimit([3,1,2], 2, function(x, callback){ - setTimeout(function(){callback(null, x === 2);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(true); - done(); - }); - }); - - it('someLimit false', function(done){ - async.someLimit([3,1,2], 2, function(x, callback){ - setTimeout(function(){callback(null, x === 10);}, 0); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(false); - done(); - }); - }); - - - it('someLimit short-circuit', function(done){ - var calls = 0; - async.someLimit([3,1,2], 1, function(x, callback){ - calls++; - callback(null, x === 1); - }, function(err, result){ - expect(err).to.equal(null); - expect(result).to.equal(true); - expect(calls).to.equal(2); - done(); - }); - }); - - it('any alias', function(){ - expect(async.any).to.equal(async.some); - }); - - it('anyLimit alias', function(){ - expect(async.anyLimit).to.equal(async.someLimit); - }); - - it('anySeries alias', function(){ - expect(async.anySeries).to.be.a('function'); - expect(async.anySeries).to.equal(async.someSeries); - }); - - -}); diff --git a/mocha_test/sortBy.js b/mocha_test/sortBy.js deleted file mode 100644 index 1636276b2..000000000 --- a/mocha_test/sortBy.js +++ /dev/null @@ -1,36 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('sortBy', function(){ - it('sortBy', function(done) { - async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ - setTimeout(function(){callback(null, x.a);}, 0); - }, function(err, result){ - assert(err === null, err + " passed instead of 'null'"); - expect(result).to.eql([{a:1},{a:6},{a:15}]); - done(); - }); - }); - - it('sortBy inverted', function(done) { - async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ - setTimeout(function(){callback(null, x.a*-1);}, 0); - }, function(err, result){ - expect(result).to.eql([{a:15},{a:6},{a:1}]); - done(); - }); - }); - - it('sortBy error', function(done) { - var error = new Error('asdas'); - async.sortBy([{a:1},{a:15},{a:6}], function(x, callback){ - async.setImmediate(function(){ - callback(error); - }); - }, function(err){ - expect(err).to.equal(error); - done(); - }); - }); -}); diff --git a/mocha_test/timeout.js b/mocha_test/timeout.js deleted file mode 100644 index be4128372..000000000 --- a/mocha_test/timeout.js +++ /dev/null @@ -1,72 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe('timeout', function () { - - it('timeout with series', function(done){ - async.series([ - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I didn\'t time out'); - }, 25); - }, 50), - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I will time out'); - }, 75); - }, 50) - ], - function(err, results) { - expect(err.message).to.equal('Callback function "asyncFn" timed out.'); - expect(err.code).to.equal('ETIMEDOUT'); - expect(err.info).to.equal(undefined); - expect(results[0]).to.equal('I didn\'t time out'); - done(); - }); - }); - - it('timeout with series and info', function (done) { - var info = { custom: 'info about callback' }; - async.series([ - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I didn\'t time out'); - }, 25); - }, 50), - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I will time out'); - }, 75); - }, 50, info) - ], - function(err, results) { - expect(err.message).to.equal('Callback function "asyncFn" timed out.'); - expect(err.code).to.equal('ETIMEDOUT'); - expect(err.info).to.equal(info); - expect(results[0]).to.equal('I didn\'t time out'); - done(); - }); - }); - - it('timeout with parallel', function(done){ - async.parallel([ - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I didn\'t time out'); - }, 25); - }, 50), - async.timeout(function asyncFn(callback) { - setTimeout(function() { - callback(null, 'I will time out'); - }, 75); - }, 50) - ], - function(err, results) { - expect(err.message).to.equal('Callback function "asyncFn" timed out.'); - expect(err.code).to.equal('ETIMEDOUT'); - expect(err.info).to.equal(undefined); - expect(results[0]).to.equal('I didn\'t time out'); - done(); - }); - }); -}); diff --git a/mocha_test/times.js b/mocha_test/times.js deleted file mode 100644 index ad1dfcdf4..000000000 --- a/mocha_test/times.js +++ /dev/null @@ -1,90 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; -var assert = require('assert'); - -describe('times', function() { - - it('times', function(done) { - async.times(5, function(n, next) { - next(null, n); - }, function(err, results) { - assert(err === null, err + " passed instead of 'null'"); - expect(results).to.eql([0,1,2,3,4]); - done(); - }); - }); - - it('times 3', function(done) { - var args = []; - async.times(3, function(n, callback){ - setTimeout(function(){ - args.push(n); - callback(); - }, n * 25); - }, function(err){ - if (err) throw err; - expect(args).to.eql([0,1,2]); - done(); - }); - }); - - it('times 0', function(done) { - async.times(0, function(n, callback){ - assert(false, 'iteratee should not be called'); - callback(); - }, function(err){ - if (err) throw err; - assert(true, 'should call callback'); - }); - setTimeout(done, 25); - }); - - it('times error', function(done) { - async.times(3, function(n, callback){ - callback('error'); - }, function(err){ - expect(err).to.equal('error'); - }); - setTimeout(done, 50); - }); - - it('timesSeries', function(done) { - var call_order = []; - async.timesSeries(5, function(n, callback){ - setTimeout(function(){ - call_order.push(n); - callback(null, n); - }, 100 - n * 10); - }, function(err, results){ - expect(call_order).to.eql([0,1,2,3,4]); - expect(results).to.eql([0,1,2,3,4]); - done(); - }); - }); - - it('timesSeries error', function(done) { - async.timesSeries(5, function(n, callback){ - callback('error'); - }, function(err){ - expect(err).to.equal('error'); - }); - setTimeout(done, 50); - }); - - it('timesLimit', function(done) { - var limit = 2; - var running = 0; - async.timesLimit(5, limit, function (i, next) { - running++; - assert(running <= limit && running > 0, running); - setTimeout(function () { - running--; - next(null, i * 2); - }, (3 - i) * 10); - }, function(err, results){ - assert(err === null, err + " passed instead of 'null'"); - expect(results).to.eql([0, 2, 4, 6, 8]); - done(); - }); - }); -}); diff --git a/mocha_test/transform.js b/mocha_test/transform.js deleted file mode 100644 index 5c04f56c5..000000000 --- a/mocha_test/transform.js +++ /dev/null @@ -1,54 +0,0 @@ -var async = require('../lib'); -var expect = require('chai').expect; - -describe('transform', function() { - - it('transform implictly determines memo if not provided', function(done) { - async.transform([1,2,3], function(memo, x, v, callback){ - memo.push(x + 1); - callback(); - }, function(err, result){ - expect(result).to.eql([2, 3, 4]); - done(); - }); - }); - - it('transform async with object memo', function(done) { - async.transform([1,3,2], {}, function(memo, v, k, callback){ - setTimeout(function() { - memo[k] = v; - callback(); - }); - }, function(err, result) { - expect(err).to.equal(null); - expect(result).to.eql({ - 0: 1, - 1: 3, - 2: 2 - }); - done(); - }); - }); - - it('transform iterating object', function(done) { - async.transform({a: 1, b: 3, c: 2}, function(memo, v, k, callback){ - setTimeout(function() { - memo[k] = v + 1; - callback(); - }); - }, function(err, result) { - expect(err).to.equal(null); - expect(result).to.eql({a: 2, b: 4, c: 3}); - done(); - }); - }); - - it('transform error', function(done) { - async.transform([1,2,3], function(a, v, k, callback){ - callback('error'); - }, function(err){ - expect(err).to.equal('error'); - done(); - }); - }); -}); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..5351a4f34 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,9520 @@ +{ + "name": "async", + "version": "3.2.6", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "async", + "version": "3.2.6", + "license": "MIT", + "devDependencies": { + "@babel/core": "7.28.3", + "@babel/eslint-parser": "^7.16.5", + "babel-minify": "^0.5.0", + "babel-plugin-add-module-exports": "^1.0.4", + "babel-plugin-istanbul": "^7.0.0", + "babel-plugin-syntax-async-generators": "^6.13.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", + "babel-preset-es2015": "^6.3.13", + "babel-preset-es2017": "^6.22.0", + "babel-register": "^6.26.0", + "babelify": "^10.0.0", + "benchmark": "^2.1.1", + "bluebird": "^3.4.6", + "browserify": "^17.0.0", + "chai": "^4.2.0", + "cheerio": "^1.0.0", + "es6-promise": "^4.2.8", + "eslint": "^8.6.0", + "eslint-plugin-prefer-arrow": "^1.2.3", + "fs-extra": "^11.1.1", + "jsdoc": "^4.0.3", + "karma": "^6.3.12", + "karma-browserify": "^8.1.0", + "karma-firefox-launcher": "^2.1.2", + "karma-mocha": "^2.0.1", + "karma-mocha-reporter": "^2.2.0", + "karma-safari-launcher": "^1.0.0", + "mocha": "^6.1.4", + "native-promise-only": "^0.8.0-a", + "nyc": "^17.0.0", + "rollup": "^4.2.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-npm": "^2.0.0", + "rsvp": "^4.8.5", + "semver": "^7.3.5", + "taffydb": "^2.7.3", + "yargs": "^18.0.0" + } + }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.28.0.tgz", + "integrity": "sha512-60X7qkglvrap8mn1lh2ebxXdZYtUcpd7gsmy9kLaBJ4i/WdY8PqTSdxyA8qraikqKQK5C1KRBKXqznrVapyNaw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.3.tgz", + "integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.28.3", + "@babel/helper-compilation-targets": "^7.27.2", + "@babel/helper-module-transforms": "^7.28.3", + "@babel/helpers": "^7.28.3", + "@babel/parser": "^7.28.3", + "@babel/template": "^7.27.2", + "@babel/traverse": "^7.28.3", + "@babel/types": "^7.28.2", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/eslint-parser": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.28.0.tgz", + "integrity": "sha512-N4ntErOlKvcbTt01rr5wj3y55xnIdx1ymrfIr8C2WnM1Y9glFgWaGDEULJIazOX3XM9NRzhfJ6zZnQ1sBNWU+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", + "eslint-visitor-keys": "^2.1.0", + "semver": "^6.3.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || >=14.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.11.0", + "eslint": "^7.5.0 || ^8.0.0 || ^9.0.0" + } + }, + "node_modules/@babel/eslint-parser/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.28.3.tgz", + "integrity": "sha512-3lSpxGgvnmZznmBkCRnVREPUFJv2wrv9iAoFDvADJc0ypmdOxdUtcLeBgBJ6zE0PMeTKnxeQzyk0xTBq4Ep7zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.3", + "@babel/types": "^7.28.2", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz", + "integrity": "sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.27.2", + "@babel/helper-validator-option": "^7.27.1", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.28.0.tgz", + "integrity": "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz", + "integrity": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.27.1", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.3.tgz", + "integrity": "sha512-gytXUbs8k2sXS9PnQptz5o0QnpLL51SwASIORY6XaBKF88nsOT0Zw9szLqlSGQDP/4TljBAD5y98p2U1fqkdsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1", + "@babel/traverse": "^7.28.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.20.2", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz", + "integrity": "sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz", + "integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.28.3.tgz", + "integrity": "sha512-PTNtvUQihsAsDHMOP5pfobP8C6CM4JWXmP8DrEIt46c3r2bf87Ua1zoqevsMo9g+tWDwgWrFP5EIxuBx5RudAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.3.tgz", + "integrity": "sha512-7+Ey1mAgYqFAx2h0RuoxcQT5+MlG3GTV0TQrgr7/ZliKsm/MNDxVVutlWaziMq7wJNAz8MTqz55XLpWvva6StA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/template": { + "version": "7.27.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", + "integrity": "sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/parser": "^7.27.2", + "@babel/types": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.28.3.tgz", + "integrity": "sha512-7w4kZYHneL3A6NP2nxzHvT3HCZ7puDZZjFMqDpBPECub79sTtSO5CGXDkKrTQq8ksAwfD/XI2MRFX23njdDaIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/generator": "^7.28.3", + "@babel/helper-globals": "^7.28.0", + "@babel/parser": "^7.28.3", + "@babel/template": "^7.27.2", + "@babel/types": "^7.28.2", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.28.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz", + "integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@colors/colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", + "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@eslint/eslintrc/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.30", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.30.tgz", + "integrity": "sha512-GQ7Nw5G2lTu/BtHTKfXhKHok2WGetd4XYcVKGx00SjAk8GMwgJM3zr6zORiPGuOE+/vkc90KtTosSSvaCjKb2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jsdoc/salty": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.8.tgz", + "integrity": "sha512-5e+SFVavj1ORKlKaKr2BmTOekmXbelU7dC0cDkQLqag7xfuTPuGMUFx7KWJuv4bYZrTsoL2Z18VVCOKYxzoHcg==", + "dev": true, + "dependencies": { + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v12.0.0" + } + }, + "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { + "version": "5.1.1-v1", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", + "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", + "dev": true, + "dependencies": { + "eslint-scope": "5.1.1" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.50.0.tgz", + "integrity": "sha512-lVgpeQyy4fWN5QYebtW4buT/4kn4p4IJ+kDNB4uYNT5b8c8DLJDg6titg20NIg7E8RWwdWZORW6vUFfrLyG3KQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.50.0.tgz", + "integrity": "sha512-2O73dR4Dc9bp+wSYhviP6sDziurB5/HCym7xILKifWdE9UsOe2FtNcM+I4xZjKrfLJnq5UR8k9riB87gauiQtw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.50.0.tgz", + "integrity": "sha512-vwSXQN8T4sKf1RHr1F0s98Pf8UPz7pS6P3LG9NSmuw0TVh7EmaE+5Ny7hJOZ0M2yuTctEsHHRTMi2wuHkdS6Hg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.50.0.tgz", + "integrity": "sha512-cQp/WG8HE7BCGyFVuzUg0FNmupxC+EPZEwWu2FCGGw5WDT1o2/YlENbm5e9SMvfDFR6FRhVCBePLqj0o8MN7Vw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.50.0.tgz", + "integrity": "sha512-UR1uTJFU/p801DvvBbtDD7z9mQL8J80xB0bR7DqW7UGQHRm/OaKzp4is7sQSdbt2pjjSS72eAtRh43hNduTnnQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.50.0.tgz", + "integrity": "sha512-G/DKyS6PK0dD0+VEzH/6n/hWDNPDZSMBmqsElWnCRGrYOb2jC0VSupp7UAHHQ4+QILwkxSMaYIbQ72dktp8pKA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.50.0.tgz", + "integrity": "sha512-u72Mzc6jyJwKjJbZZcIYmd9bumJu7KNmHYdue43vT1rXPm2rITwmPWF0mmPzLm9/vJWxIRbao/jrQmxTO0Sm9w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.50.0.tgz", + "integrity": "sha512-S4UefYdV0tnynDJV1mdkNawp0E5Qm2MtSs330IyHgaccOFrwqsvgigUD29uT+B/70PDY1eQ3t40+xf6wIvXJyg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.50.0.tgz", + "integrity": "sha512-1EhkSvUQXJsIhk4msxP5nNAUWoB4MFDHhtc4gAYvnqoHlaL9V3F37pNHabndawsfy/Tp7BPiy/aSa6XBYbaD1g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.50.0.tgz", + "integrity": "sha512-EtBDIZuDtVg75xIPIK1l5vCXNNCIRM0OBPUG+tbApDuJAy9mKago6QxX+tfMzbCI6tXEhMuZuN1+CU8iDW+0UQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.50.0.tgz", + "integrity": "sha512-BGYSwJdMP0hT5CCmljuSNx7+k+0upweM2M4YGfFBjnFSZMHOLYR0gEEj/dxyYJ6Zc6AiSeaBY8dWOa11GF/ppQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.50.0.tgz", + "integrity": "sha512-I1gSMzkVe1KzAxKAroCJL30hA4DqSi+wGc5gviD0y3IL/VkvcnAqwBf4RHXHyvH66YVHxpKO8ojrgc4SrWAnLg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.50.0.tgz", + "integrity": "sha512-bSbWlY3jZo7molh4tc5dKfeSxkqnf48UsLqYbUhnkdnfgZjgufLS/NTA8PcP/dnvct5CCdNkABJ56CbclMRYCA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.50.0.tgz", + "integrity": "sha512-LSXSGumSURzEQLT2e4sFqFOv3LWZsEF8FK7AAv9zHZNDdMnUPYH3t8ZlaeYYZyTXnsob3htwTKeWtBIkPV27iQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.50.0.tgz", + "integrity": "sha512-CxRKyakfDrsLXiCyucVfVWVoaPA4oFSpPpDwlMcDFQvrv3XY6KEzMtMZrA+e/goC8xxp2WSOxHQubP8fPmmjOQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.50.0.tgz", + "integrity": "sha512-8PrJJA7/VU8ToHVEPu14FzuSAqVKyo5gg/J8xUerMbyNkWkO9j2ExBho/68RnJsMGNJq4zH114iAttgm7BZVkA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.50.0.tgz", + "integrity": "sha512-SkE6YQp+CzpyOrbw7Oc4MgXFvTw2UIBElvAvLCo230pyxOLmYwRPwZ/L5lBe/VW/qT1ZgND9wJfOsdy0XptRvw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.50.0.tgz", + "integrity": "sha512-PZkNLPfvXeIOgJWA804zjSFH7fARBBCpCXxgkGDRjjAhRLOR8o0IGS01ykh5GYfod4c2yiiREuDM8iZ+pVsT+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.50.0.tgz", + "integrity": "sha512-q7cIIdFvWQoaCbLDUyUc8YfR3Jh2xx3unO8Dn6/TTogKjfwrax9SyfmGGK6cQhKtjePI7jRfd7iRYcxYs93esg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.50.0.tgz", + "integrity": "sha512-XzNOVg/YnDOmFdDKcxxK410PrcbcqZkBmz+0FicpW5jtjKQxcW1BZJEQOF0NJa6JO7CZhett8GEtRN/wYLYJuw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.50.0.tgz", + "integrity": "sha512-xMmiWRR8sp72Zqwjgtf3QbZfF1wdh8X2ABu3EaozvZcyHJeU0r+XAnXdKgs4cCAp6ORoYoCygipYP1mjmbjrsg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@socket.io/component-emitter": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", + "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==", + "dev": true + }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==", + "dev": true + }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "dev": true + }, + "node_modules/@types/markdown-it": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.1.tgz", + "integrity": "sha512-4NpsnpYl2Gt1ljyBGrKMxFYAYvpqbnnkgP/i/g+NLpjEUa3obn1XJCur9YbEXKDAkaXqsR1LbDnGEJ0MmKFxfg==", + "dev": true, + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "dev": true + }, + "node_modules/@types/node": { + "version": "18.14.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.4.tgz", + "integrity": "sha512-VhCw7I7qO2X49+jaKcAUwi3rR+hbxT5VcYF493+Z5kMLI0DL568b7JI4IDJaxWFH0D/xwmGJNoXisyX+w7GH/g==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/acorn-node": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", + "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", + "dev": true, + "dependencies": { + "acorn": "^7.0.0", + "acorn-walk": "^7.0.0", + "xtend": "^4.0.2" + } + }, + "node_modules/acorn-node/node_modules/acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aggregate-error": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", + "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", + "dev": true, + "dependencies": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-colors": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", + "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "dependencies": { + "default-require-extensions": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==", + "dev": true + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/array.prototype.reduce": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/array.prototype.reduce/-/array.prototype.reduce-1.0.5.tgz", + "integrity": "sha512-kDdugMl7id9COE8R7MHF5jWk7Dqt/fs4Pv+JXoICnYwqpjjjbUurz6w5fT5IG6brLdJhv6/VoHB0H7oyIBXd+Q==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "es-array-method-boxes-properly": "^1.0.0", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", + "dev": true, + "dependencies": { + "object-assign": "^4.1.1", + "util": "0.10.3" + } + }, + "node_modules/assert/node_modules/inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==", + "dev": true + }, + "node_modules/assert/node_modules/util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha512-5KiHfsmkqacuKjkRkdV7SsfDJ2EGiPsK92s2MhNSY0craxjTdKTtqKsJaCWp4LW33ZZ0OPUv1WO/TFvNQRiQxQ==", + "dev": true, + "dependencies": { + "inherits": "2.0.1" + } + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g==", + "dev": true, + "dependencies": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + } + }, + "node_modules/babel-code-frame/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", + "dev": true, + "dependencies": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg==", + "dev": true + }, + "node_modules/babel-code-frame/node_modules/strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-code-frame/node_modules/supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/babel-core": { + "version": "6.26.3", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.3.tgz", + "integrity": "sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==", + "dev": true, + "dependencies": { + "babel-code-frame": "^6.26.0", + "babel-generator": "^6.26.0", + "babel-helpers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-register": "^6.26.0", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "convert-source-map": "^1.5.1", + "debug": "^2.6.9", + "json5": "^0.5.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.4", + "path-is-absolute": "^1.0.1", + "private": "^0.1.8", + "slash": "^1.0.0", + "source-map": "^0.5.7" + } + }, + "node_modules/babel-core/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/babel-core/node_modules/json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/babel-core/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/babel-generator": { + "version": "6.26.1", + "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", + "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", + "dev": true, + "dependencies": { + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "detect-indent": "^4.0.0", + "jsesc": "^1.3.0", + "lodash": "^4.17.4", + "source-map": "^0.5.7", + "trim-right": "^1.0.1" + } + }, + "node_modules/babel-generator/node_modules/jsesc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", + "integrity": "sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, + "node_modules/babel-helper-call-delegate": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", + "integrity": "sha512-RL8n2NiEj+kKztlrVJM9JT1cXzzAdvWFh76xh/H1I4nKwunzE4INBXn8ieCZ+wh4zWszZk7NBS1s/8HR5jDkzQ==", + "dev": true, + "dependencies": { + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-define-map": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", + "integrity": "sha512-bHkmjcC9lM1kmZcVpA5t2om2nzT/xiZpo6TJq7UlZ3wqKfzia4veeXbIhKvJXAMzhhEBd3cR1IElL5AenWEUpA==", + "dev": true, + "dependencies": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + } + }, + "node_modules/babel-helper-evaluate-path": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.5.0.tgz", + "integrity": "sha512-mUh0UhS607bGh5wUMAQfOpt2JX2ThXMtppHRdRU1kL7ZLRWIXxoV2UIV1r2cAeeNeU1M5SB5/RSUgUxrK8yOkA==", + "dev": true + }, + "node_modules/babel-helper-flip-expressions": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-helper-flip-expressions/-/babel-helper-flip-expressions-0.4.3.tgz", + "integrity": "sha512-rSrkRW4YQ2ETCWww9gbsWk4N0x1BOtln349Tk0dlCS90oT68WMLyGR7WvaMp3eAnsVrCqdUtC19lo1avyGPejA==", + "dev": true + }, + "node_modules/babel-helper-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", + "integrity": "sha512-Oo6+e2iX+o9eVvJ9Y5eKL5iryeRdsIkwRYheCuhYdVHsdEQysbc2z2QkqCLIYnNxkT5Ss3ggrHdXiDI7Dhrn4Q==", + "dev": true, + "dependencies": { + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-get-function-arity": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", + "integrity": "sha512-WfgKFX6swFB1jS2vo+DwivRN4NB8XUdM3ij0Y1gnC21y1tdBoe6xjVnd7NSI6alv+gZXCtJqvrTeMW3fR/c0ng==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-hoist-variables": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", + "integrity": "sha512-zAYl3tqerLItvG5cKYw7f1SpvIxS9zi7ohyGHaI9cgDUjAT6YcY9jIEH5CstetP5wHIVSceXwNS7Z5BpJg+rOw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-is-nodes-equiv": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/babel-helper-is-nodes-equiv/-/babel-helper-is-nodes-equiv-0.0.1.tgz", + "integrity": "sha512-ri/nsMFVRqXn7IyT5qW4/hIAGQxuYUFHa3qsxmPtbk6spZQcYlyDogfVpNm2XYOslH/ULS4VEJGUqQX5u7ACQw==", + "dev": true + }, + "node_modules/babel-helper-is-void-0": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-helper-is-void-0/-/babel-helper-is-void-0-0.4.3.tgz", + "integrity": "sha512-07rBV0xPRM3TM5NVJEOQEkECX3qnHDjaIbFvWYPv+T1ajpUiVLiqTfC+MmiZxY5KOL/Ec08vJdJD9kZiP9UkUg==", + "dev": true + }, + "node_modules/babel-helper-mark-eval-scopes": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-helper-mark-eval-scopes/-/babel-helper-mark-eval-scopes-0.4.3.tgz", + "integrity": "sha512-+d/mXPP33bhgHkdVOiPkmYoeXJ+rXRWi7OdhwpyseIqOS8CmzHQXHUp/+/Qr8baXsT0kjGpMHHofHs6C3cskdA==", + "dev": true + }, + "node_modules/babel-helper-optimise-call-expression": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", + "integrity": "sha512-Op9IhEaxhbRT8MDXx2iNuMgciu2V8lDvYCNQbDGjdBNCjaMvyLf4wl4A3b8IgndCyQF8TwfgsQ8T3VD8aX1/pA==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-regex": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", + "integrity": "sha512-VlPiWmqmGJp0x0oK27Out1D+71nVVCTSdlbhIVoaBAj2lUgrNjBCRR9+llO4lTSb2O4r7PJg+RobRkhBrf6ofg==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + } + }, + "node_modules/babel-helper-remap-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", + "integrity": "sha512-RYqaPD0mQyQIFRu7Ho5wE2yvA/5jxqCIj/Lv4BXNq23mHYu/vxikOy2JueLiBxQknwapwrJeNCesvY0ZcfnlHg==", + "dev": true, + "dependencies": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-remove-or-void": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-helper-remove-or-void/-/babel-helper-remove-or-void-0.4.3.tgz", + "integrity": "sha512-eYNceYtcGKpifHDir62gHJadVXdg9fAhuZEXiRQnJJ4Yi4oUTpqpNY//1pM4nVyjjDMPYaC2xSf0I+9IqVzwdA==", + "dev": true + }, + "node_modules/babel-helper-replace-supers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", + "integrity": "sha512-sLI+u7sXJh6+ToqDr57Bv973kCepItDhMou0xCP2YPVmR1jkHSCY+p1no8xErbV1Siz5QE8qKT1WIwybSWlqjw==", + "dev": true, + "dependencies": { + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-helper-to-multiple-sequence-expressions": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-helper-to-multiple-sequence-expressions/-/babel-helper-to-multiple-sequence-expressions-0.5.0.tgz", + "integrity": "sha512-m2CvfDW4+1qfDdsrtf4dwOslQC3yhbgyBFptncp4wvtdrDHqueW7slsYv4gArie056phvQFhT2nRcGS4bnm6mA==", + "dev": true + }, + "node_modules/babel-helpers": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", + "integrity": "sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "node_modules/babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-minify": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/babel-minify/-/babel-minify-0.5.2.tgz", + "integrity": "sha512-H1ExfmvTxKWQZYcty1My6XRhoZm04/5MNb2DdZsC08r7y/rowipC0s9sszKA7jgW9mYYDdFnU68XohB+zP35qQ==", + "dev": true, + "dependencies": { + "@babel/core": "^7.1.0", + "babel-preset-minify": "^0.5.2", + "fs-readdir-recursive": "^1.1.0", + "lodash": "^4.17.11", + "mkdirp": "^0.5.1", + "util.promisify": "^1.0.0", + "yargs-parser": "^10.0.0" + }, + "bin": { + "babel-minify": "bin/minify.js", + "minify": "bin/minify.js" + } + }, + "node_modules/babel-plugin-add-module-exports": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-1.0.4.tgz", + "integrity": "sha512-g+8yxHUZ60RcyaUpfNzy56OtWW+x9cyEe9j+CranqLiqbju2yf/Cy6ZtYK40EZxtrdHllzlVZgLmcOUCTlJ7Jg==", + "dev": true + }, + "node_modules/babel-plugin-check-es2015-constants": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", + "integrity": "sha512-B1M5KBP29248dViEo1owyY32lk1ZSH2DaNNrXLGt8lyjjHm7pBqAdQ7VKUPR6EEDO323+OvT3MQXbCin8ooWdA==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-7.0.0.tgz", + "integrity": "sha512-C5OzENSx/A+gt7t4VH1I2XsflxyPUmXRFPKBxt33xncdOmq7oROVM3bZv9Ysjjkv8OJYDMa+tKuKMvqU/H3xdw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-instrument": "^6.0.2", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/babel-plugin-minify-builtins": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-builtins/-/babel-plugin-minify-builtins-0.5.0.tgz", + "integrity": "sha512-wpqbN7Ov5hsNwGdzuzvFcjgRlzbIeVv1gMIlICbPj0xkexnfoIDe7q+AZHMkQmAE/F9R5jkrB6TLfTegImlXag==", + "dev": true + }, + "node_modules/babel-plugin-minify-constant-folding": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-constant-folding/-/babel-plugin-minify-constant-folding-0.5.0.tgz", + "integrity": "sha512-Vj97CTn/lE9hR1D+jKUeHfNy+m1baNiJ1wJvoGyOBUx7F7kJqDZxr9nCHjO/Ad+irbR3HzR6jABpSSA29QsrXQ==", + "dev": true, + "dependencies": { + "babel-helper-evaluate-path": "^0.5.0" + } + }, + "node_modules/babel-plugin-minify-dead-code-elimination": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-dead-code-elimination/-/babel-plugin-minify-dead-code-elimination-0.5.2.tgz", + "integrity": "sha512-krq9Lwi0QIzyAlcNBXTL4usqUvevB4BzktdEsb8srcXC1AaYqRJiAQw6vdKdJSaXbz6snBvziGr6ch/aoRCfpA==", + "dev": true, + "dependencies": { + "babel-helper-evaluate-path": "^0.5.0", + "babel-helper-mark-eval-scopes": "^0.4.3", + "babel-helper-remove-or-void": "^0.4.3", + "lodash": "^4.17.11" + } + }, + "node_modules/babel-plugin-minify-flip-comparisons": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-flip-comparisons/-/babel-plugin-minify-flip-comparisons-0.4.3.tgz", + "integrity": "sha512-8hNwgLVeJzpeLVOVArag2DfTkbKodzOHU7+gAZ8mGBFGPQHK6uXVpg3jh5I/F6gfi5Q5usWU2OKcstn1YbAV7A==", + "dev": true, + "dependencies": { + "babel-helper-is-void-0": "^0.4.3" + } + }, + "node_modules/babel-plugin-minify-guarded-expressions": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-guarded-expressions/-/babel-plugin-minify-guarded-expressions-0.4.4.tgz", + "integrity": "sha512-RMv0tM72YuPPfLT9QLr3ix9nwUIq+sHT6z8Iu3sLbqldzC1Dls8DPCywzUIzkTx9Zh1hWX4q/m9BPoPed9GOfA==", + "dev": true, + "dependencies": { + "babel-helper-evaluate-path": "^0.5.0", + "babel-helper-flip-expressions": "^0.4.3" + } + }, + "node_modules/babel-plugin-minify-infinity": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-infinity/-/babel-plugin-minify-infinity-0.4.3.tgz", + "integrity": "sha512-X0ictxCk8y+NvIf+bZ1HJPbVZKMlPku3lgYxPmIp62Dp8wdtbMLSekczty3MzvUOlrk5xzWYpBpQprXUjDRyMA==", + "dev": true + }, + "node_modules/babel-plugin-minify-mangle-names": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-mangle-names/-/babel-plugin-minify-mangle-names-0.5.1.tgz", + "integrity": "sha512-8KMichAOae2FHlipjNDTo2wz97MdEb2Q0jrn4NIRXzHH7SJ3c5TaNNBkeTHbk9WUsMnqpNUx949ugM9NFWewzw==", + "dev": true, + "dependencies": { + "babel-helper-mark-eval-scopes": "^0.4.3" + } + }, + "node_modules/babel-plugin-minify-numeric-literals": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-numeric-literals/-/babel-plugin-minify-numeric-literals-0.4.3.tgz", + "integrity": "sha512-5D54hvs9YVuCknfWywq0eaYDt7qYxlNwCqW9Ipm/kYeS9gYhJd0Rr/Pm2WhHKJ8DC6aIlDdqSBODSthabLSX3A==", + "dev": true + }, + "node_modules/babel-plugin-minify-replace": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-replace/-/babel-plugin-minify-replace-0.5.0.tgz", + "integrity": "sha512-aXZiaqWDNUbyNNNpWs/8NyST+oU7QTpK7J9zFEFSA0eOmtUNMU3fczlTTTlnCxHmq/jYNFEmkkSG3DDBtW3Y4Q==", + "dev": true + }, + "node_modules/babel-plugin-minify-simplify": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-simplify/-/babel-plugin-minify-simplify-0.5.1.tgz", + "integrity": "sha512-OSYDSnoCxP2cYDMk9gxNAed6uJDiDz65zgL6h8d3tm8qXIagWGMLWhqysT6DY3Vs7Fgq7YUDcjOomhVUb+xX6A==", + "dev": true, + "dependencies": { + "babel-helper-evaluate-path": "^0.5.0", + "babel-helper-flip-expressions": "^0.4.3", + "babel-helper-is-nodes-equiv": "^0.0.1", + "babel-helper-to-multiple-sequence-expressions": "^0.5.0" + } + }, + "node_modules/babel-plugin-minify-type-constructors": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-minify-type-constructors/-/babel-plugin-minify-type-constructors-0.4.3.tgz", + "integrity": "sha512-4ADB0irJ/6BeXWHubjCJmrPbzhxDgjphBMjIjxCc25n4NGJ00NsYqwYt+F/OvE9RXx8KaSW7cJvp+iZX436tnQ==", + "dev": true, + "dependencies": { + "babel-helper-is-void-0": "^0.4.3" + } + }, + "node_modules/babel-plugin-syntax-async-functions": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", + "integrity": "sha512-4Zp4unmHgw30A1eWI5EpACji2qMocisdXhAftfhXoSV9j0Tvj6nRFE3tOmRY912E0FMRm/L5xWE7MGVT2FoLnw==", + "dev": true + }, + "node_modules/babel-plugin-syntax-async-generators": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz", + "integrity": "sha512-EbciFN5Jb9iqU9bqaLmmFLx2G8pAUsvpWJ6OzOWBNrSY9qTohXj+7YfZx6Ug1Qqh7tCb1EA7Jvn9bMC1HBiucg==", + "dev": true + }, + "node_modules/babel-plugin-syntax-trailing-function-commas": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", + "integrity": "sha512-Gx9CH3Q/3GKbhs07Bszw5fPTlU+ygrOGfAhEt7W2JICwufpC4SuO0mG0+4NykPBSYPMJhqvVlDBU17qB1D+hMQ==", + "dev": true + }, + "node_modules/babel-plugin-transform-async-to-generator": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", + "integrity": "sha512-7BgYJujNCg0Ti3x0c/DL3tStvnKS6ktIYOmo9wginv/dfZOrbSZ+qG4IRRHMBOzZ5Awb1skTiAsQXg/+IWkZYw==", + "dev": true, + "dependencies": { + "babel-helper-remap-async-to-generator": "^6.24.1", + "babel-plugin-syntax-async-functions": "^6.8.0", + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-arrow-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", + "integrity": "sha512-PCqwwzODXW7JMrzu+yZIaYbPQSKjDTAsNNlK2l5Gg9g4rz2VzLnZsStvp/3c46GfXpwkyufb3NCyG9+50FF1Vg==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-block-scoped-functions": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", + "integrity": "sha512-2+ujAT2UMBzYFm7tidUsYh+ZoIutxJ3pN9IYrF1/H6dCKtECfhmB8UkHVpyxDwkj0CYbQG35ykoz925TUnBc3A==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-block-scoping": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", + "integrity": "sha512-YiN6sFAQ5lML8JjCmr7uerS5Yc/EMbgg9G8ZNmk2E3nYX4ckHR01wrkeeMijEf5WHNK5TW0Sl0Uu3pv3EdOJWw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "lodash": "^4.17.4" + } + }, + "node_modules/babel-plugin-transform-es2015-classes": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", + "integrity": "sha512-5Dy7ZbRinGrNtmWpquZKZ3EGY8sDgIVB4CU8Om8q8tnMLrD/m94cKglVcHps0BCTdZ0TJeeAWOq2TK9MIY6cag==", + "dev": true, + "dependencies": { + "babel-helper-define-map": "^6.24.1", + "babel-helper-function-name": "^6.24.1", + "babel-helper-optimise-call-expression": "^6.24.1", + "babel-helper-replace-supers": "^6.24.1", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-computed-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", + "integrity": "sha512-C/uAv4ktFP/Hmh01gMTvYvICrKze0XVX9f2PdIXuriCSvUmV9j+u+BB9f5fJK3+878yMK6dkdcq+Ymr9mrcLzw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-destructuring": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", + "integrity": "sha512-aNv/GDAW0j/f4Uy1OEPZn1mqD+Nfy9viFGBfQ5bZyT35YqOiqx7/tXdyfZkJ1sC21NyEsBdfDY6PYmLHF4r5iA==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-duplicate-keys": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", + "integrity": "sha512-ossocTuPOssfxO2h+Z3/Ea1Vo1wWx31Uqy9vIiJusOP4TbF7tPs9U0sJ9pX9OJPf4lXRGj5+6Gkl/HHKiAP5ug==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-for-of": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", + "integrity": "sha512-DLuRwoygCoXx+YfxHLkVx5/NpeSbVwfoTeBykpJK7JhYWlL/O8hgAK/reforUnZDlxasOrVPPJVI/guE3dCwkw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-function-name": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", + "integrity": "sha512-iFp5KIcorf11iBqu/y/a7DK3MN5di3pNCzto61FqCNnUX4qeBwcV1SLqe10oXNnCaxBUImX3SckX2/o1nsrTcg==", + "dev": true, + "dependencies": { + "babel-helper-function-name": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", + "integrity": "sha512-tjFl0cwMPpDYyoqYA9li1/7mGFit39XiNX5DKC/uCNjBctMxyL1/PT/l4rSlbvBG1pOKI88STRdUsWXB3/Q9hQ==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-modules-amd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", + "integrity": "sha512-LnIIdGWIKdw7zwckqx+eGjcS8/cl8D74A3BpJbGjKTFFNJSMrjN4bIh22HY1AlkUbeLG6X6OZj56BDvWD+OeFA==", + "dev": true, + "dependencies": { + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-modules-commonjs": { + "version": "6.26.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz", + "integrity": "sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q==", + "dev": true, + "dependencies": { + "babel-plugin-transform-strict-mode": "^6.24.1", + "babel-runtime": "^6.26.0", + "babel-template": "^6.26.0", + "babel-types": "^6.26.0" + } + }, + "node_modules/babel-plugin-transform-es2015-modules-systemjs": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", + "integrity": "sha512-ONFIPsq8y4bls5PPsAWYXH/21Hqv64TBxdje0FvU3MhIV6QM2j5YS7KvAzg/nTIVLot2D2fmFQrFWCbgHlFEjg==", + "dev": true, + "dependencies": { + "babel-helper-hoist-variables": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-modules-umd": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", + "integrity": "sha512-LpVbiT9CLsuAIp3IG0tfbVo81QIhn6pE8xBJ7XSeCtFlMltuar5VuBV6y6Q45tpui9QWcy5i0vLQfCfrnF7Kiw==", + "dev": true, + "dependencies": { + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-object-super": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", + "integrity": "sha512-8G5hpZMecb53vpD3mjs64NhI1au24TAmokQ4B+TBFBjN9cVoGoOvotdrMMRmHvVZUEvqGUPWL514woru1ChZMA==", + "dev": true, + "dependencies": { + "babel-helper-replace-supers": "^6.24.1", + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-parameters": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", + "integrity": "sha512-8HxlW+BB5HqniD+nLkQ4xSAVq3bR/pcYW9IigY+2y0dI+Y7INFeTbfAQr+63T3E4UDsZGjyb+l9txUnABWxlOQ==", + "dev": true, + "dependencies": { + "babel-helper-call-delegate": "^6.24.1", + "babel-helper-get-function-arity": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-template": "^6.24.1", + "babel-traverse": "^6.24.1", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-shorthand-properties": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", + "integrity": "sha512-mDdocSfUVm1/7Jw/FIRNw9vPrBQNePy6wZJlR8HAUBLybNp1w/6lr6zZ2pjMShee65t/ybR5pT8ulkLzD1xwiw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-spread": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", + "integrity": "sha512-3Ghhi26r4l3d0Js933E5+IhHwk0A1yiutj9gwvzmFbVV0sPMYk2lekhOufHBswX7NCoSeF4Xrl3sCIuSIa+zOg==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-sticky-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", + "integrity": "sha512-CYP359ADryTo3pCsH0oxRo/0yn6UsEZLqYohHmvLQdfS9xkf+MbCzE3/Kolw9OYIY4ZMilH25z/5CbQbwDD+lQ==", + "dev": true, + "dependencies": { + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-es2015-template-literals": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", + "integrity": "sha512-x8b9W0ngnKzDMHimVtTfn5ryimars1ByTqsfBDwAqLibmuuQY6pgBQi5z1ErIsUOWBdw1bW9FSz5RZUojM4apg==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-typeof-symbol": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", + "integrity": "sha512-fz6J2Sf4gYN6gWgRZaoFXmq93X+Li/8vf+fb0sGDVtdeWvxC9y5/bTD7bvfWMEq6zetGEHpWjtzRGSugt5kNqw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0" + } + }, + "node_modules/babel-plugin-transform-es2015-unicode-regex": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", + "integrity": "sha512-v61Dbbihf5XxnYjtBN04B/JBvsScY37R1cZT5r9permN1cp+b70DY3Ib3fIkgn1DI9U3tGgBJZVD8p/mE/4JbQ==", + "dev": true, + "dependencies": { + "babel-helper-regex": "^6.24.1", + "babel-runtime": "^6.22.0", + "regexpu-core": "^2.0.0" + } + }, + "node_modules/babel-plugin-transform-inline-consecutive-adds": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-inline-consecutive-adds/-/babel-plugin-transform-inline-consecutive-adds-0.4.3.tgz", + "integrity": "sha512-8D104wbzzI5RlxeVPYeQb9QsUyepiH1rAO5hpPpQ6NPRgQLpIVwkS/Nbx944pm4K8Z+rx7CgjPsFACz/VCBN0Q==", + "dev": true + }, + "node_modules/babel-plugin-transform-member-expression-literals": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-member-expression-literals/-/babel-plugin-transform-member-expression-literals-6.9.4.tgz", + "integrity": "sha512-Xq9/Rarpj+bjOZSl1nBbZYETsNEDDJSrb6Plb1sS3/36FukWFLLRysgecva5KZECjUJTrJoQqjJgtWToaflk5Q==", + "dev": true + }, + "node_modules/babel-plugin-transform-merge-sibling-variables": { + "version": "6.9.5", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-merge-sibling-variables/-/babel-plugin-transform-merge-sibling-variables-6.9.5.tgz", + "integrity": "sha512-xj/KrWi6/uP+DrD844h66Qh2cZN++iugEIgH8QcIxhmZZPNP6VpOE9b4gP2FFW39xDAY43kCmYMM6U0QNKN8fw==", + "dev": true + }, + "node_modules/babel-plugin-transform-minify-booleans": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-minify-booleans/-/babel-plugin-transform-minify-booleans-6.9.4.tgz", + "integrity": "sha512-9pW9ePng6DZpzGPalcrULuhSCcauGAbn8AeU3bE34HcDkGm8Ldt0ysjGkyb64f0K3T5ilV4mriayOVv5fg0ASA==", + "dev": true + }, + "node_modules/babel-plugin-transform-property-literals": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-property-literals/-/babel-plugin-transform-property-literals-6.9.4.tgz", + "integrity": "sha512-Pf8JHTjTPxecqVyL6KSwD/hxGpoTZjiEgV7nCx0KFQsJYM0nuuoCajbg09KRmZWeZbJ5NGTySABYv8b/hY1eEA==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + } + }, + "node_modules/babel-plugin-transform-regenerator": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", + "integrity": "sha512-LS+dBkUGlNR15/5WHKe/8Neawx663qttS6AGqoOUhICc9d1KciBvtrQSuc0PI+CxQ2Q/S1aKuJ+u64GtLdcEZg==", + "dev": true, + "dependencies": { + "regenerator-transform": "^0.10.0" + } + }, + "node_modules/babel-plugin-transform-regexp-constructors": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-regexp-constructors/-/babel-plugin-transform-regexp-constructors-0.4.3.tgz", + "integrity": "sha512-JjymDyEyRNhAoNFp09y/xGwYVYzT2nWTGrBrWaL6eCg2m+B24qH2jR0AA8V8GzKJTgC8NW6joJmc6nabvWBD/g==", + "dev": true + }, + "node_modules/babel-plugin-transform-remove-console": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-console/-/babel-plugin-transform-remove-console-6.9.4.tgz", + "integrity": "sha512-88blrUrMX3SPiGkT1GnvVY8E/7A+k6oj3MNvUtTIxJflFzXTw1bHkuJ/y039ouhFMp2prRn5cQGzokViYi1dsg==", + "dev": true + }, + "node_modules/babel-plugin-transform-remove-debugger": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-debugger/-/babel-plugin-transform-remove-debugger-6.9.4.tgz", + "integrity": "sha512-Kd+eTBYlXfwoFzisburVwrngsrz4xh9I0ppoJnU/qlLysxVBRgI4Pj+dk3X8F5tDiehp3hhP8oarRMT9v2Z3lw==", + "dev": true + }, + "node_modules/babel-plugin-transform-remove-undefined": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-remove-undefined/-/babel-plugin-transform-remove-undefined-0.5.0.tgz", + "integrity": "sha512-+M7fJYFaEE/M9CXa0/IRkDbiV3wRELzA1kKQFCJ4ifhrzLKn/9VCCgj9OFmYWwBd8IB48YdgPkHYtbYq+4vtHQ==", + "dev": true, + "dependencies": { + "babel-helper-evaluate-path": "^0.5.0" + } + }, + "node_modules/babel-plugin-transform-simplify-comparison-operators": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-simplify-comparison-operators/-/babel-plugin-transform-simplify-comparison-operators-6.9.4.tgz", + "integrity": "sha512-GLInxhGAQWJ9YIdjwF6dAFlmh4U+kN8pL6Big7nkDzHoZcaDQOtBm28atEhQJq6m9GpAovbiGEShKqXv4BSp0A==", + "dev": true + }, + "node_modules/babel-plugin-transform-strict-mode": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", + "integrity": "sha512-j3KtSpjyLSJxNoCDrhwiJad8kw0gJ9REGj8/CqL0HeRyLnvUNYV9zcqluL6QJSXh3nfsLEmSLvwRfGzrgR96Pw==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.22.0", + "babel-types": "^6.24.1" + } + }, + "node_modules/babel-plugin-transform-undefined-to-void": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-undefined-to-void/-/babel-plugin-transform-undefined-to-void-6.9.4.tgz", + "integrity": "sha512-D2UbwxawEY1xVc9svYAUZQM2xarwSNXue2qDIx6CeV2EuMGaes/0su78zlIDIAgE7BvnMw4UpmSo9fDy+znghg==", + "dev": true + }, + "node_modules/babel-preset-es2015": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", + "integrity": "sha512-XfwUqG1Ry6R43m4Wfob+vHbIVBIqTg/TJY4Snku1iIzeH7mUnwHA8Vagmv+ZQbPwhS8HgsdQvy28Py3k5zpoFQ==", + "deprecated": "๐Ÿ™Œ Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!", + "dev": true, + "dependencies": { + "babel-plugin-check-es2015-constants": "^6.22.0", + "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", + "babel-plugin-transform-es2015-block-scoping": "^6.24.1", + "babel-plugin-transform-es2015-classes": "^6.24.1", + "babel-plugin-transform-es2015-computed-properties": "^6.24.1", + "babel-plugin-transform-es2015-destructuring": "^6.22.0", + "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", + "babel-plugin-transform-es2015-for-of": "^6.22.0", + "babel-plugin-transform-es2015-function-name": "^6.24.1", + "babel-plugin-transform-es2015-literals": "^6.22.0", + "babel-plugin-transform-es2015-modules-amd": "^6.24.1", + "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", + "babel-plugin-transform-es2015-modules-umd": "^6.24.1", + "babel-plugin-transform-es2015-object-super": "^6.24.1", + "babel-plugin-transform-es2015-parameters": "^6.24.1", + "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", + "babel-plugin-transform-es2015-spread": "^6.22.0", + "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", + "babel-plugin-transform-es2015-template-literals": "^6.22.0", + "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", + "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", + "babel-plugin-transform-regenerator": "^6.24.1" + } + }, + "node_modules/babel-preset-es2017": { + "version": "6.24.1", + "resolved": "https://registry.npmjs.org/babel-preset-es2017/-/babel-preset-es2017-6.24.1.tgz", + "integrity": "sha512-3iPqwP/tBkRATDg9qKkuycGEi1FZCF9pYoa2orhBynoQEPIelORSbk5VqbBI6+UzAt0CGG2gOfj46fmUmuz32g==", + "deprecated": "๐Ÿ™Œ Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!", + "dev": true, + "dependencies": { + "babel-plugin-syntax-trailing-function-commas": "^6.22.0", + "babel-plugin-transform-async-to-generator": "^6.24.1" + } + }, + "node_modules/babel-preset-minify": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/babel-preset-minify/-/babel-preset-minify-0.5.2.tgz", + "integrity": "sha512-v4GL+kk0TfovbRIKZnC3HPbu2cAGmPAby7BsOmuPdMJfHV+4FVdsGXTH/OOGQRKYdjemBuL1+MsE6mobobhe9w==", + "dev": true, + "dependencies": { + "babel-plugin-minify-builtins": "^0.5.0", + "babel-plugin-minify-constant-folding": "^0.5.0", + "babel-plugin-minify-dead-code-elimination": "^0.5.2", + "babel-plugin-minify-flip-comparisons": "^0.4.3", + "babel-plugin-minify-guarded-expressions": "^0.4.4", + "babel-plugin-minify-infinity": "^0.4.3", + "babel-plugin-minify-mangle-names": "^0.5.1", + "babel-plugin-minify-numeric-literals": "^0.4.3", + "babel-plugin-minify-replace": "^0.5.0", + "babel-plugin-minify-simplify": "^0.5.1", + "babel-plugin-minify-type-constructors": "^0.4.3", + "babel-plugin-transform-inline-consecutive-adds": "^0.4.3", + "babel-plugin-transform-member-expression-literals": "^6.9.4", + "babel-plugin-transform-merge-sibling-variables": "^6.9.5", + "babel-plugin-transform-minify-booleans": "^6.9.4", + "babel-plugin-transform-property-literals": "^6.9.4", + "babel-plugin-transform-regexp-constructors": "^0.4.3", + "babel-plugin-transform-remove-console": "^6.9.4", + "babel-plugin-transform-remove-debugger": "^6.9.4", + "babel-plugin-transform-remove-undefined": "^0.5.0", + "babel-plugin-transform-simplify-comparison-operators": "^6.9.4", + "babel-plugin-transform-undefined-to-void": "^6.9.4", + "lodash": "^4.17.11" + } + }, + "node_modules/babel-register": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", + "integrity": "sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A==", + "dev": true, + "dependencies": { + "babel-core": "^6.26.0", + "babel-runtime": "^6.26.0", + "core-js": "^2.5.0", + "home-or-tmp": "^2.0.0", + "lodash": "^4.17.4", + "mkdirp": "^0.5.1", + "source-map-support": "^0.4.15" + } + }, + "node_modules/babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "dev": true, + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "node_modules/babel-template": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", + "integrity": "sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.26.0", + "babel-traverse": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "lodash": "^4.17.4" + } + }, + "node_modules/babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA==", + "dev": true, + "dependencies": { + "babel-code-frame": "^6.26.0", + "babel-messages": "^6.23.0", + "babel-runtime": "^6.26.0", + "babel-types": "^6.26.0", + "babylon": "^6.18.0", + "debug": "^2.6.8", + "globals": "^9.18.0", + "invariant": "^2.2.2", + "lodash": "^4.17.4" + } + }, + "node_modules/babel-traverse/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/babel-traverse/node_modules/globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babel-traverse/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.26.0", + "esutils": "^2.0.2", + "lodash": "^4.17.4", + "to-fast-properties": "^1.0.3" + } + }, + "node_modules/babel-types/node_modules/to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/babelify": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-10.0.0.tgz", + "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true, + "bin": { + "babylon": "bin/babylon.js" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "dev": true, + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, + "node_modules/benchmark": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz", + "integrity": "sha512-l9MlfN4M1K/H2fbhfMy3B7vJd6AGKJVQn2h6Sg/Yx+KckoUA7ewS5Vv6TjSq18ooE1kS9hhAlQRH3AkXIh/aOQ==", + "dev": true, + "dependencies": { + "lodash": "^4.17.4", + "platform": "^1.3.3" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", + "dev": true + }, + "node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, + "node_modules/body-parser": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "dev": true, + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.11.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, + "node_modules/browser-pack": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", + "dev": true, + "dependencies": { + "combine-source-map": "~0.8.0", + "defined": "^1.0.0", + "JSONStream": "^1.0.3", + "safe-buffer": "^5.1.1", + "through2": "^2.0.0", + "umd": "^3.0.0" + }, + "bin": { + "browser-pack": "bin/cmd.js" + } + }, + "node_modules/browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "dependencies": { + "resolve": "^1.17.0" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/browserify": { + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-17.0.1.tgz", + "integrity": "sha512-pxhT00W3ylMhCHwG5yfqtZjNnFuX5h2IJdaBfSo4ChaaBsIp9VLrEMQ1bHV+Xr1uLPXuNDDM1GlJkjli0qkRsw==", + "dev": true, + "dependencies": { + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^2.0.0", + "browserify-zlib": "~0.2.0", + "buffer": "~5.2.1", + "cached-path-relative": "^1.0.0", + "concat-stream": "^1.6.0", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.1", + "domain-browser": "^1.2.0", + "duplexer2": "~0.1.2", + "events": "^3.0.0", + "glob": "^7.1.0", + "hasown": "^2.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "^1.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.2.1", + "JSONStream": "^1.0.3", + "labeled-stream-splicer": "^2.0.0", + "mkdirp-classic": "^0.5.2", + "module-deps": "^6.2.3", + "os-browserify": "~0.3.0", + "parents": "^1.0.1", + "path-browserify": "^1.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum-object": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^3.0.0", + "stream-http": "^3.0.0", + "string_decoder": "^1.1.1", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "0.0.1", + "url": "~0.11.0", + "util": "~0.12.0", + "vm-browserify": "^1.0.0", + "xtend": "^4.0.0" + }, + "bin": { + "browserify": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "dev": true, + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "dependencies": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "dev": true, + "dependencies": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "node_modules/browserify-sign": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", + "dev": true, + "dependencies": { + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + } + }, + "node_modules/browserify-sign/node_modules/readable-stream": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "dependencies": { + "pako": "~1.0.5" + } + }, + "node_modules/browserslist": { + "version": "4.25.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.4.tgz", + "integrity": "sha512-4jYpcjabC606xJ3kw2QwGEZKX0Aw7sgQdZCvIK9dhVSPh76BKo+C+btT1RRofH7B+8iNpEbgGNVWiLki5q93yg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001737", + "electron-to-chromium": "^1.5.211", + "node-releases": "^2.0.19", + "update-browserslist-db": "^1.1.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "dev": true, + "dependencies": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", + "dev": true + }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==", + "dev": true + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/cached-path-relative": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", + "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", + "dev": true + }, + "node_modules/caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "dependencies": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001739", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001739.tgz", + "integrity": "sha512-y+j60d6ulelrNSwpPyrHdl+9mJnQzHBr08xm48Qno0nSk4h3Qojh+ziv2qE6rXf4k3tadF4o1J/1tAbVm1NtnA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/catharsis": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", + "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", + "dev": true, + "dependencies": { + "lodash": "^4.17.15" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/chai": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.5.0.tgz", + "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/cheerio": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.1.2.tgz", + "integrity": "sha512-IkxPpb5rS/d1IiLbHMgfPuS0FgiWTtFIm/Nj+2woXDLTZ7fOT2eqzgYbdMlLweqlHbsZjxEChoVK+7iph7jyQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cheerio-select": "^2.1.0", + "dom-serializer": "^2.0.0", + "domhandler": "^5.0.3", + "domutils": "^3.2.2", + "encoding-sniffer": "^0.2.1", + "htmlparser2": "^10.0.0", + "parse5": "^7.3.0", + "parse5-htmlparser2-tree-adapter": "^7.1.0", + "parse5-parser-stream": "^7.1.2", + "undici": "^7.12.0", + "whatwg-mimetype": "^4.0.0" + }, + "engines": { + "node": ">=20.18.1" + }, + "funding": { + "url": "https://github.com/cheeriojs/cheerio?sponsor=1" + } + }, + "node_modules/cheerio-select": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", + "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-select": "^5.1.0", + "css-what": "^6.1.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/cliui": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-9.0.1.tgz", + "integrity": "sha512-k7ndgKhwoQveBL+/1tqGJYNz097I7WOvwbmmU2AR5+magtbjPWQTS1C5vzGkBC8Ym8UWRzfKUzUUqFLypY4Q+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^7.2.0", + "strip-ansi": "^7.1.0", + "wrap-ansi": "^9.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-9.0.0.tgz", + "integrity": "sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/combine-source-map": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha512-UlxQ9Vw0b/Bt/KYwCFqdEwsQ1eL8d1gibiFb7lxQJFdvTgc2hIZi6ugsg+kyhzhPV+QEpUiEIwInIAIrgoEkrg==", + "dev": true, + "dependencies": { + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" + } + }, + "node_modules/combine-source-map/node_modules/convert-source-map": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "integrity": "sha512-Y8L5rp6jo+g9VEPgvqNfEopjTR4OTYct8lXlS8iVQdmnjDvbdbzYe9rjtFCB9egC86JoNCU61WRY+ScjkZpnIg==", + "dev": true + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/connect": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/connect/-/connect-3.7.0.tgz", + "integrity": "sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "finalhandler": "1.1.2", + "parseurl": "~1.3.3", + "utils-merge": "1.0.1" + }, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/connect/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/connect/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", + "dev": true + }, + "node_modules/constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==", + "dev": true + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/convert-source-map": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", + "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", + "dev": true + }, + "node_modules/cookie": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "dev": true, + "hasInstallScript": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dev": true, + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "dependencies": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" + } + }, + "node_modules/css-select": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", + "integrity": "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.1.0.tgz", + "integrity": "sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==", + "dev": true, + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/custom-event": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", + "integrity": "sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg==", + "dev": true + }, + "node_modules/dash-ast": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", + "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", + "dev": true + }, + "node_modules/date-format": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", + "integrity": "sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/default-require-extensions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.1.tgz", + "integrity": "sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==", + "dev": true, + "dependencies": { + "strip-bom": "^4.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-properties": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.0.tgz", + "integrity": "sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==", + "dev": true, + "dependencies": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/defined": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.1.tgz", + "integrity": "sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/deps-sort": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", + "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", + "dev": true, + "dependencies": { + "JSONStream": "^1.0.3", + "shasum-object": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" + }, + "bin": { + "deps-sort": "bin/cmd.js" + } + }, + "node_modules/des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/detect-indent": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", + "integrity": "sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A==", + "dev": true, + "dependencies": { + "repeating": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/detective": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", + "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", + "dev": true, + "dependencies": { + "acorn-node": "^1.8.2", + "defined": "^1.0.0", + "minimist": "^1.2.6" + }, + "bin": { + "detective": "bin/detective.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/di": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", + "integrity": "sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA==", + "dev": true + }, + "node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/dom-serialize": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", + "integrity": "sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ==", + "dev": true, + "dependencies": { + "custom-event": "~1.0.0", + "ent": "~2.2.0", + "extend": "^3.0.0", + "void-elements": "^2.0.0" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domain-browser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", + "dev": true, + "engines": { + "node": ">=0.4", + "npm": ">=1.2" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ] + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true + }, + "node_modules/electron-to-chromium": { + "version": "1.5.211", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.211.tgz", + "integrity": "sha512-IGBvimJkotaLzFnwIVgW9/UD/AOJ2tByUmeOrtqBfACSbAw5b1G0XpvdaieKyc7ULmbwXVx+4e4Be8pOPBrYkw==", + "dev": true, + "license": "ISC" + }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/encoding-sniffer": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz", + "integrity": "sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "^0.6.3", + "whatwg-encoding": "^3.1.1" + }, + "funding": { + "url": "https://github.com/fb55/encoding-sniffer?sponsor=1" + } + }, + "node_modules/encoding-sniffer/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/engine.io": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz", + "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==", + "dev": true, + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.4.1", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.11.0" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/engine.io-parser": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz", + "integrity": "sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/ent": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", + "integrity": "sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA==", + "dev": true + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-abstract": { + "version": "1.21.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.21.1.tgz", + "integrity": "sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.3", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has": "^1.0.3", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "internal-slot": "^1.0.4", + "is-array-buffer": "^3.0.1", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.10", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.2", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.4.3", + "safe-regex-test": "^1.0.0", + "string.prototype.trimend": "^1.0.6", + "string.prototype.trimstart": "^1.0.6", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.9" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-abstract/node_modules/object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-array-method-boxes-properly": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", + "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", + "dev": true + }, + "node_modules/es-set-tostringtag": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", + "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3", + "has": "^1.0.3", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, + "node_modules/es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", + "dev": true + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-plugin-prefer-arrow": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-prefer-arrow/-/eslint-plugin-prefer-arrow-1.2.3.tgz", + "integrity": "sha512-J9I5PKCOJretVuiZRGvPQxCbllxGAV/viI20JO3LYblAodofBxyMnZAJ+WGeClHgANnSJberTNoFWWjrWKBuXQ==", + "dev": true, + "peerDependencies": { + "eslint": ">=2.0.0" + } + }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/eslint/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/eslint/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/eslint/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/eslint/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esquery/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", + "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "dev": true + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "dev": true + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dev": true, + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/finalhandler/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/flat": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.1.tgz", + "integrity": "sha512-FmTtBsHskrU6FJ2VxCnsDb84wu9zhmO3cUX2kGFb5tuwhfXxGciiT0oRY+cck35QmG+NmGh5eLz6lLCpWTqwpA==", + "dev": true, + "dependencies": { + "is-buffer": "~2.0.3" + }, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flat/node_modules/is-buffer": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", + "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "engines": { + "node": ">=4" + } + }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true + }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, + "node_modules/foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/fromentries": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.3.2.tgz", + "integrity": "sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/fs-extra": { + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", + "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-east-asian-width": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.3.1.tgz", + "integrity": "sha512-R1QfovbPsKmosqTnPoRFiJ7CF9MLRgb53ChvMZm+r4p76/+8yKDy17qLL2PKInORy2RkZZekuK0efYgmzTkXyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", + "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.3.tgz", + "integrity": "sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true, + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", + "dev": true, + "dependencies": { + "ansi-regex": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-ansi/node_modules/ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hash-base": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", + "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/hash-base/node_modules/readable-stream": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/hasha": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.2.tgz", + "integrity": "sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==", + "dev": true, + "dependencies": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hat": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/hat/-/hat-0.0.3.tgz", + "integrity": "sha512-zpImx2GoKXy42fVDSEad2BPKuSQdLcqsCYa48K3zHSzM/ugWuYjLDr8IXxpVuL7uCLHw56eaiLxCRthhOzf5ug==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/home-or-tmp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", + "integrity": "sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg==", + "dev": true, + "dependencies": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/htmlescape": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", + "integrity": "sha512-eVcrzgbR4tim7c7soKQKtxa/kQM4TzjnlU83rcZ9bHU6t31ehfV7SktN6McWgwPWg+JYMA/O3qpGxBvFq1z2Jg==", + "dev": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/htmlparser2": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.0.0.tgz", + "integrity": "sha512-TwAZM+zE5Tq3lrEHvOlvwgj1XLWQCtaaibSN11Q+gGBAS7Y1uZSWwXXRe4iF6OXnaq1riyQAPFOBtYc77Mxq0g==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.2.1", + "entities": "^6.0.0" + } + }, + "node_modules/htmlparser2/node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dev": true, + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-errors/node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-proxy": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz", + "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==", + "dev": true, + "dependencies": { + "eventemitter3": "^4.0.0", + "follow-redirects": "^1.0.0", + "requires-port": "^1.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==", + "dev": true + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.0.tgz", + "integrity": "sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-fresh/node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/inline-source-map": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", + "integrity": "sha512-0mVWSSbNDvedDWIN4wxLsdPM4a7cIPcpyMxj3QZ406QRwQ6ePGB1YIHxVPjqpcUGbWQ5C+nHTwGNWAGvt7ggVA==", + "dev": true, + "dependencies": { + "source-map": "~0.5.3" + } + }, + "node_modules/insert-module-globals": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.1.tgz", + "integrity": "sha512-ufS5Qq9RZN+Bu899eA9QCAYThY+gGW7oRkmb0vC93Vlyu/CFGcH0OYPEjVkDXA5FEbTt1+VWzdoOD3Ny9N+8tg==", + "dev": true, + "dependencies": { + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", + "is-buffer": "^1.1.0", + "JSONStream": "^1.0.3", + "path-is-absolute": "^1.0.1", + "process": "~0.11.0", + "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", + "xtend": "^4.0.0" + }, + "bin": { + "insert-module-globals": "bin/cmd.js" + } + }, + "node_modules/internal-slot": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", + "integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "dependencies": { + "loose-envify": "^1.0.0" + } + }, + "node_modules/is-arguments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", + "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-finite": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.1.0.tgz", + "integrity": "sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==", + "dev": true, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, + "node_modules/is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", + "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==", + "dev": true + }, + "node_modules/is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-windows": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/isbinaryfile": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", + "integrity": "sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw==", + "dev": true, + "engines": { + "node": ">= 8.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/gjtorikian/" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "dependencies": { + "append-transform": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-processinfo": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.3.tgz", + "integrity": "sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg==", + "dev": true, + "dependencies": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.3", + "istanbul-lib-coverage": "^3.2.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^8.3.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/js-string-escape": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz", + "integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/js2xmlparser": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz", + "integrity": "sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==", + "dev": true, + "dependencies": { + "xmlcreate": "^2.0.4" + } + }, + "node_modules/jsdoc": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.4.tgz", + "integrity": "sha512-zeFezwyXeG4syyYHbvh1A967IAqq/67yXtXvuL5wnqCkFZe8I0vKfm+EO+YEvLguo6w9CDUbrAXVtJSHh2E8rw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.20.15", + "@jsdoc/salty": "^0.2.1", + "@types/markdown-it": "^14.1.1", + "bluebird": "^3.7.2", + "catharsis": "^0.9.0", + "escape-string-regexp": "^2.0.0", + "js2xmlparser": "^4.0.2", + "klaw": "^3.0.0", + "markdown-it": "^14.1.0", + "markdown-it-anchor": "^8.6.7", + "marked": "^4.0.10", + "mkdirp": "^1.0.4", + "requizzle": "^0.2.3", + "strip-json-comments": "^3.1.0", + "underscore": "~1.13.2" + }, + "bin": { + "jsdoc": "jsdoc.js" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/jsdoc/node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/jsdoc/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", + "dev": true, + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dev": true, + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/karma": { + "version": "6.4.4", + "resolved": "https://registry.npmjs.org/karma/-/karma-6.4.4.tgz", + "integrity": "sha512-LrtUxbdvt1gOpo3gxG+VAJlJAEMhbWlM4YrFQgql98FwF7+K8K12LYO4hnDdUkNjeztYrOXEMqgTajSWgmtI/w==", + "dev": true, + "dependencies": { + "@colors/colors": "1.5.0", + "body-parser": "^1.19.0", + "braces": "^3.0.2", + "chokidar": "^3.5.1", + "connect": "^3.7.0", + "di": "^0.0.1", + "dom-serialize": "^2.2.1", + "glob": "^7.1.7", + "graceful-fs": "^4.2.6", + "http-proxy": "^1.18.1", + "isbinaryfile": "^4.0.8", + "lodash": "^4.17.21", + "log4js": "^6.4.1", + "mime": "^2.5.2", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.5", + "qjobs": "^1.2.0", + "range-parser": "^1.2.1", + "rimraf": "^3.0.2", + "socket.io": "^4.7.2", + "source-map": "^0.6.1", + "tmp": "^0.2.1", + "ua-parser-js": "^0.7.30", + "yargs": "^16.1.1" + }, + "bin": { + "karma": "bin/karma" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/karma-browserify": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/karma-browserify/-/karma-browserify-8.1.0.tgz", + "integrity": "sha512-q5OWuCfdXMfyhkRrH8XP5LiixD4lx0uCmlf6yQmGeQNHLH4Hoofur3tBJtSEhOXmY0mOdBe8ek2UUxicjmGqFQ==", + "dev": true, + "dependencies": { + "convert-source-map": "^1.8.0", + "hat": "^0.0.3", + "js-string-escape": "^1.0.0", + "lodash": "^4.17.21", + "minimatch": "^3.0.0", + "os-shim": "^0.1.3" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "browserify": ">=10 <18", + "karma": ">=4.3.0", + "watchify": ">=3 <5" + } + }, + "node_modules/karma-firefox-launcher": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.3.tgz", + "integrity": "sha512-LMM2bseebLbYjODBOVt7TCPP9OI2vZIXCavIXhkO9m+10Uj5l7u/SKoeRmYx8FYHTVGZSpk6peX+3BMHC1WwNw==", + "dev": true, + "dependencies": { + "is-wsl": "^2.2.0", + "which": "^3.0.0" + } + }, + "node_modules/karma-firefox-launcher/node_modules/which": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-3.0.1.tgz", + "integrity": "sha512-XA1b62dzQzLfaEOSQFTCOd5KFf/1VSzZo7/7TUjnya6u0vGGKzU96UQBZTAThCb2j4/xjBAyii1OhRLJEivHvg==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/karma-mocha": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-2.0.1.tgz", + "integrity": "sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ==", + "dev": true, + "dependencies": { + "minimist": "^1.2.3" + } + }, + "node_modules/karma-mocha-reporter": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/karma-mocha-reporter/-/karma-mocha-reporter-2.2.5.tgz", + "integrity": "sha512-Hr6nhkIp0GIJJrvzY8JFeHpQZNseuIakGac4bpw8K1+5F0tLb6l7uvXRa8mt2Z+NVwYgCct4QAfp2R2QP6o00w==", + "dev": true, + "dependencies": { + "chalk": "^2.1.0", + "log-symbols": "^2.1.0", + "strip-ansi": "^4.0.0" + }, + "peerDependencies": { + "karma": ">=0.13" + } + }, + "node_modules/karma-mocha-reporter/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/karma-mocha-reporter/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/karma-safari-launcher": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-1.0.0.tgz", + "integrity": "sha512-qmypLWd6F2qrDJfAETvXDfxHvKDk+nyIjpH9xIeI3/hENr0U3nuqkxaftq73PfXZ4aOuOChA6SnLW4m4AxfRjQ==", + "dev": true, + "peerDependencies": { + "karma": ">=0.9" + } + }, + "node_modules/karma/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/karma/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/karma/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/karma/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/karma/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/karma/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/klaw": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", + "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.9" + } + }, + "node_modules/labeled-stream-splicer": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", + "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "stream-splicer": "^2.0.0" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", + "dev": true + }, + "node_modules/lodash.memoize": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", + "integrity": "sha512-eDn9kqrAmVUC1wmZvlQ6Uhde44n+tXpqPrN8olQJbttgh0oKclk+SF54P47VEGE9CEiMeRwAP8BaM7UHvBkz2A==", + "dev": true + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "dependencies": { + "chalk": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/log4js": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-6.8.0.tgz", + "integrity": "sha512-g+V8gZyurIexrOvWQ+AcZsIvuK/lBnx2argejZxL4gVZ4Hq02kUYH6WZOnqxgBml+zzQZYdaEoTN84B6Hzm8Fg==", + "dev": true, + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "flatted": "^3.2.7", + "rfdc": "^1.3.0", + "streamroller": "^3.1.5" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dev": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it-anchor": { + "version": "8.6.7", + "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.7.tgz", + "integrity": "sha512-FlCHFwNnutLgVTflOYHPW2pPcl2AACqVzExlkGQNsi4CJgqOHN7YTgDd4LuhgN1BFO3TS0vLAruV1Td6dwWPJA==", + "dev": true, + "peerDependencies": { + "@types/markdown-it": "*", + "markdown-it": "*" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/marked": { + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.2.12.tgz", + "integrity": "sha512-yr8hSKa3Fv4D3jdZmtMMPghgVt6TWbk86WQaWhDloQjRSQhMMYCAro7jP7VDJrjjdV8pxVxMssXS8B8Y5DZ5aw==", + "dev": true, + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true + }, + "node_modules/mocha": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.3.tgz", + "integrity": "sha512-0R/3FvjIGH3eEuG17ccFPk117XL2rWxatr81a57D+r/x2uTYZRbdZ4oVidEUMh2W2TJDa7MdAb12Lm2/qrKajg==", + "dev": true, + "dependencies": { + "ansi-colors": "3.2.3", + "browser-stdout": "1.3.1", + "debug": "3.2.6", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "find-up": "3.0.0", + "glob": "7.1.3", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "3.13.1", + "log-symbols": "2.2.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.4", + "ms": "2.1.1", + "node-environment-flags": "1.0.5", + "object.assign": "4.1.0", + "strip-json-comments": "2.0.1", + "supports-color": "6.0.0", + "which": "1.3.1", + "wide-align": "1.1.3", + "yargs": "13.3.2", + "yargs-parser": "13.1.2", + "yargs-unparser": "1.6.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/mocha/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "dependencies": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "node_modules/mocha/node_modules/debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "deprecated": "Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/mocha/node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "node_modules/mocha/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/js-yaml": { + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/mocha/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/mkdirp": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz", + "integrity": "sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==", + "deprecated": "Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "node_modules/mocha/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/mocha/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mocha/node_modules/supports-color": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", + "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/mocha/node_modules/wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/mocha/node_modules/yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "node_modules/mocha/node_modules/yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "node_modules/module-deps": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.3.tgz", + "integrity": "sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA==", + "dev": true, + "dependencies": { + "browser-resolve": "^2.0.0", + "cached-path-relative": "^1.0.2", + "concat-stream": "~1.6.0", + "defined": "^1.0.0", + "detective": "^5.2.0", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "JSONStream": "^1.0.3", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.4.0", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" + }, + "bin": { + "module-deps": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha512-zkVhZUA3y8mbz652WrL5x0fB0ehrBkulWT3TomAQ9iDtyXZvzKeEA6GPxAItBYeNYl5yngKRX612qHOhvMkDeg==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-environment-flags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz", + "integrity": "sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ==", + "dev": true, + "dependencies": { + "object.getownpropertydescriptors": "^2.0.3", + "semver": "^5.7.0" + } + }, + "node_modules/node-environment-flags/node_modules/semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "dependencies": { + "process-on-spawn": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/node-releases": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.19.tgz", + "integrity": "sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/nyc": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-17.1.0.tgz", + "integrity": "sha512-U42vQ4czpKa0QdI1hu950XuNhYqgoM+ZF1HT+VuUHL9hPfDPVvNQyltmMqdE9bUHMVa+8yNbc3QKTj8zQhlVxQ==", + "dev": true, + "dependencies": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^3.3.0", + "get-package-type": "^0.1.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^6.0.2", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "bin": { + "nyc": "bin/nyc.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/nyc/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/nyc/node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/nyc/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/nyc/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/nyc/node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/nyc/node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/nyc/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/nyc/node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/nyc/node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.getownpropertydescriptors": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.5.tgz", + "integrity": "sha512-yDNzckpM6ntyQiGTik1fKV1DcVDRS+w8bvpWNCBanvH5LfRX9O8WTHqQzG4RZwRAM4I0oU7TV11Lj5v0g20ibw==", + "dev": true, + "dependencies": { + "array.prototype.reduce": "^1.0.5", + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==", + "dev": true + }, + "node_modules/os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/os-shim": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", + "integrity": "sha512-jd0cvB8qQ5uVt0lvCIexBaROw1KyKm5sbulg2fWOHjETisuCzWyt+eTZKEMs8v6HwzoGs8xik26jg7eCM6pS+A==", + "dev": true, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/outpipe": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", + "integrity": "sha512-BnNY/RwnDrkmQdUa9U+OfN/Y7AWmKuUPCCd+hbRclZnnANvYpO72zp/a6Q4n829hPbdqEac31XCcsvlEvb+rtA==", + "dev": true, + "peer": true, + "dependencies": { + "shell-quote": "^1.4.2" + } + }, + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parents": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", + "integrity": "sha512-mXKF3xkoUt5td2DoxpLmtOmZvko9VfFpwRwkKDHSNvgmpLAeBo18YDhcPbBzJq+QLCHMbGOfzia2cX4U+0v9Mg==", + "dev": true, + "dependencies": { + "path-platform": "~0.11.15" + } + }, + "node_modules/parse-asn1": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "dev": true, + "dependencies": { + "asn1.js": "^5.2.0", + "browserify-aes": "^1.0.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz", + "integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "domhandler": "^5.0.3", + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5-parser-stream": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz", + "integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==", + "dev": true, + "dependencies": { + "parse5": "^7.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/parse5/node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-platform": { + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", + "integrity": "sha512-Y30dB6rab1A/nfEKsZxmr01nUotHX0c/ZiIAsCTatEe1CmS5Pm5He7fZ195bPT7RdquoaL8lLxFCMQi/bS7IJg==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/pbkdf2": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "dev": true, + "dependencies": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/platform": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz", + "integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==", + "dev": true + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dev": true, + "dependencies": { + "fromentries": "^1.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", + "dev": true + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/qjobs": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", + "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", + "dev": true, + "engines": { + "node": ">=0.9" + } + }, + "node_modules/qs": { + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", + "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, + "node_modules/querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dev": true, + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/read-only-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", + "integrity": "sha512-3ALe0bjBVZtkdWKIcThYpQCLbBMd/+Tbh2CDSrAIDO3UsZ4Xs+tnyjv2MjCOMMgBG+AsUOeuP1cgtY1INISc8w==", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/readable-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/regenerate": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true + }, + "node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "node_modules/regenerator-transform": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", + "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "dev": true, + "dependencies": { + "babel-runtime": "^6.18.0", + "babel-types": "^6.19.0", + "private": "^0.1.6" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexpu-core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", + "integrity": "sha512-tJ9+S4oKjxY8IZ9jmjnp/mtytu1u3iyIQAfmI51IKWH6bFf7XR1ybtaO6j7INhZKXOTYADk7V5qxaqLkmNxiZQ==", + "dev": true, + "dependencies": { + "regenerate": "^1.2.1", + "regjsgen": "^0.2.0", + "regjsparser": "^0.1.4" + } + }, + "node_modules/regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g==", + "dev": true + }, + "node_modules/regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw==", + "dev": true, + "dependencies": { + "jsesc": "~0.5.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, + "node_modules/release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA==", + "dev": true, + "dependencies": { + "es6-error": "^4.0.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A==", + "dev": true, + "dependencies": { + "is-finite": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==", + "dev": true + }, + "node_modules/requizzle": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz", + "integrity": "sha512-JRrFk1D4OQ4SqovXOgdav+K8EAhSB/LJZqCz8tbX0KObcdeM15Ss59ozWMBWmmINMagCwmqn4ZNryUGpBsl6Jw==", + "dev": true, + "dependencies": { + "lodash": "^4.17.21" + } + }, + "node_modules/resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rfdc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", + "dev": true + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "node_modules/rollup": { + "version": "4.50.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.50.0.tgz", + "integrity": "sha512-/Zl4D8zPifNmyGzJS+3kVoyXeDeT/GrsJM94sACNg9RtUE0hrHa1bNPtRSrfHTMH5HjRzce6K7rlTh3Khiw+pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.50.0", + "@rollup/rollup-android-arm64": "4.50.0", + "@rollup/rollup-darwin-arm64": "4.50.0", + "@rollup/rollup-darwin-x64": "4.50.0", + "@rollup/rollup-freebsd-arm64": "4.50.0", + "@rollup/rollup-freebsd-x64": "4.50.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.50.0", + "@rollup/rollup-linux-arm-musleabihf": "4.50.0", + "@rollup/rollup-linux-arm64-gnu": "4.50.0", + "@rollup/rollup-linux-arm64-musl": "4.50.0", + "@rollup/rollup-linux-loongarch64-gnu": "4.50.0", + "@rollup/rollup-linux-ppc64-gnu": "4.50.0", + "@rollup/rollup-linux-riscv64-gnu": "4.50.0", + "@rollup/rollup-linux-riscv64-musl": "4.50.0", + "@rollup/rollup-linux-s390x-gnu": "4.50.0", + "@rollup/rollup-linux-x64-gnu": "4.50.0", + "@rollup/rollup-linux-x64-musl": "4.50.0", + "@rollup/rollup-openharmony-arm64": "4.50.0", + "@rollup/rollup-win32-arm64-msvc": "4.50.0", + "@rollup/rollup-win32-ia32-msvc": "4.50.0", + "@rollup/rollup-win32-x64-msvc": "4.50.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/rollup-plugin-node-resolve": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz", + "integrity": "sha512-jUlyaDXts7TW2CqQ4GaO5VJ4PwwaV8VUGA7+km3n6k6xtOEacf61u0VXwN80phY/evMcaS+9eIeJ9MOyDxt5Zw==", + "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-node-resolve.", + "dev": true, + "dependencies": { + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.11.1", + "rollup-pluginutils": "^2.8.1" + }, + "peerDependencies": { + "rollup": ">=1.11.0" + } + }, + "node_modules/rollup-plugin-npm": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-npm/-/rollup-plugin-npm-2.0.0.tgz", + "integrity": "sha512-FsEW/zQVMmgLawNpPFCxCIrx8RdRn9bLfnz/xQjI7U4HW5lNa0V3j1Tvyr0MA/rFpKG3Q3cWKYuCHKz1gM3U4g==", + "deprecated": "rollup-plugin-npm", + "dev": true + }, + "node_modules/rollup-pluginutils": { + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", + "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", + "dev": true, + "dependencies": { + "estree-walker": "^0.6.1" + } + }, + "node_modules/rsvp": { + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", + "dev": true, + "engines": { + "node": "6.* || >= 7.*" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/semver": { + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/shasum-object": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", + "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", + "dev": true, + "dependencies": { + "fast-safe-stringify": "^2.0.7" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/shell-quote": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.0.tgz", + "integrity": "sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/socket.io": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.4.tgz", + "integrity": "sha512-DcotgfP1Zg9iP/dH9zvAQcWrE0TtbMVwXmlV4T4mqsvY+gw+LqUGPfx2AoVyRk0FLME+GQhufDMyacFmw7ksqw==", + "dev": true, + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "cors": "~2.8.5", + "debug": "~4.3.2", + "engine.io": "~6.5.2", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz", + "integrity": "sha512-wDNHGXGewWAjQPt3pyeYBtpWSq9cLE5UW1ZUPL/2eGK9jtse/FpXib7epSTsz0Q0m+6sg6Y4KtcFTlah1bdOVg==", + "dev": true, + "dependencies": { + "debug": "~4.3.4", + "ws": "~8.11.0" + } + }, + "node_modules/socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "dev": true, + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.4.18", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", + "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "dev": true, + "dependencies": { + "source-map": "^0.5.6" + } + }, + "node_modules/spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "dependencies": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/stream-browserify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", + "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", + "dev": true, + "dependencies": { + "inherits": "~2.0.4", + "readable-stream": "^3.5.0" + } + }, + "node_modules/stream-browserify/node_modules/readable-stream": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha512-3PnJbYgS56AeWgtKF5jtJRT6uFJe56Z0Hc5Ngg/6sI6rIt8iiMBTa9cvdyFfpMQjaVHr8dusbNeFGIIonxOvKw==", + "dev": true, + "dependencies": { + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" + } + }, + "node_modules/stream-http": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", + "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", + "dev": true, + "dependencies": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "xtend": "^4.0.2" + } + }, + "node_modules/stream-http/node_modules/readable-stream": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-splicer": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", + "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" + } + }, + "node_modules/streamroller": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-3.1.5.tgz", + "integrity": "sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw==", + "dev": true, + "dependencies": { + "date-format": "^4.0.14", + "debug": "^4.3.4", + "fs-extra": "^8.1.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/streamroller/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, + "node_modules/streamroller/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/streamroller/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/string-width/node_modules/ansi-regex": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", + "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/string-width/node_modules/strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow==", + "dev": true, + "dependencies": { + "ansi-regex": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz", + "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz", + "integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/subarg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", + "integrity": "sha512-RIrIdRY0X1xojthNcVtgT9sjpOGagEUKpZdgBUi054OEPFo282yg+zE+t1Rj3+RqKq2xStL7uUHhY+AjbC4BXg==", + "dev": true, + "dependencies": { + "minimist": "^1.1.0" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/syntax-error": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", + "dev": true, + "dependencies": { + "acorn-node": "^1.2.0" + } + }, + "node_modules/taffydb": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.7.3.tgz", + "integrity": "sha512-GQ3gtYFSOAxSMN/apGtDKKkbJf+8izz5YfbGqIsUc7AMiQOapARZ76dhilRY2h39cynYxBFdafQo5HUL5vgkrg==", + "dev": true + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", + "dev": true + }, + "node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, + "node_modules/timers-browserify": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", + "integrity": "sha512-PIxwAupJZiYU4JmVZYwXp9FKsHMXb5h0ZEFyuXTAn8WLHOlcij+FEcbrvDsom1o5dr1YggEtFbECvGCW2sT53Q==", + "dev": true, + "dependencies": { + "process": "~0.11.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/tmp": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", + "integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==", + "dev": true, + "dependencies": { + "rimraf": "^3.0.0" + }, + "engines": { + "node": ">=8.17.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, + "node_modules/trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tty-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-detect": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.1.0.tgz", + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true + }, + "node_modules/typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "dependencies": { + "is-typedarray": "^1.0.0" + } + }, + "node_modules/ua-parser-js": { + "version": "0.7.33", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.33.tgz", + "integrity": "sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ], + "engines": { + "node": "*" + } + }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true + }, + "node_modules/umd": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", + "dev": true, + "bin": { + "umd": "bin/cli.js" + } + }, + "node_modules/unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undeclared-identifiers": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", + "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", + "dev": true, + "dependencies": { + "acorn-node": "^1.3.0", + "dash-ast": "^1.0.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + }, + "bin": { + "undeclared-identifiers": "bin.js" + } + }, + "node_modules/underscore": { + "version": "1.13.6", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz", + "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==", + "dev": true + }, + "node_modules/undici": { + "version": "7.15.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.15.0.tgz", + "integrity": "sha512-7oZJCPvvMvTd0OlqWsIxTuItTpJBpU1tcbVl24FMn3xt3+VSunwUasmfPJRE57oNO1KsZ4PgA1xTdAX4hq8NyQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/universalify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.3.tgz", + "integrity": "sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/uri-js/node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", + "dev": true, + "dependencies": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "node_modules/url/node_modules/punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==", + "dev": true + }, + "node_modules/util": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/util.promisify": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.1.1.tgz", + "integrity": "sha512-/s3UsZUrIfa6xDhr7zZhnE9SLQ5RIXyYfiVnMMyMDzOc8WhWN4Nbh36H842OyurKbCDAesZOJaVyvmSl6fhGQw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "for-each": "^0.3.3", + "has-symbols": "^1.0.1", + "object.getownpropertydescriptors": "^2.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "dev": true, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vm-browserify": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", + "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", + "dev": true + }, + "node_modules/void-elements": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/watchify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/watchify/-/watchify-4.0.0.tgz", + "integrity": "sha512-2Z04dxwoOeNxa11qzWumBTgSAohTC0+ScuY7XMenPnH+W2lhTcpEOJP4g2EIG/SWeLadPk47x++Yh+8BqPM/lA==", + "dev": true, + "peer": true, + "dependencies": { + "anymatch": "^3.1.0", + "browserify": "^17.0.0", + "chokidar": "^3.4.0", + "defined": "^1.0.0", + "outpipe": "^1.1.0", + "through2": "^4.0.2", + "xtend": "^4.0.2" + }, + "bin": { + "watchify": "bin/cmd.js" + }, + "engines": { + "node": ">= 8.10.0" + } + }, + "node_modules/watchify/node_modules/readable-stream": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.1.tgz", + "integrity": "sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ==", + "dev": true, + "peer": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/watchify/node_modules/through2": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", + "dev": true, + "peer": true, + "dependencies": { + "readable-stream": "3" + } + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-encoding/node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", + "dev": true + }, + "node_modules/which-typed-array": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", + "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/wide-align": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", + "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", + "dev": true, + "dependencies": { + "string-width": "^1.0.2 || 2" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/wrap-ansi/node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xmlcreate": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", + "integrity": "sha512-nquOebG4sngPmGPICTS5EnxqhKbCmz5Ox5hsszI2T6U5qdrJizBc+0ilYSEjTSzU0yZcmvppztXe/5Al5fUwdg==", + "dev": true + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yargs": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-18.0.0.tgz", + "integrity": "sha512-4UEqdc2RYGHZc7Doyqkrqiln3p9X2DZVxaGbwhn2pi7MrRagKaOcIKe8L3OxYcbhXLgLFUS3zAYuQjKBQgmuNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^9.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "string-width": "^7.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^22.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yargs-parser": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", + "dev": true, + "dependencies": { + "camelcase": "^4.1.0" + } + }, + "node_modules/yargs-parser/node_modules/camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/yargs-unparser": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", + "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", + "dev": true, + "dependencies": { + "flat": "^4.1.0", + "lodash": "^4.17.15", + "yargs": "^13.3.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/ansi-regex": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "dependencies": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, + "node_modules/yargs-unparser/node_modules/emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "node_modules/yargs-unparser/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/yargs-unparser/node_modules/string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "dependencies": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "dependencies": { + "ansi-regex": "^4.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs-unparser/node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/yargs-unparser/node_modules/yargs": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", + "dev": true, + "dependencies": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.2" + } + }, + "node_modules/yargs-unparser/node_modules/yargs-parser": { + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.5.0.tgz", + "integrity": "sha512-lb49vf1Xzfx080OKA0o6l8DQQpV+6Vg95zyCJX9VB/BqKYlhG7N4wgROUUHRA+ZPUefLnteQOad7z1kT2bV7bg==", + "dev": true, + "license": "MIT" + }, + "node_modules/yargs/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "22.0.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-22.0.0.tgz", + "integrity": "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=23" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/package.json b/package.json index a85fa04be..c1e7d78bc 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "async", "description": "Higher-order functions and common patterns for asynchronous code", - "version": "2.0.1", + "version": "3.2.6", "main": "dist/async.js", "author": "Caolan McMahon", + "homepage": "https://caolan.github.io/async/", "repository": { "type": "git", "url": "https://github.com/caolan/async.git" @@ -17,64 +18,58 @@ "module", "utility" ], - "dependencies": { - "lodash": "^4.14.0", - "lodash-es": "^4.14.0" - }, "devDependencies": { - "babel-core": "^6.3.26", - "babel-plugin-add-module-exports": "~0.1.2", - "babel-plugin-istanbul": "^1.0.3", - "babel-plugin-transform-es2015-modules-commonjs": "^6.3.16", + "@babel/core": "7.28.3", + "@babel/eslint-parser": "^7.16.5", + "babel-minify": "^0.5.0", + "babel-plugin-add-module-exports": "^1.0.4", + "babel-plugin-istanbul": "^7.0.0", + "babel-plugin-syntax-async-generators": "^6.13.0", + "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", "babel-preset-es2015": "^6.3.13", - "babelify": "^7.2.0", - "benchmark": "bestiejs/benchmark.js", - "bluebird": "^2.9.32", - "chai": "^3.1.0", - "cheerio": "^0.20.0", - "coveralls": "^2.11.2", - "es6-promise": "^2.3.0", - "eslint": "^2.11.1", - "fs-extra": "^0.26.7", - "gh-pages-deploy": "^0.4.2", - "jsdoc": "^3.4.0", - "karma": "^0.13.2", - "karma-browserify": "^4.2.1", - "karma-firefox-launcher": "^0.1.6", - "karma-mocha": "^0.2.0", - "karma-mocha-reporter": "^1.0.2", - "mocha": "^2.2.5", + "babel-preset-es2017": "^6.22.0", + "babel-register": "^6.26.0", + "babelify": "^10.0.0", + "benchmark": "^2.1.1", + "bluebird": "^3.4.6", + "browserify": "^17.0.0", + "chai": "^4.2.0", + "cheerio": "^1.0.0", + "es6-promise": "^4.2.8", + "eslint": "^8.6.0", + "eslint-plugin-prefer-arrow": "^1.2.3", + "fs-extra": "^11.1.1", + "jsdoc": "^4.0.3", + "karma": "^6.3.12", + "karma-browserify": "^8.1.0", + "karma-firefox-launcher": "^2.1.2", + "karma-mocha": "^2.0.1", + "karma-mocha-reporter": "^2.2.0", + "karma-safari-launcher": "^1.0.0", + "mocha": "^6.1.4", "native-promise-only": "^0.8.0-a", - "nyc": "^7.0.0", - "recursive-readdir": "^1.3.0", - "rimraf": "^2.5.0", - "rollup": "^0.25.0", - "rollup-plugin-node-resolve": "^1.5.0", - "rollup-plugin-npm": "~1.3.0", - "rsvp": "^3.0.18", - "semver": "^4.3.6", - "uglify-js": "~2.4.0", - "vinyl-buffer": "^1.0.0", - "vinyl-source-stream": "^1.1.0", - "yargs": "~3.9.1" + "nyc": "^17.0.0", + "rollup": "^4.2.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-npm": "^2.0.0", + "rsvp": "^4.8.5", + "semver": "^7.3.5", + "taffydb": "^2.7.3", + "yargs": "^18.0.0" }, "scripts": { "coverage": "nyc npm run mocha-node-test -- --grep @nycinvalid --invert", - "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", "jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js", - "lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/build/ support/*.js karma.conf.js", + "lint": "eslint --fix .", "mocha-browser-test": "karma start", - "mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register", + "mocha-node-test": "mocha", "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test", - "test": "npm run-script lint && npm run mocha-node-test" + "test": "npm run lint && npm run mocha-node-test" }, "license": "MIT", - "gh-pages-deploy": { - "staticpath": "docs" - }, "nyc": { "exclude": [ - "mocha_test" + "test" ] } } diff --git a/perf/benchmark.js b/perf/benchmark.js index f75e05d47..236acf6d3 100755 --- a/perf/benchmark.js +++ b/perf/benchmark.js @@ -2,13 +2,12 @@ var _ = require("lodash"); var Benchmark = require("benchmark"); -var exec = require("child_process").exec; -var execSync = require("child_process").execSync; +var {exec, execSync} = require("child_process"); var fs = require("fs"); var path = require("path"); var mkdirp = require("mkdirp"); -var async = require("../"); -var suiteConfigs = require("./suites"); +var async = require("../index.js"); +var suiteConfigs = require("./suites.js"); var semver = require("semver"); var args = require("yargs") @@ -60,7 +59,7 @@ console.log("Comparing " + version0 + " with " + version1 + console.log("--------------------------------------"); -async.eachSeries(versionNames, cloneVersion, function (err) { +async.eachSeries(versionNames, cloneVersion, (err) => { if (err) { throw err; } versions = versionNames.map(requireVersion); @@ -72,7 +71,7 @@ async.eachSeries(versionNames, cloneVersion, function (err) { .filter(doesNotMatch) .map(createSuite); - async.eachSeries(suites, runSuite, function () { + async.eachSeries(suites, runSuite, () => { var totalTime0 = +totalTime[version0].toPrecision(3); var totalTime1 = +totalTime[version1].toPrecision(3); @@ -105,7 +104,7 @@ async.eachSeries(versionNames, cloneVersion, function (err) { }); function runSuite(suite, callback) { - suite.on("complete", function () { + suite.on("complete", () => { callback(); }).run({async: true}); } @@ -117,8 +116,8 @@ function setDefaultOptions(suiteConfig) { } function handleMultipleArgs(list, suiteConfig) { - return list.concat(suiteConfig.args.map(function (args) { - return _.defaults({args: args}, suiteConfig); + return list.concat(suiteConfig.args.map((suiteArgs) => { + return _.defaults({args: suiteArgs}, suiteConfig); })); } @@ -137,7 +136,6 @@ function doesNotMatch(suiteConfig) { function createSuite(suiteConfig) { var suite = new Benchmark.Suite(); - var args = suiteConfig.args; var errored = false; function addBench(version, versionName) { @@ -145,51 +143,55 @@ function createSuite(suiteConfig) { try { suiteConfig.setup(1); - suiteConfig.fn(version, function () {}); + suiteConfig.fn(version, () => {}); } catch (e) { console.error(name + " Errored"); errored = true; return; } - suite.add(name, function (deferred) { - suiteConfig.fn(version, function () { - deferred.resolve(); - }); - }, _.extend({ - versionName: versionName, - setup: _.partial.apply(null, [suiteConfig.setup].concat(args)), - onError: function (err) { + var options = _.extend({ + versionName, + setup() { + suiteConfig.setup(...suiteConfig.args); + }, + onError (err) { console.log(err.stack); } - }, benchOptions)); + }, benchOptions); + + suite.add(name, (deferred) => { + suiteConfig.fn(version, () => { + deferred.resolve(); + }); + }, options); } addBench(versions[0], versionNames[0]); addBench(versions[1], versionNames[1]); - return suite.on('cycle', function(event) { + return suite.on('cycle', (event) => { var mean = event.target.stats.mean * 1000; console.log(event.target + ", " + mean.toPrecision(3) + "ms per run"); var version = event.target.options.versionName; if (errored) return; totalTime[version] += mean; }) - .on('error', function (err) { console.error(err); }) - .on('complete', function() { - if (!errored) { - var fastest = this.filter('fastest'); - if (fastest.length === 2) { - console.log("Tie"); - } else { - var winner = fastest[0].options.versionName; - console.log(winner + ' is faster'); - wins[winner]++; + .on('error', (err) => { console.error(err); }) + .on('complete', function() { + if (!errored) { + var fastest = this.filter('fastest'); + if (fastest.length === 2) { + console.log("Tie"); + } else { + var winner = fastest[0].options.versionName; + console.log(winner + ' is faster'); + wins[winner]++; + } } - } - console.log("--------------------------------------"); - }); + console.log("--------------------------------------"); + }); } @@ -206,23 +208,17 @@ function cloneVersion(tag, callback) { var versionDir = __dirname + "/versions/" + tag; mkdirp.sync(versionDir); - fs.open(versionDir + "/package.json", "r", function (err, handle) { + fs.open(versionDir + "/package.json", "r", (err, handle) => { if (!err) { // version has already been cloned - fs.close(handle); - return callback(); + return fs.close(handle, callback); } var repoPath = path.join(__dirname, ".."); var cmd = "git clone --branch " + tag + " " + repoPath + " " + versionDir; - exec(cmd, function (err) { - if (err) { - throw err; - } - callback(); - }); + exec(cmd, callback); }); } diff --git a/perf/memory.js b/perf/memory.js index 1edab2077..aee900698 100644 --- a/perf/memory.js +++ b/perf/memory.js @@ -7,18 +7,16 @@ var async = require("../"); global.gc(); var startMem = process.memoryUsage().heapUsed; -function waterfallTest(cb) { +function waterfallTest(done) { var functions = []; for(var i = 0; i < 10000; i++) { - functions.push(function leaky(next) { + functions.push((next) => { function func1(cb) {return cb(); } function func2(callback) { - if (true) { - callback(); - //return next(); // Should be callback here. - } + callback(); + //return next(); // Should be callback here. } function func3(cb) {return cb(); } @@ -31,7 +29,7 @@ function waterfallTest(cb) { }); } - async.parallel(functions, cb); + async.parallel(functions, done); } function reportMemory() { @@ -41,6 +39,6 @@ function reportMemory() { (+(increase / 1024).toPrecision(3)) + "kB"); } -waterfallTest(function () { +waterfallTest(() => { setTimeout(reportMemory, 0); }); diff --git a/perf/suites.js b/perf/suites.js index dfef9f610..6f8df32a5 100644 --- a/perf/suites.js +++ b/perf/suites.js @@ -10,11 +10,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.each(tasks, function(num, cb) { + fn(async, done) { + async.each(tasks, (num, cb) => { async.setImmediate(cb); }, done); } @@ -25,11 +25,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.eachSeries(tasks, function(num, cb) { + fn(async, done) { + async.eachSeries(tasks, (num, cb) => { async.setImmediate(cb); }, done); } @@ -40,11 +40,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.eachLimit(tasks, 4, function(num, cb) { + fn(async, done) { + async.eachLimit(tasks, 4, (num, cb) => { async.setImmediate(cb); }, done); } @@ -56,11 +56,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.map(tasks, function(num, cb) { + fn(async, done) { + async.map(tasks, (num, cb) => { async.setImmediate(cb); }, done); } @@ -71,11 +71,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.mapSeries(tasks, function(num, cb) { + fn(async, done) { + async.mapSeries(tasks, (num, cb) => { async.setImmediate(cb); }, done); } @@ -86,11 +86,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.mapLimit(tasks, 4, function(num, cb) { + fn(async, done) { + async.mapLimit(tasks, 4, (num, cb) => { async.setImmediate(cb); }, done); } @@ -101,13 +101,13 @@ module.exports = [{ [300], [10000] ], - setup: function(c) { + setup(c) { count = c; tasks = _.range(count); }, - fn: function(async, done) { - async.filter(tasks, function(num, cb) { - async.setImmediate(function() { + fn(async, done) { + async.filter(tasks, (num, cb) => { + async.setImmediate(() => { cb(null, num > (count / 2)); }); }, done); @@ -119,17 +119,35 @@ module.exports = [{ [300], [10000] ], - setup: function(c) { + setup(c) { count = c; tasks = _.range(count); }, - fn: function(async, done) { - async.filterLimit(tasks, 10, function(num, cb) { - async.setImmediate(function() { + fn(async, done) { + async.filterLimit(tasks, 10, (num, cb) => { + async.setImmediate(() => { cb(null, num > (count / 2)); }); }, done); } +}, { + name: "concat", + // args lists are passed to the setup function + args: [ + [10], + [300], + [10000] + ], + setup(num) { + tasks = _.range(num); + }, + fn(async, done) { + async.concat(tasks, (num, cb) => { + async.setImmediate(() => { + cb(null, [num]); + }); + }, done); + } }, { name: "eachOf", // args lists are passed to the setup function @@ -138,11 +156,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.eachOf(tasks, function(num, i, cb) { + fn(async, done) { + async.eachOf(tasks, (num, i, cb) => { async.setImmediate(cb); }, done); } @@ -153,11 +171,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.eachOfSeries(tasks, function(num, i, cb) { + fn(async, done) { + async.eachOfSeries(tasks, (num, i, cb) => { async.setImmediate(cb); }, done); } @@ -168,11 +186,11 @@ module.exports = [{ [300], [10000] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.eachOfLimit(tasks, 4, function(num, i, cb) { + fn(async, done) { + async.eachOfLimit(tasks, 4, (num, i, cb) => { async.setImmediate(cb); }, done); } @@ -183,14 +201,14 @@ module.exports = [{ [100], [1000] ], - setup: function(count) { - tasks = _.range(count).map(function() { + setup(num) { + tasks = _.range(num).map(() => { return function(cb) { setImmediate(cb); }; }); }, - fn: function(async, done) { + fn(async, done) { async.parallel(tasks, done); } }, { @@ -200,14 +218,14 @@ module.exports = [{ [100], [1000] ], - setup: function(count) { - tasks = _.range(count).map(function() { + setup(num) { + tasks = _.range(num).map(() => { return function(cb) { setImmediate(cb); }; }); }, - fn: function(async, done) { + fn(async, done) { async.series(tasks, done); } }, { @@ -217,34 +235,58 @@ module.exports = [{ [100], [1000] ], - setup: function(count) { + setup(num) { tasks = [ function(cb) { return cb(null, 1); } - ].concat(_.range(count).map(function(i) { + ].concat(_.range(num).map((i) => { return function(arg, cb) { - setImmediate(function() { + setImmediate(() => { cb(null, i); }); }; })); }, - fn: function(async, done) { + fn(async, done) { async.waterfall(tasks, done); } +}, { + name: "auto", + args: [ + [5], + [10], + [100] + ], + setup(num) { + tasks = { + dep1 (cb) { cb(null, 1); } + }; + _.times(num, (n) => { + var task = ['dep' + (n+1), function(results, cb) { + setImmediate(cb, null, n); + }]; + if (n > 2) task.unshift('dep' + n); + tasks['dep' + (n+2)] = task; + }); + }, + fn(async, done) { + async.auto(tasks, done); + } }, { name: "queue", args: [ + [10], + [100], [1000], [30000], [100000], [200000] ], - setup: function(count) { - tasks = count; + setup(num) { + tasks = num; }, - fn: function(async, done) { + fn(async, done) { var numEntries = tasks; var q = async.queue(worker, 1); for (var i = 1; i <= numEntries; i++) { @@ -260,18 +302,49 @@ module.exports = [{ setImmediate(callback); } } +}, { + name: "priorityQueue", + args: [ + [10], + [100], + [1000], + [30000], + [50000] + ], + setup(num) { + tasks = num; + }, + fn(async, done) { + var numEntries = tasks; + var q = async.priorityQueue(worker, 1); + for (var i = 1; i <= numEntries; i++) { + q.push({ + num: i + }, i); + } + + var completedCnt = 0; + + function worker(task, callback) { + completedCnt++; + if (completedCnt === numEntries) { + return done(); + } + setImmediate(callback); + } + } }, { name: "some - no short circuit- false", // args lists are passed to the setup function args: [ [500] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.some(tasks, function(i, cb) { - async.setImmediate(function() { + fn(async, done) { + async.some(tasks, (i, cb) => { + async.setImmediate(() => { cb(i >= 600); }); }, done); @@ -282,12 +355,12 @@ module.exports = [{ args: [ [500] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.some(tasks, function(i, cb) { - async.setImmediate(function() { + fn(async, done) { + async.some(tasks, (i, cb) => { + async.setImmediate(() => { cb(i >= 60); }); }, done); @@ -298,12 +371,12 @@ module.exports = [{ args: [ [500] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.every(tasks, function(i, cb) { - async.setImmediate(function() { + fn(async, done) { + async.every(tasks, (i, cb) => { + async.setImmediate(() => { cb(i <= 600); }); }, done); @@ -314,58 +387,58 @@ module.exports = [{ args: [ [500] ], - setup: function(count) { - tasks = _.range(count); + setup(num) { + tasks = _.range(num); }, - fn: function(async, done) { - async.every(tasks, function(i, cb) { - async.setImmediate(function() { + fn(async, done) { + async.every(tasks, (i, cb) => { + async.setImmediate(() => { cb(i <= 60); }); }, done); } }, { name: "defer nextTick", - fn: function(async, done) { + fn(async, done) { process.nextTick(done); } }, { name: "defer setImmediate", - fn: function(async, done) { + fn(async, done) { setImmediate(done); } }, { name: "defer async.nextTick", - fn: function(async, done) { + fn(async, done) { async.nextTick(done); } }, { name: "defer async.setImmediate", - fn: function(async, done) { + fn(async, done) { async.setImmediate(done); } }, { name: "defer setTimeout", - fn: function(async, done) { + fn(async, done) { setTimeout(done, 0); } }, { name: "ensureAsync sync", - fn: function(async, done) { - async.ensureAsync(function(cb) { + fn(async, done) { + async.ensureAsync((cb) => { cb(); })(done); } }, { name: "ensureAsync async", - fn: function(async, done) { - async.ensureAsync(function(cb) { + fn(async, done) { + async.ensureAsync((cb) => { setImmediate(cb); })(done); } }, { name: "ensureAsync async noWrap", - fn: function(async, done) { + fn(async, done) { (function(cb) { setImmediate(cb); }(done)); diff --git a/support/aliases.txt b/support/aliases.txt new file mode 100644 index 000000000..6758a0def --- /dev/null +++ b/support/aliases.txt @@ -0,0 +1,27 @@ +all every +allLimit everyLimit +allSeries everySeries +any some +anyLimit someLimit +anySeries someSeries +find detect +findLimit detectLimit +findSeries detectSeries +flatMap concat +flatMapLimit concatLimit +flatMapSeries concatSeries +forEach each +forEachSeries eachSeries +forEachLimit eachLimit +forEachOf eachOf +forEachOfSeries eachOfSeries +forEachOfLimit eachOfLimit +inject reduce +foldl reduce +foldr reduceRight +select filter +selectLimit filterLimit +selectSeries filterSeries +wrapSync asyncify +during whilst +doDuring doWhilst diff --git a/support/build.test.js b/support/build.test.js index cc5634834..095127011 100644 --- a/support/build.test.js +++ b/support/build.test.js @@ -1,93 +1,93 @@ // Smoke test for the CJS build -var methods = ["each", "waterfall", "queue", "eachSeries"]; -var expect = require('chai').expect; -var rollup = require('rollup').rollup; +var methods = ["each", "waterfall", "queue", "eachSeries", "forEachOf"]; +var {expect} = require('chai'); +var {rollup} = require('rollup'); var rollupPluginNodeResolve = require('rollup-plugin-node-resolve'); var fs = require('fs'); -var exec = require('child_process').exec; +var {exec} = require('child_process'); -describe("async main", function() { +describe("async main", () => { var async; - before(function() { + before(() => { async = require("../build/"); }); - it("should have methods", function() { - methods.forEach(function(methodName) { + it("should have methods", () => { + methods.forEach((methodName) => { expect(async[methodName]).to.be.a("function"); }); }); }); -describe("async umd", function() { +describe("async umd", () => { var async; - before(function() { + before(() => { async = require("../build/dist/async.js"); }); - it("should have methods", function() { - methods.forEach(function(methodName) { + it("should have methods", () => { + methods.forEach((methodName) => { expect(async[methodName]).to.be.a("function"); }); }); }); -describe("async umd minified", function() { +describe("async umd minified", () => { var async; - before(function() { + before(() => { async = require("../build/dist/async.min.js"); }); - it("should have methods", function() { - methods.forEach(function(methodName) { + it("should have methods", () => { + methods.forEach((methodName) => { expect(async[methodName]).to.be.a("function"); }); }); }); -methods.forEach(function (methodName) { - describe("async." + methodName, function () { +methods.forEach((methodName) => { + describe("async." + methodName, () => { var method; - before(function () { + before(() => { method = require("../build/" + methodName); }); - it("should require the individual method", function() { + it("should require the individual method", () => { expect(method).to.be.a("function"); }); }); }); -describe("ES Modules", function () { +describe("ES Modules", () => { var tmpDir = __dirname + "/../tmp"; var buildFile = __dirname + "/../tmp/es.test.js"; - before(function (done) { + before((done) => { if (fs.existsSync(tmpDir)) { return done(); } fs.mkdir(tmpDir, done); }); - before(function () { + before(() => { return rollup({ - entry: __dirname + "/es.test.js", + input: __dirname + "/es.test.js", plugins: [ rollupPluginNodeResolve() ] - }).then(function (bundle) { + }).then((bundle) => { return bundle.write({ format: "umd", - dest: buildFile + file: buildFile }); }); }); - it("should build a successful bundle", function (done) { - exec("node " + buildFile, function (err, stdout) { + it("should build a successful bundle", (done) => { + exec("node " + buildFile, (err, stdout) => { if (err) { return done(err); } expect(stdout).to.match(/42/); done(); diff --git a/support/build/aggregate-build.js b/support/build/aggregate-build.js deleted file mode 100644 index 61833b889..000000000 --- a/support/build/aggregate-build.js +++ /dev/null @@ -1,20 +0,0 @@ -import compileModules from './compile-modules'; -import rollup from 'rollup'; -import rimraf from 'rimraf/rimraf'; - -export default function buildBundle(options) { - function bundle() { - rollup.rollup({ - entry: options.outpath + '/index.js' - }).then(function ( bundle ) { - bundle.write({ - format: options.format, - moduleName: 'async', - dest: options.outfile - }); - rimraf.sync(options.outpath); - }).catch(console.error); - } - - compileModules(bundle, options); -} diff --git a/support/build/aggregate-bundle.js b/support/build/aggregate-bundle.js index 482bfcdef..452a1f1fa 100644 --- a/support/build/aggregate-bundle.js +++ b/support/build/aggregate-bundle.js @@ -1,9 +1,15 @@ -import aggregateBuild from './aggregate-build'; +const {rollup} = require('rollup'); +const nodeResolve = require('rollup-plugin-node-resolve'); -aggregateBuild({ - es6: true, - outpath:'build/build-modules-es6', - outfile: 'build/dist/async.js', - format: 'umd', - lodashRename: true -}); +rollup({ + input: 'build-es/index.js', + plugins: [ nodeResolve() ] +}) + .then(( bundle ) => { + return bundle.write({ + format: 'umd', + name: 'async', + file: 'build/dist/async.js' + }); + }) + .catch((err) => { throw err; }); diff --git a/support/build/aggregate-cjs.js b/support/build/aggregate-cjs.js deleted file mode 100644 index 077ca4988..000000000 --- a/support/build/aggregate-cjs.js +++ /dev/null @@ -1,9 +0,0 @@ -import aggregateBuild from './aggregate-build'; - -aggregateBuild({ - es6: true, - outpath:'build/build-modules-es6', - outfile: 'build/index.js', - format: 'cjs', - lodashRename: false -}); diff --git a/support/build/aggregate-module.js b/support/build/aggregate-module.js new file mode 100644 index 000000000..fde7e78a8 --- /dev/null +++ b/support/build/aggregate-module.js @@ -0,0 +1,15 @@ +const {rollup} = require('rollup'); +const nodeResolve = require('rollup-plugin-node-resolve'); + +rollup({ + input: 'build-es/index.js', + plugins: [ nodeResolve() ] +}) + .then(( bundle ) => { + return bundle.write({ + format: 'esm', + name: 'async', + file: 'build/dist/async.mjs' + }); + }) + .catch((err) => { throw err; }); diff --git a/support/build/compile-module.js b/support/build/compile-module.js new file mode 100755 index 000000000..38a4d383c --- /dev/null +++ b/support/build/compile-module.js @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +const yargs = require('yargs'); +const fs = require('fs'); +const {transformFile} = require('babel-core'); +const pluginCJS = require('babel-plugin-transform-es2015-modules-commonjs'); +const pluginModuleExports = require('babel-plugin-add-module-exports'); + +compileModule(yargs.argv, (err) => { + if (err) throw err; +}) + +function compileModule(options, callback) { + const {file, output} = options; + const plugins = [ + pluginModuleExports, + pluginCJS + ]; + + transformFile(file, { + babelrc: false, + ast: false, + plugins + }, (err, content) => { + if (err) return callback(err); + if (!output) { + process.stdout.write(content.code); + return callback(); + } + fs.writeFile(output, content.code, callback) + }) +} diff --git a/support/build/compile-modules.js b/support/build/compile-modules.js deleted file mode 100644 index 16aa1ca8c..000000000 --- a/support/build/compile-modules.js +++ /dev/null @@ -1,45 +0,0 @@ -import async from '../../lib'; -import {transformFile} from 'babel-core'; -import _ from 'lodash'; -import readdirR from 'recursive-readdir'; -import pluginCJS from 'babel-plugin-transform-es2015-modules-commonjs'; -import pluginModuleExports from 'babel-plugin-add-module-exports'; -import pluginLodashImportRename from './plugin-lodash-import-rename'; -import {join as joinPath} from 'path'; -import fs from 'fs-extra'; - -export default function(cb, options) { - options = _.defaults({}, options, { - path:'lib/', - outpath:'build', - es6: false, - lodashRename: false - }); - let plugins = []; - - if (options.lodashRename) { - plugins.push(pluginLodashImportRename); - } - if (!options.es6) { - plugins.push(pluginModuleExports); - plugins.push(pluginCJS); - } - - readdirR(options.path, [], function(err, files) { - fs.emptyDirSync(options.outpath); - fs.emptyDirSync(joinPath(options.outpath, 'internal')); - async.each(files, (file, callback) => { - let filename = file.startsWith(options.path) ? - file.slice(options.path.length) : - file; - - transformFile(file, { - babelrc: false, - plugins: plugins - }, function(err, content) { - let outpath = joinPath(options.outpath, filename); - fs.writeFile(outpath, content.code, callback); - }); - }, cb); - }); -} diff --git a/support/build/modules-cjs.js b/support/build/modules-cjs.js deleted file mode 100644 index 09632ffd4..000000000 --- a/support/build/modules-cjs.js +++ /dev/null @@ -1,3 +0,0 @@ -import compileModules from './compile-modules'; - -compileModules(function() {}, {es6: false}); diff --git a/support/build/plugin-lodash-import-rename.js b/support/build/plugin-lodash-import-rename.js deleted file mode 100644 index 6fe893bea..000000000 --- a/support/build/plugin-lodash-import-rename.js +++ /dev/null @@ -1,24 +0,0 @@ -import _ from 'lodash'; -import {dirname, sep} from 'path'; - -export default function() { - return { - visitor: { - - ImportDeclaration(path, mapping) { - let {node} = path; - let {value} = node.source; - - if (/\blodash\b/.test(value)) { - let f = mapping.file.opts.filename; - let dir = dirname(f).split(sep); - let relative = _.repeat('../', dir.length + 1); - - node.source.value = value.replace( - /\blodash\b/, - relative + 'node_modules/lodash-es'); - } - } - } - }; -} diff --git a/support/es.test.js b/support/es.test.js index 9f7fd5e59..9a307cdc6 100644 --- a/support/es.test.js +++ b/support/es.test.js @@ -1,17 +1,30 @@ // simple async example to test ES module build output -import {waterfall as waterfall} from "../build-es/index"; -import async from "../build-es/index"; +import {default as async, waterfall as wf, wrapSync} from "../build-es/index"; import constant from "../build-es/constant"; +import forEachOf from "../build-es/forEachOf"; -waterfall([ +wf([ constant(42), function (val, next) { - async.setImmediate(function () { + async.setImmediate(() => { next(null, val); }); + }, + wrapSync((a) => { return a; }), + function (val, next) { + async.forEachOf({a: 1}, (v, key, cb) => { + if (v !== 1 && key !== 'a') return cb(new Error('fail!')); + cb(); + }, (err) => { next (err, val)}); + }, + function (val, next) { + forEachOf([1, 2, 3], (v, key, cb) => { + val += key + cb() + }, (err) => { next(err, val - 3) }) } -], function (err, result) { +], (err, result) => { if (err) { throw err; } console.log(result); if (result !== 42) { diff --git a/support/generate-index.js b/support/generate-index.js new file mode 100644 index 000000000..060655147 --- /dev/null +++ b/support/generate-index.js @@ -0,0 +1,79 @@ +#!/usr/bin/env node +'use strict' + +const fs = require('fs') +const path = require('path') +require('babel-core/register') +const autoInject = require('../lib/autoInject').default + +generateIndex(err => { + if (err) throw err +}) + +function generateIndex(done) { + autoInject({ + entries: cb => readEntries(cb), + aliases: cb => loadAliases(cb), + template: cb => fs.readFile(path.join(__dirname, './index-template.js'), 'utf8', cb), + generated: (entries, aliases, template, cb) => { + cb(null, renderTemplate(entries, aliases, template)) + } + }, (err, results) => { + if (err) return done(err) + console.log(results.generated) + done() + }) +} + +function loadAliases (cb) { + const aliases = {} + fs.readFileSync(path.join(__dirname, 'aliases.txt'), 'utf8') + .split('\n') + .filter(Boolean) + .forEach(line => { + const [alias, src] = line.split(' ') + aliases[alias] = src + }) + cb(null, aliases) +} + +function readEntries (cb) { + const libDir = path.join(__dirname, '../lib') + fs.readdir(libDir, (err, files) => { + if (err) return cb(err) + cb(null, files + .map(file => path.basename(file, '.js')) + .filter(file => !file.match(/(^(index|internal)$)/))) + }) +} + +function renderTemplate(entries, aliases, template) { + return template + .replace( + `/*__imports__*/`, + entries + .map(entry => `import ${entry} from './${entry}'`) + .join('\n')) + .replace( + `/*__default_object__*/`, + entries + .map(entry => ` ${entry}`) + .join(',\n') + ',') + + .replace( + `/*__default_aliases__*/`, + Object.keys(aliases) + .map(alias => ` ${alias}: ${aliases[alias]}`) + .join(',\n')) + .replace( + `/*__exports__*/`, + entries + .map(entry => ` ${entry} as ${entry}`) + .join(',\n') + ',') + + .replace( + `/*__alias_exports__*/`, + Object.keys(aliases) + .map(alias => ` ${aliases[alias]} as ${alias}`) + .join(',\n')) +} diff --git a/support/index-template.js b/support/index-template.js new file mode 100644 index 000000000..58ba86702 --- /dev/null +++ b/support/index-template.js @@ -0,0 +1,80 @@ +/** + * 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 + */ + +/*__imports__*/ + +export default { +/*__default_object__*/ + + // aliases +/*__default_aliases__*/ +}; + +export { +/*__exports__*/ + + // Aliases +/*__alias_exports__*/ +}; diff --git a/support/jsdoc/jsdoc-custom.js b/support/jsdoc/jsdoc-custom.js index 0bce1fa53..0d233e6a4 100644 --- a/support/jsdoc/jsdoc-custom.js +++ b/support/jsdoc/jsdoc-custom.js @@ -1,5 +1,9 @@ /* eslint no-undef: "off" */ -$(function initSearchBar() { +if (typeof setImmediate !== 'function' && typeof async === 'object') { + window.setImmediate = async.setImmediate; +} + +$(() => { function matchSubstrs(methodName) { var tokens = []; var len = methodName.length; @@ -36,8 +40,8 @@ $(function initSearchBar() { url: 'https://api.github.com/search/issues?q=%QUERY+repo:caolan/async', cache: true, wildcard: '%QUERY', - transform: function(response) { - return $.map(response.items, function(issue) { + transform(response) { + return $.map(response.items, (issue) => { // if (issue.state !== 'open') { // return null; // } @@ -46,7 +50,7 @@ $(function initSearchBar() { name: issue.number + ': ' + issue.title, number: issue.number }; - }).sort(function(a, b) { + }).sort((a, b) => { return b.number - a.number; }); } @@ -76,7 +80,7 @@ $(function initSearchBar() { templates: { header: '

Issues

' } - }).on('typeahead:select', function(ev, suggestion) { + }).on('typeahead:select', (ev, suggestion) => { var host; if (location.origin != "null") { host = location.origin; @@ -94,12 +98,32 @@ $(function initSearchBar() { // handle source files } else if (suggestion.indexOf('.html') !== -1) { location.href = host + suggestion; - // handle searching from one of the source files or the home page - } else if (currentPage !== 'docs.html') { - location.href = host + 'docs.html#.' + suggestion; } else { - var $el = document.getElementById('.' + suggestion); - $('#main').animate({ scrollTop: $el.offsetTop - 60 }, 500); + var parenIndex = suggestion.indexOf('('); + if (parenIndex !== -1) { + suggestion = suggestion.substring(0, parenIndex-1); + } + + // handle searching from one of the source files or the home page + if (currentPage !== 'docs.html') { + location.href = host + 'docs.html#' + suggestion; + } else { + var $el = document.getElementById(suggestion); + $('#main-container').animate({ scrollTop: $el.offsetTop - 60 }, 500); + location.hash = '#'+suggestion; + } } - }); + }).focus(); + + function fixOldHash() { + var {hash} = window.location; + if (hash) { + var hashMatches = hash.match(/^#\.(\w+)$/); + if (hashMatches) { + window.location.hash = '#'+hashMatches[1]; + } + } + } + + fixOldHash(); }); diff --git a/support/jsdoc/jsdoc-fix-html.js b/support/jsdoc/jsdoc-fix-html.js index a45b383e1..483570393 100644 --- a/support/jsdoc/jsdoc-fix-html.js +++ b/support/jsdoc/jsdoc-fix-html.js @@ -1,26 +1,29 @@ -var async = require('../../dist/async'); +var async = require('../../dist/async.js'); var fs = require('fs-extra'); var path = require('path'); var $ = require('cheerio'); -var _ = require('lodash'); -var docsDir = path.join(__dirname, '../../docs'); +var VERSION = require('../../package.json').version; +var docsDir = path.join(__dirname, '../../docs/v3'); var pageTitle = 'Methods:'; var docFilename = 'docs.html'; var mainModuleFile = 'module-async.html'; -var mainSectionId = '#main'; +var mainScrollableSection = '#main-container'; var sectionTitleClass = '.page-title'; var HTMLFileBegin = '\n\n\n'; var HTMLFileHeadBodyJoin = '\n'; var HTMLFileEnd = ''; -var additionalFooterText = ' Documentation has been modified from the original. ' + - ' For more information, please see the async repository.'; - function generateHTMLFile(filename, $page, callback) { + var methodName = filename.match(/\/(\w+)\.js\.html$/); + if (methodName) { + var $thisMethodDocLink = $page.find('#toc').find('a[href="'+docFilename+'#'+methodName[1]+'"]'); + $thisMethodDocLink.parent().addClass('active'); + } + // generate an HTML file from a cheerio object var HTMLdata = HTMLFileBegin + $page.find('head').html() + HTMLFileHeadBodyJoin + $page.find('body').html() @@ -30,60 +33,33 @@ function generateHTMLFile(filename, $page, callback) { } function extractModuleFiles(files) { - return _.filter(files, function(file) { - return _.startsWith(file, 'module') && file !== mainModuleFile; + return files.filter((file) => { + return file.startsWith('module') && file !== mainModuleFile; }); } -function getSearchableInfo($page, callback) { - var $sourceLinks = $page.find('a[href$=".js.html"]'); - var sourceFiles = $sourceLinks.map(function() { - return $(this).attr('href'); - }).toArray().sort(); - - var $methodLinks = $page.find('nav').find('a'); - var methods = $methodLinks.map(function() { - var methodName = $(this).text(); - return (methodName === 'Home' ? null : methodName); - }).toArray().sort(); - - fs.mkdirsSync(path.join(docsDir, 'data')); - async.parallel([ - function(fileCallback) { - fs.writeJson(path.join(docsDir, 'data/sourceFiles.json'), sourceFiles, fileCallback); - }, - function(fileCallback) { - fs.writeJson(path.join(docsDir, 'data/methodNames.json'), methods, fileCallback); - } - ], callback); -} - function combineFakeModules(files, callback) { var moduleFiles = extractModuleFiles(files); - fs.readFile(path.join(docsDir, mainModuleFile), 'utf8', function(err, mainModuleData) { - if (err) return callback(err); + fs.readFile(path.join(docsDir, mainModuleFile), 'utf8', (fileErr, mainModuleData) => { + if (fileErr) return callback(fileErr); var $mainPage = $(mainModuleData); // each 'module' (category) has a separate page, with all of the // important information in a 'main' div. Combine all of these divs into // one on the actual module page (async) - async.eachSeries(moduleFiles, function(file, fileCallback) { - fs.readFile(path.join(docsDir, file), 'utf8', function(err, moduleData) { + async.eachSeries(moduleFiles, (file, fileCallback) => { + fs.readFile(path.join(docsDir, file), 'utf8', (err, moduleData) => { if (err) return fileCallback(err); var $modulePage = $(moduleData); var moduleName = $modulePage.find(sectionTitleClass).text(); $modulePage.find(sectionTitleClass).attr('id', moduleName.toLowerCase()); - $mainPage.find(mainSectionId).append($modulePage.find(mainSectionId).html()); + $mainPage.find(mainScrollableSection).append($modulePage.find(mainScrollableSection).html()); return fileCallback(); }); - }, function(err) { + }, (err) => { if (err) return callback(err); - - getSearchableInfo($mainPage, function(err) { - if (err) return callback(err); - generateHTMLFile(path.join(docsDir, docFilename), $mainPage, callback); - }); + generateHTMLFile(path.join(docsDir, docFilename), $mainPage, callback); }); }); } @@ -103,22 +79,52 @@ function applyPreCheerioFixes(data) { .replace(rIncorrectCFText, fixedCFText) // for return types, JSDoc doesn't allow replacing the link text, so it // needs to be done here - .replace(rIncorrectModuleText, function(match, moduleName, methodName) { + .replace(rIncorrectModuleText, (match, moduleName, methodName) => { return '>'+methodName+'<'; }); } -function fixToc($page, moduleFiles) { +function scrollSpyFix($page, $nav) { + // move everything into one big ul (for Bootstrap scroll-spy) + var $ul = $nav.children('ul'); + $ul.addClass('nav').addClass('methods'); + $ul.find('.methods').each(function() { + var $methodsList = $(this); + var $methods = $methodsList.find('[data-type="method"]'); + var $parentLi = $methodsList.parent(); + + $methodsList.remove(); + $methods.remove(); + $parentLi.after($methods); + $parentLi.addClass('toc-header'); + + }); + + $page.find('[data-type="method"]').addClass("toc-method"); + + $page.find('[id^="."]').each(function() { + var $ele = $(this); + var id = $(this).attr('id'); + $ele.attr('id', id.replace('.', '')); + }); +} + +function fixToc(file, $page, moduleFiles) { // remove `async` listing from toc - $page.find('li').find('a[href="'+mainModuleFile+'"]').parent().remove(); + $page.find('a[href="'+mainModuleFile+'"]').parent().remove(); // change toc title - $page.find('nav').children('h3').text(pageTitle); - $page.find('nav').children('h2').remove(); - + var $nav = $page.find('nav'); + $nav.attr('id', 'toc'); + $nav.children('h3').text(pageTitle); + $nav.children('h2').remove(); + + scrollSpyFix($page, $nav); + var isDocsFile = file === docFilename + var prependFilename = isDocsFile ? '' : docFilename; // make everything point to the same 'docs.html' page - _.each(moduleFiles, function(filename) { + moduleFiles.forEach((filename) => { $page.find('[href^="'+filename+'"]').each(function() { var $ele = $(this); var href = $ele.attr('href'); @@ -126,33 +132,35 @@ function fixToc($page, moduleFiles) { // category titles should sections title, while everything else // points to the correct listing if (href === filename) { - var moduleName = $ele.text().toLowerCase().replace(/\s/g, ''); - $ele.attr('href', docFilename+'#'+moduleName); + var moduleName = $ele.text().toLowerCase().replace(/\s/g, '').replace('.', ''); + $ele.attr('href', prependFilename+'#'+moduleName); } else { - $ele.attr('href', href.replace(filename, docFilename)); + $ele.attr('href', href.replace(filename, prependFilename).replace('#.', '#')); } }); }); } function fixFooter($page) { - // add a note to the footer that the documentation has been modified var $footer = $page.find('footer'); - $footer.append(additionalFooterText); - $page.find('#main').append($footer); + $page.find(mainScrollableSection).append($footer); } function fixModuleLinks(files, callback) { var moduleFiles = extractModuleFiles(files); - async.each(files, function(file, fileCallback) { + async.each(files, (file, fileCallback) => { var filePath = path.join(docsDir, file); - fs.readFile(filePath, 'utf8', function(err, fileData) { + fs.readFile(filePath, 'utf8', (err, fileData) => { if (err) return fileCallback(err); var $file = $(applyPreCheerioFixes(fileData)); - fixToc($file, moduleFiles); + var $vDropdown = $file.find('#version-dropdown'); + $vDropdown.find('.dropdown-toggle').contents().get(0).data = 'v'+VERSION+' '; + $vDropdown.find('a[href="'+docFilename+'"]').text('v'+VERSION); + + fixToc(file, $file, moduleFiles); fixFooter($file); $file.find('[href="'+mainModuleFile+'"]').attr('href', docFilename); generateHTMLFile(filePath, $file, fileCallback); @@ -165,27 +173,24 @@ fs.copySync(path.join(__dirname, './jsdoc-custom.js'), path.join(docsDir, 'scrip fs.copySync(path.join(__dirname, '..', '..', 'logo', 'favicon.ico'), path.join(docsDir, 'favicon.ico'), { clobber: true }); fs.copySync(path.join(__dirname, '..', '..', 'logo', 'async-logo.svg'), path.join(docsDir, 'img', 'async-logo.svg'), { clobber: true }); -fs.readdir(docsDir, function(err, files) { - if (err) { - throw err; - } +fs.readdir(docsDir, (readErr, files) => { + if (readErr) { throw readErr; } + + var HTMLFiles = files + .filter(file => path.extname(file) === '.html') + .filter(file => file !== 'docs.html') - var HTMLFiles = _.filter(files, function(file) { - return path.extname(file) === '.html'; - }); async.waterfall([ - function(callback) { - combineFakeModules(HTMLFiles, function(err) { - if (err) return callback(err); - HTMLFiles.push(docFilename); - return callback(null); - }); - }, + async.constant(HTMLFiles), + combineFakeModules, + async.asyncify(() => { + HTMLFiles.push(docFilename) + }), function(callback) { fixModuleLinks(HTMLFiles, callback); } - ], function(err) { + ], (err) => { if (err) throw err; console.log('Docs generated successfully'); }); diff --git a/support/jsdoc/jsdoc-import-path-plugin.js b/support/jsdoc/jsdoc-import-path-plugin.js index 3f0937ff0..905e15776 100644 --- a/support/jsdoc/jsdoc-import-path-plugin.js +++ b/support/jsdoc/jsdoc-import-path-plugin.js @@ -1,7 +1,7 @@ const path = require('path'); exports.handlers = { - jsdocCommentFound: function(e) { + jsdocCommentFound(e) { var moduleName = path.parse(e.filename).name; diff --git a/support/jsdoc/jsdoc.json b/support/jsdoc/jsdoc.json index c90c17254..28ee65638 100644 --- a/support/jsdoc/jsdoc.json +++ b/support/jsdoc/jsdoc.json @@ -11,7 +11,7 @@ "readme": "intro.md", "template": "support/jsdoc/theme", "encoding": "utf8", - "destination": "./docs", + "destination": "./docs/v3", "recurse": true }, "templates": { diff --git a/support/jsdoc/theme/publish.js b/support/jsdoc/theme/publish.js index fbfd61430..080e68d2c 100644 --- a/support/jsdoc/theme/publish.js +++ b/support/jsdoc/theme/publish.js @@ -1,25 +1,25 @@ /*global env: true */ 'use strict'; -var doop = require('jsdoc/util/doop'); -var fs = require('jsdoc/fs'); -var helper = require('jsdoc/util/templateHelper'); -var logger = require('jsdoc/util/logger'); -var path = require('jsdoc/path'); -var taffy = require('taffydb').taffy; -var template = require('jsdoc/template'); -var util = require('util'); - -var htmlsafe = helper.htmlsafe; -var linkto = helper.linkto; -var resolveAuthorLinks = helper.resolveAuthorLinks; -var scopeToPunc = helper.scopeToPunc; -var hasOwnProp = Object.prototype.hasOwnProperty; - -var data; -var view; - -var outdir = path.normalize(env.opts.destination); +const doop = require('jsdoc/util/doop'); +const fs = require('jsdoc/fs'); // jsdoc/fs offer non-standard functions (mkPath) +const fsExtra = require('fs-extra'); +const helper = require('jsdoc/util/templateHelper'); +const logger = require('jsdoc/util/logger'); +const path = require('jsdoc/path'); +const taffy = require('taffydb').taffy; +const template = require('jsdoc/template'); +const util = require('util'); + +const htmlsafe = helper.htmlsafe; +const linkto = helper.linkto; +const resolveAuthorLinks = helper.resolveAuthorLinks; +const hasOwnProp = Object.prototype.hasOwnProperty; + +let data; +let view; + +let outdir = path.normalize(env.opts.destination); function find(spec) { return helper.find(data, spec); @@ -36,14 +36,14 @@ function getAncestorLinks(doclet) { function hashToLink(doclet, hash) { if ( !/^(#.+)/.test(hash) ) { return hash; } - var url = helper.createLink(doclet); + let url = helper.createLink(doclet); url = url.replace(/(#.+|$)/, hash); return '' + hash + ''; } function needsSignature(doclet) { - var needsSig = false; + let needsSig = false; // function and class definitions always get a signature if (doclet.kind === 'function' || doclet.kind === 'class') { @@ -52,7 +52,7 @@ function needsSignature(doclet) { // typedefs that contain functions get a signature, too else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names && doclet.type.names.length) { - for (var i = 0, l = doclet.type.names.length; i < l; i++) { + for (let i = 0, l = doclet.type.names.length; i < l; i++) { if (doclet.type.names[i].toLowerCase() === 'function') { needsSig = true; break; @@ -64,7 +64,7 @@ function needsSignature(doclet) { } function getSignatureAttributes(item) { - var attributes = []; + const attributes = []; if (item.optional) { attributes.push('opt'); @@ -81,8 +81,8 @@ function getSignatureAttributes(item) { } function updateItemName(item) { - var attributes = getSignatureAttributes(item); - var itemName = item.name || ''; + const attributes = getSignatureAttributes(item); + let itemName = item.name || ''; if (item.variable) { itemName = '…' + itemName; @@ -97,16 +97,16 @@ function updateItemName(item) { } function addParamAttributes(params) { - return params.filter(function(param) { + return params.filter(param => { return param.name && param.name.indexOf('.') === -1; }).map(updateItemName); } function buildItemTypeStrings(item) { - var types = []; + const types = []; if (item && item.type && item.type.names) { - item.type.names.forEach(function(name) { + item.type.names.forEach(name => { types.push( linkto(name, htmlsafe(name)) ); }); } @@ -115,7 +115,7 @@ function buildItemTypeStrings(item) { } function buildAttribsString(attribs) { - var attribsString = ''; + let attribsString = ''; if (attribs && attribs.length) { attribsString = htmlsafe( util.format('(%s) ', attribs.join(', ')) ); @@ -125,9 +125,9 @@ function buildAttribsString(attribs) { } function addNonParamAttributes(items) { - var types = []; + let types = []; - items.forEach(function(item) { + items.forEach(item => { types = types.concat( buildItemTypeStrings(item) ); }); @@ -135,22 +135,22 @@ function addNonParamAttributes(items) { } function addSignatureParams(f) { - var params = f.params ? addParamAttributes(f.params) : []; + const params = f.params ? addParamAttributes(f.params) : []; f.signature = util.format( '%s(%s)', (f.signature || ''), params.join(', ') ); } function addSignatureReturns(f) { - var attribs = []; - var attribsString = ''; - var returnTypes = []; - var returnTypesString = ''; + const attribs = []; + let attribsString = ''; + let returnTypes = []; + let returnTypesString = ''; // jam all the return-type attributes into an array. this could create odd results (for example, // if there are both nullable and non-nullable return types), but let's assume that most people // who use multiple @return tags aren't using Closure Compiler type annotations, and vice-versa. if (f.returns) { - f.returns.forEach(function(item) { - helper.getAttribs(item).forEach(function(attrib) { + f.returns.forEach(item => { + helper.getAttribs(item).forEach(attrib => { if (attribs.indexOf(attrib) === -1) { attribs.push(attrib); } @@ -172,21 +172,21 @@ function addSignatureReturns(f) { } function addSignatureTypes(f) { - var types = f.type ? buildItemTypeStrings(f) : []; + const types = f.type ? buildItemTypeStrings(f) : []; f.signature = (f.signature || '') + '' + (types.length ? ' :' + types.join('|') : '') + ''; } function addAttribs(f) { - var attribs = helper.getAttribs(f); - var attribsString = buildAttribsString(attribs); + const attribs = helper.getAttribs(f); + const attribsString = buildAttribsString(attribs); f.attribs = util.format('%s', attribsString); } function shortenPaths(files, commonPrefix) { - Object.keys(files).forEach(function(file) { + Object.keys(files).forEach(file => { files[file].shortened = files[file].resolved.replace(commonPrefix, '') // always use forward slashes .replace(/\\/g, '/'); @@ -208,14 +208,14 @@ function getPathFromDoclet(doclet) { function generate(type, title, docs, filename, resolveLinks) { resolveLinks = resolveLinks === false ? false : true; - var docData = { + const docData = { type: type, title: title, docs: docs }; - var outpath = path.join(outdir, filename), - html = view.render('container.tmpl', docData); + const outpath = path.join(outdir, filename); + let html = view.render('container.tmpl', docData); if (resolveLinks) { html = helper.resolveLinks(html); // turn {@link foo} into foo @@ -226,10 +226,12 @@ function generate(type, title, docs, filename, resolveLinks) { function generateSourceFiles(sourceFiles, encoding) { encoding = encoding || 'utf8'; - Object.keys(sourceFiles).forEach(function(file) { - var source; + const sourceFilenames = []; + Object.keys(sourceFiles).forEach(file => { + let source; // links are keyed to the shortened path in each doclet's `meta.shortpath` property - var sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened); + const sourceOutfile = helper.getUniqueFilename(sourceFiles[file].shortened); + sourceFilenames.push(sourceOutfile); helper.registerLink(sourceFiles[file].shortened, sourceOutfile); try { @@ -241,9 +243,9 @@ function generateSourceFiles(sourceFiles, encoding) { catch(e) { logger.error('Error while generating source file %s: %s', file, e.message); } - generate('Source', sourceFiles[file].shortened, [source], sourceOutfile, false); }); + return sourceFilenames; } /** @@ -258,23 +260,23 @@ function generateSourceFiles(sourceFiles, encoding) { * @param {Array.} modules - The array of module doclets to search. */ function attachModuleSymbols(doclets, modules) { - var symbols = {}; + const symbols = {}; // build a lookup table - doclets.forEach(function(symbol) { + doclets.forEach(symbol => { symbols[symbol.longname] = symbols[symbol.longname] || []; symbols[symbol.longname].push(symbol); }); - return modules.map(function(module) { + return modules.map(module => { if (symbols[module.longname]) { module.modules = symbols[module.longname] // Only show symbols that have a description. Make an exception for classes, because // we want to show the constructor-signature heading no matter what. - .filter(function(symbol) { + .filter(symbol => { return symbol.description || symbol.kind === 'class'; }) - .map(function(symbol) { + .map(symbol => { symbol = doop(symbol); if (symbol.kind === 'class' || symbol.kind === 'function') { @@ -288,14 +290,14 @@ function attachModuleSymbols(doclets, modules) { } function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) { - var nav = ''; + let nav = ''; if (items && items.length) { - var itemsNav = ''; + let itemsNav = ''; - items.forEach(function(item) { - var methods = find({kind:'function', memberof: item.longname}); - var members = find({kind:'member', memberof: item.longname}); + items.forEach(item => { + const methods = find({kind:'function', memberof: item.longname}); + const members = find({kind:'member', memberof: item.longname}); if ( !hasOwnProp.call(item, 'longname') ) { itemsNav += '
  • ' + linktoFn('', item.name); @@ -305,7 +307,7 @@ function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) { if (methods.length) { itemsNav += "
      "; - methods.forEach(function (method) { + methods.forEach(method => { itemsNav += "
    • "; itemsNav += linkto(method.longname, method.name); itemsNav += "
    • "; @@ -349,9 +351,9 @@ function linktoExternal(longName, name) { * @return {string} The HTML for the navigation sidebar. */ function buildNav(members) { - var nav = '

      Home

      '; - var seen = {}; - var seenTutorials = {}; + let nav = '

      Home

      '; + const seen = {}; + const seenTutorials = {}; nav += buildMemberNav(members.classes, 'Classes', seen, linkto); nav += buildMemberNav(members.modules, 'Modules', {}, linkto); @@ -363,9 +365,9 @@ function buildNav(members) { nav += buildMemberNav(members.interfaces, 'Interfaces', seen, linkto); if (members.globals.length) { - var globalNav = ''; + let globalNav = ''; - members.globals.forEach(function(g) { + members.globals.forEach(g => { if ( g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname) ) { globalNav += '
    • ' + linkto(g.longname, g.name) + '
    • '; } @@ -384,26 +386,60 @@ function buildNav(members) { return nav; } +/** + Sorts an array of strings alphabetically + @param {Array} strArr - Array of strings to sort + @return {Array} The sorted array + */ +function sortStrs(strArr) { + return strArr.sort((s1, s2) => { + const lowerCaseS1 = s1.toLowerCase(); + const lowerCaseS2 = s2.toLowerCase(); + + if (lowerCaseS1 < lowerCaseS2) { + return -1; + } else if (lowerCaseS1 > lowerCaseS2) { + return 1; + } else { + return 0; + } + }); +} + +/** + Prints into /data a `methodNames.json` and a `sourceFiles.json` + JSON file that contains methods and files that can be searched on the + generated doc site. + @param {Array} methodNames - A list of method names + @param {Array} sourceFilenames - A list of source filenames + */ +function writeSearchData(methodNames, sourceFilenames) { + const dataDir = path.join(outdir, 'data'); + fsExtra.mkdirsSync(dataDir); + fsExtra.writeJsonSync(path.join(dataDir, 'methodNames.json'), sortStrs(methodNames), 'utf8'); + fsExtra.writeJsonSync(path.join(dataDir, 'sourceFiles.json'), sortStrs(sourceFilenames), 'utf8'); +} + /** @param {TAFFY} taffyData See . @param {object} opts @param {Tutorial} tutorials */ -exports.publish = function(taffyData, opts, tutorials) { +exports.publish = (taffyData, opts, tutorials) => { data = taffyData; - var conf = env.conf.templates || {}; + const conf = env.conf.templates || {}; conf.default = conf.default || {}; - var templatePath = path.normalize(opts.template); + const templatePath = path.normalize(opts.template); view = new template.Template( path.join(templatePath, 'tmpl') ); // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness // doesn't try to hand them out later - var indexUrl = helper.getUniqueFilename('index'); + const indexUrl = helper.getUniqueFilename('index'); // don't call registerLink() on this one! 'index' is also a valid longname - var globalUrl = helper.getUniqueFilename('global'); + const globalUrl = helper.getUniqueFilename('global'); helper.registerLink('global', globalUrl); // set up templating @@ -419,14 +455,14 @@ exports.publish = function(taffyData, opts, tutorials) { data.sort('longname, version, since'); helper.addEventListeners(data); - var sourceFiles = {}; - var sourceFilePaths = []; - data().each(function(doclet) { + let sourceFiles = {}; + const sourceFilePaths = []; + data().each(doclet => { doclet.attribs = ''; if (doclet.examples) { - doclet.examples = doclet.examples.map(function(example) { - var caption, code; + doclet.examples = doclet.examples.map(example => { + let caption, code; if (example.match(/^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) { caption = RegExp.$1; @@ -440,13 +476,13 @@ exports.publish = function(taffyData, opts, tutorials) { }); } if (doclet.see) { - doclet.see.forEach(function(seeItem, i) { + doclet.see.forEach((seeItem, i) => { doclet.see[i] = hashToLink(doclet, seeItem); }); } // build a list of source files - var sourcePath; + let sourcePath; if (doclet.meta) { sourcePath = getPathFromDoclet(doclet); sourceFiles[sourcePath] = { @@ -460,41 +496,41 @@ exports.publish = function(taffyData, opts, tutorials) { }); // update outdir if necessary, then create outdir - var packageInfo = ( find({kind: 'package'}) || [] ) [0]; + const packageInfo = ( find({kind: 'package'}) || [] ) [0]; if (packageInfo && packageInfo.name) { outdir = path.join( outdir, packageInfo.name, (packageInfo.version || '') ); } fs.mkPath(outdir); // copy the template's static files to outdir - var fromDir = path.join(templatePath, 'static'); - var staticFiles = fs.ls(fromDir, 3); + const fromDir = path.join(templatePath, 'static'); + const staticFiles = fs.ls(fromDir, 3); - staticFiles.forEach(function(fileName) { - var toDir = fs.toDir( fileName.replace(fromDir, outdir) ); + staticFiles.forEach(fileName => { + const toDir = fs.toDir( fileName.replace(fromDir, outdir) ); fs.mkPath(toDir); fs.copyFileSync(fileName, toDir); }); // copy user-specified static files to outdir - var staticFilePaths; - var staticFileFilter; - var staticFileScanner; + let staticFilePaths; + let staticFileFilter; + let staticFileScanner; if (conf.default.staticFiles) { // The canonical property name is `include`. We accept `paths` for backwards compatibility // with a bug in JSDoc 3.2.x. staticFilePaths = conf.default.staticFiles.include || conf.default.staticFiles.paths || []; - staticFileFilter = new (require('jsdoc/src/filter')).Filter(conf.default.staticFiles); - staticFileScanner = new (require('jsdoc/src/scanner')).Scanner(); + staticFileFilter = new (require('jsdoc/src/filter').Filter)(conf.default.staticFiles); + staticFileScanner = new (require('jsdoc/src/scanner').Scanner)(); - staticFilePaths.forEach(function(filePath) { - var extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter); + staticFilePaths.forEach(filePath => { + const extraStaticFiles = staticFileScanner.scan([filePath], 10, staticFileFilter); - extraStaticFiles.forEach(function(fileName) { - var sourcePath = fs.toDir(filePath); - var toDir = fs.toDir( fileName.replace(sourcePath, outdir) ); + extraStaticFiles.forEach(fileName => { + const sourcePath = fs.toDir(filePath); + const toDir = fs.toDir( fileName.replace(sourcePath, outdir) ); fs.mkPath(toDir); fs.copyFileSync(fileName, toDir); }); @@ -504,12 +540,12 @@ exports.publish = function(taffyData, opts, tutorials) { if (sourceFilePaths.length) { sourceFiles = shortenPaths( sourceFiles, path.commonPrefix(sourceFilePaths) ); } - data().each(function(doclet) { - var url = helper.createLink(doclet); + data().each(doclet => { + const url = helper.createLink(doclet); helper.registerLink(doclet.longname, url); // add a shortened version of the full path - var docletPath; + let docletPath; if (doclet.meta) { docletPath = getPathFromDoclet(doclet); docletPath = sourceFiles[docletPath].shortened; @@ -519,8 +555,8 @@ exports.publish = function(taffyData, opts, tutorials) { } }); - data().each(function(doclet) { - var url = helper.longnameToUrl[doclet.longname]; + data().each(doclet => { + const url = helper.longnameToUrl[doclet.longname]; if (url.indexOf('#') > -1) { doclet.id = helper.longnameToUrl[doclet.longname].split(/#/).pop(); @@ -537,8 +573,21 @@ exports.publish = function(taffyData, opts, tutorials) { }); // do this after the urls have all been generated - data().each(function(doclet) { + const methodNames = []; + data().each(doclet => { doclet.ancestors = getAncestorLinks(doclet); + if (doclet.kind === 'function') { + let alias = doclet.alias; + const name = doclet.name; + if (alias) { + if (Array.isArray(alias)) { + alias = alias.join(', '); + } + methodNames.push(name + ` (${alias})`); + } else { + methodNames.push(name); + } + } if (doclet.kind === 'member') { addSignatureTypes(doclet); @@ -552,12 +601,12 @@ exports.publish = function(taffyData, opts, tutorials) { } }); - var members = helper.getMembers(data); + const members = helper.getMembers(data); members.tutorials = tutorials.children; // output pretty-printed source files by default - var outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false - ? true + const outputSourceFiles = conf.default && conf.default.outputSourceFiles !== false + ? true : false; // add template helpers @@ -573,17 +622,20 @@ exports.publish = function(taffyData, opts, tutorials) { attachModuleSymbols( find({ longname: {left: 'module:'} }), members.modules ); // generate the pretty-printed source files first so other pages can link to them + let sourceFilenames = []; if (outputSourceFiles) { - generateSourceFiles(sourceFiles, opts.encoding); + sourceFilenames = generateSourceFiles(sourceFiles, opts.encoding); } - if (members.globals.length) { - generate('', 'Global', [{kind: 'globalobj'}], globalUrl); + writeSearchData(methodNames, sourceFilenames); + + if (members.globals.length) { + generate('', 'Global', [{kind: 'globalobj'}], globalUrl); } // index page displays information from package.json and lists files - var files = find({kind: 'file'}); - var packages = find({kind: 'package'}); + const files = find({kind: 'file'}); + const packages = find({kind: 'package'}); generate('', 'Home', packages.concat( @@ -592,40 +644,40 @@ exports.publish = function(taffyData, opts, tutorials) { indexUrl); // set up the lists that we'll use to generate pages - var classes = taffy(members.classes); - var modules = taffy(members.modules); - var namespaces = taffy(members.namespaces); - var mixins = taffy(members.mixins); - var externals = taffy(members.externals); - var interfaces = taffy(members.interfaces); - - Object.keys(helper.longnameToUrl).forEach(function(longname) { - var myModules = helper.find(modules, {longname: longname}); + const classes = taffy(members.classes); + const modules = taffy(members.modules); + const namespaces = taffy(members.namespaces); + const mixins = taffy(members.mixins); + const externals = taffy(members.externals); + const interfaces = taffy(members.interfaces); + + Object.keys(helper.longnameToUrl).forEach(longname => { + const myModules = helper.find(modules, {longname: longname}); if (myModules.length) { generate('Module', myModules[0].name, myModules, helper.longnameToUrl[longname]); } - var myClasses = helper.find(classes, {longname: longname}); + const myClasses = helper.find(classes, {longname: longname}); if (myClasses.length) { generate('Class', myClasses[0].name, myClasses, helper.longnameToUrl[longname]); } - var myNamespaces = helper.find(namespaces, {longname: longname}); + const myNamespaces = helper.find(namespaces, {longname: longname}); if (myNamespaces.length) { generate('Namespace', myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]); } - var myMixins = helper.find(mixins, {longname: longname}); + const myMixins = helper.find(mixins, {longname: longname}); if (myMixins.length) { generate('Mixin', myMixins[0].name, myMixins, helper.longnameToUrl[longname]); } - var myExternals = helper.find(externals, {longname: longname}); + const myExternals = helper.find(externals, {longname: longname}); if (myExternals.length) { generate('External', myExternals[0].name, myExternals, helper.longnameToUrl[longname]); } - var myInterfaces = helper.find(interfaces, {longname: longname}); + const myInterfaces = helper.find(interfaces, {longname: longname}); if (myInterfaces.length) { generate('Interface', myInterfaces[0].name, myInterfaces, helper.longnameToUrl[longname]); } @@ -633,15 +685,15 @@ exports.publish = function(taffyData, opts, tutorials) { // TODO: move the tutorial functions to templateHelper.js function generateTutorial(title, tutorial, filename) { - var tutorialData = { + const tutorialData = { title: title, header: tutorial.title, content: tutorial.parse(), children: tutorial.children }; - var tutorialPath = path.join(outdir, filename); - var html = view.render('tutorial.tmpl', tutorialData); + const tutorialPath = path.join(outdir, filename); + let html = view.render('tutorial.tmpl', tutorialData); // yes, you can use {@link} in tutorials too! html = helper.resolveLinks(html); // turn {@link foo} into foo @@ -650,11 +702,11 @@ exports.publish = function(taffyData, opts, tutorials) { // tutorials can have only one parent so there is no risk for loops function saveChildren(node) { - node.children.forEach(function(child) { + node.children.forEach(child => { generateTutorial('Tutorial: ' + child.title, child, helper.tutorialToUrl(child.name)); saveChildren(child); }); } - + saveChildren(tutorials); }; diff --git a/support/jsdoc/theme/static/styles/jsdoc-default.css b/support/jsdoc/theme/static/styles/jsdoc-default.css index 76ade41e0..ef165bfa2 100644 --- a/support/jsdoc/theme/static/styles/jsdoc-default.css +++ b/support/jsdoc/theme/static/styles/jsdoc-default.css @@ -1,5 +1,3 @@ -@import url(https://fonts.googleapis.com/css?family=Montserrat:400,700); - * { box-sizing: border-box } @@ -112,22 +110,34 @@ tt, code, kbd, samp { bottom: 0; float: none; min-width: 360px; - overflow-y: auto; - padding-left: 16px; - padding-right: 16px; + overflow-y: hidden; +} + +#main-container { + position: relative; + width: 100%; + height: 100%; + overflow-y: scroll; + padding-left: 16px; + padding-right: 16px; } -#main h1 { +#main-container h1 { margin-top: 100px !important; padding-top: 0px; border-left: 2px solid #3391FE; } -#main h4 { - margin-top: 120px !important; - padding-top: 0px; +#main-container h4 { + padding-top: 120px; padding-left: 16px; margin-left: -16px; +} + +#main-container h4::before { + content: ''; + position: relative; + left: -16px; border-left: 2px solid #3391FE; } @@ -141,6 +151,39 @@ section, h1 { padding: 2em 30px 0; } +#toc > h3 { + margin-bottom: 0px; +} + +#toc > .methods > li { + padding: 0px 10px; +} + +#toc > .methods > li > a { + font-size: 12px; + padding: 0px; +} + +#toc > .methods > .toc-header { + margin-top: 10px; +} + +#toc > .methods > .toc-method { + padding: 0px; + margin: 0px 10px; +} + +#toc > .methods > .toc-method > a, +#toc > .methods > .toc-method > a.active { + padding: 0px 0px 0px 20px; + border-left: 1px solid #D8DCDF; + color: #98999A; +} + +#toc > .methods > .toc-method.active { + background-color: #E8E8E8; +} + .nav.navbar-right .navbar-form { padding: 0; margin: 6px 0px; @@ -339,7 +382,7 @@ nav > h2 > a { footer { max-width: 800px; - margin: 0 auto; + margin: 0 auto 4em; color: hsl(0, 0%, 56%); display: block; padding: 30px 30px 0; diff --git a/support/jsdoc/theme/tmpl/layout.tmpl b/support/jsdoc/theme/tmpl/layout.tmpl index fd998bb66..bff3b090e 100644 --- a/support/jsdoc/theme/tmpl/layout.tmpl +++ b/support/jsdoc/theme/tmpl/layout.tmpl @@ -7,38 +7,34 @@ - - + + + + + + - - - - - - - - - - +