{"id":13680676,"url":"https://github.com/transitive-bullshit/async-await-parallel","last_synced_at":"2025-08-08T21:13:10.394Z","repository":{"id":142589240,"uuid":"92785346","full_name":"transitive-bullshit/async-await-parallel","owner":"transitive-bullshit","description":"Node.js module with simple concurrency control for awaiting an array of async results","archived":false,"fork":false,"pushed_at":"2017-08-24T07:31:38.000Z","size":19,"stargazers_count":20,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T19:58:51.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/transitive-bullshit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-05-30T00:28:00.000Z","updated_at":"2024-06-17T03:24:54.000Z","dependencies_parsed_at":"2023-05-27T15:15:18.801Z","dependency_job_id":null,"html_url":"https://github.com/transitive-bullshit/async-await-parallel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/transitive-bullshit/async-await-parallel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Fasync-await-parallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Fasync-await-parallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Fasync-await-parallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Fasync-await-parallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transitive-bullshit","download_url":"https://codeload.github.com/transitive-bullshit/async-await-parallel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transitive-bullshit%2Fasync-await-parallel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267503556,"owners_count":24098331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:01:20.193Z","updated_at":"2025-07-28T10:39:45.835Z","avatar_url":"https://github.com/transitive-bullshit.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"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 \u003e= 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 () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\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 () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\n  async () =\u003e { ... },\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\u003casync Function(Void) =\u003e Any\u003e} thunks\n * @param {Number?} concurrency Max concurrency (defaults to 5)\n *\n * @return {Promise\u003cArray\u003cAny\u003e\u003e}\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitive-bullshit%2Fasync-await-parallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransitive-bullshit%2Fasync-await-parallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitive-bullshit%2Fasync-await-parallel/lists"}