{"_id":"async-await-parallel","_rev":"2-3822738977feb0f600cfb58f8592ffb1","name":"async-await-parallel","description":"Concurrency control for awaiting an array of async results","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"async-await-parallel","version":"1.0.0","description":"Concurrency control for awaiting an array of async results","main":"index.js","author":{"name":"Vidy"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/Vidy/async-await-parallel.git"},"keywords":["async","await","promise","parallel","concurrent","map","limit"],"scripts":{"test":"mocha --harmony && npm run lint","lint":"eslint ."},"devDependencies":{"eslint":"^3.7.1","eslint-config-standard":"^6.2.0","eslint-plugin-promise":"^3.4.1","eslint-plugin-standard":"^2.0.1","expect.js":"^0.3.1","mocha":"^3.2.0"},"gitHead":"26aaa440cf43359cb26c515cebe0dca72678d337","bugs":{"url":"https://github.com/Vidy/async-await-parallel/issues"},"homepage":"https://github.com/Vidy/async-await-parallel#readme","_id":"async-await-parallel@1.0.0","_shasum":"4913b0e0abfbec934a579331f8d8d75e31b0d349","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"dist":{"shasum":"4913b0e0abfbec934a579331f8d8d75e31b0d349","tarball":"https://registry.npmjs.org/async-await-parallel/-/async-await-parallel-1.0.0.tgz","integrity":"sha512-X2rEHEWLQjvbUNy6BBXwdofOeKTrWKYYhu9EtX0aGNl+Sx+E30jr0TfJ0VQFzWqFjo0v2MaRv+b3tL1PPZC7xA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4a4YRSVfx6X7YGC3Dm5Q9wF2F54YzDLwjToswLNGUGgIgImit9XNSm/rJRtFJq1kpSLWVvYjKK+10Mn3Z+Gvc7Lg="}]},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/async-await-parallel-1.0.0.tgz_1486444130532_0.25149756763130426"}}},"readme":"# async-await-parallel [![travis](https://img.shields.io/travis/Vidy/async-await-parallel.svg)](https://travis-ci.org/Vidy/async-await-parallel) [![npm](https://img.shields.io/npm/v/async-await-parallel.svg)](https://npmjs.org/package/async-await-parallel)\n\nThis module is a simple utility for limiting the concurrency of `await`ing async arrays in ES7. It replaces `Promise.all` when using `async` `await` much like `async.mapLimit` is commonly used in place of the analogous `async.map` when using callback-style async functions.\n\n### Installation\n\n```\nnpm install async-await-parallel\n```\n\nThis module uses async and await and therefore requires Node >= 7.\n\n### Background\n\nNormally, when you have an array of `async` operations that you want to `await` on, you would use `Promise.all`.\n\n```javascript\nawait Promise.all([\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n])\n```\n\nUnfortunately, there's nothing built into ES7's implementation of `async` `await` that allows you to limit the concurrency of how many async handlers are running at once.\n\nThis is problematic in many common scenarios such as performing operations on each file in a directory or downloading a batch of URLs without opening too many sockets or clogging IO bandwidth.\n\n### Usage\n\n`async-await-parallel` allows you to set a maximum concurrency for an array of async results you want to `await` on.\n\n```javascript\nconst parallel = require('async-await-parallel')\n\nawait parallel([\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n  async () => { ... },\n], 2)\n```\n\nIn this example, a max concurrency of 2 is set, so no more than 2 of the async functions may execute concurrently. Async functions will be executed in order once previous ones resolve.\n\n### API\n\n```javascript\n/**\n * Invokes an array of async functions in parallel with a limit to the maximum\n * number of concurrent invocations. Async functions are executed in-order and\n * the results are mapped to the return array.\n *\n * Acts as a replacement for `await Promise.all([ ... ])` by limiting the max\n * concurrency of the array of function invocations.\n *\n * If any single task fails (eg, returns a rejected Promise), the pool will drain\n * any remaining active tasks and reject the resulting Promsie.\n *\n * @param {Array<async Function(Void) => Any>} thunks\n * @param {Number?} concurrency Max concurrency (defaults to 5)\n *\n * @return {Promise<Array<Any>>}\n */\nasync function parallel (thunks, concurrency = 5)\n```\n\n### Inspiration\n\n* [async.mapLimit](http://caolan.github.io/async/) equivalent functionality for callbacks\n* [co-parallel](https://github.com/tj/co-parallel) equivalent functionality for co generators\n* [async-parallel](https://github.com/davetemplin/async-parallel) this library is heavily inspired by this TypeScript library for async / await by Dave Templin (simplified, converted from TS to ES, and added tests)\n\n### License\n\nMIT. Copyright (c) 2017 [Vidy](https://vidy.com).\n","maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"time":{"modified":"2022-06-13T03:36:20.233Z","created":"2017-02-07T05:08:50.756Z","1.0.0":"2017-02-07T05:08:50.756Z"},"homepage":"https://github.com/Vidy/async-await-parallel#readme","keywords":["async","await","promise","parallel","concurrent","map","limit"],"repository":{"type":"git","url":"git+ssh://git@github.com/Vidy/async-await-parallel.git"},"author":{"name":"Vidy"},"bugs":{"url":"https://github.com/Vidy/async-await-parallel/issues"},"license":"MIT","readmeFilename":"README.md"}