{"id":13724984,"url":"https://github.com/TomerAberbach/limit-concur","last_synced_at":"2025-05-07T19:32:12.010Z","repository":{"id":66020149,"uuid":"354442493","full_name":"TomerAberbach/limit-concur","owner":"TomerAberbach","description":"⚖️ Limit an async function's concurrency with ease!","archived":false,"fork":false,"pushed_at":"2024-10-15T03:31:16.000Z","size":762,"stargazers_count":22,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-04T21:13:39.311Z","etag":null,"topics":["async","concurrency","javascript","nodejs","npm-module","npm-package","promise","rate-limiting"],"latest_commit_sha":null,"homepage":"https://npm.im/limit-concur","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomerAberbach.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-04T02:56:44.000Z","updated_at":"2024-12-25T21:12:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd9ad69b-1e04-469b-b904-ae3e33ffc7e5","html_url":"https://github.com/TomerAberbach/limit-concur","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"0271b4c1620dccaa183b527c179820d749e0fff0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Flimit-concur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Flimit-concur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Flimit-concur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomerAberbach%2Flimit-concur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomerAberbach","download_url":"https://codeload.github.com/TomerAberbach/limit-concur/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252943827,"owners_count":21829317,"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","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":["async","concurrency","javascript","nodejs","npm-module","npm-package","promise","rate-limiting"],"created_at":"2024-08-03T01:02:08.760Z","updated_at":"2025-05-07T19:32:11.571Z","avatar_url":"https://github.com/TomerAberbach.png","language":"TypeScript","funding_links":["https://github.com/sponsors/TomerAberbach"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  limit-concur\n\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/limit-concur\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/limit-concur\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/TomerAberbach/limit-concur/actions\"\u003e\n    \u003cimg src=\"https://github.com/TomerAberbach/limit-concur/workflows/CI/badge.svg\" alt=\"CI\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://unpkg.com/limit-concur/dist/index.min.js\"\u003e\n    \u003cimg src=\"https://deno.bundlejs.com/?q=limit-concur\u0026badge\" alt=\"gzip size\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://unpkg.com/limit-concur/dist/index.min.js\"\u003e\n    \u003cimg src=\"https://deno.bundlejs.com/?q=limit-concur\u0026config={%22compression%22:{%22type%22:%22brotli%22}}\u0026badge\" alt=\"brotli size\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/sponsors/TomerAberbach\"\u003e\n    \u003cimg src=\"https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86\" alt=\"Sponsor\"\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  Limit an async function's concurrency with ease!\n\u003c/div\u003e\n\n## Features\n\n- **Tiny:** only ~320 B minzipped\n- **Flexible:** works for any function that returns a `Promise`\n\n## Install\n\n```sh\n$ npm i limit-concur\n```\n\n## Usage\n\n```js\nimport got from 'got'\nimport limitConcur from 'limit-concur'\n\nconst categories = await got(\n  `https://api.chucknorris.io/jokes/categories`,\n).json()\n\nconst getChuckNorrisJoke = async category =\u003e {\n  const { value } = await got(`https://api.chucknorris.io/jokes/random`, {\n    searchParams: {\n      category,\n    },\n  }).json()\n  return value\n}\n\nconst limitedGetChuckNorrisJoke = limitConcur(4, getChuckNorrisJoke)\n\n// At most 4 requests are pending at any given time!\nconst jokes = await Promise.all(categories.map(limitedGetChuckNorrisJoke))\nconsole.log(jokes)\n//=\u003e [\n//     'Chuck Norris once rode a nine foot grizzly bear through an automatic car wash, instead of taking a shower.',\n//     \"Chuck Norris is actually the front man for Apple. He let's Steve Jobs run the show when he's on a mission. Chuck Norris is always on a mission.\",\n//     \"Bill Gates thinks he's Chuck Norris. Chuck Norris actually laughed. Once.\",\n//     'Chuck Norris can install iTunes without installing Quicktime.',\n//     ...\n//   ]\n```\n\nYou can get an API equivalent to\n[`p-limit`](https://github.com/sindresorhus/p-limit) like so:\n\n```js\nimport limitConcur from 'limit-concur'\n\nconst limit = limitConcur(1, fn =\u003e fn())\n\nconst input = [\n  limit(() =\u003e fetchSomething(`foo`)),\n  limit(() =\u003e fetchSomething(`bar`)),\n  limit(() =\u003e doSomething()),\n]\n\nconst result = await Promise.all(input)\nconsole.log(result)\n//=\u003e [ ..., ..., ... ]\n```\n\n## Contributing\n\nStars are always welcome!\n\nFor bugs and feature requests,\n[please create an issue](https://github.com/TomerAberbach/limit-concur/issues/new).\n\nFor pull requests, please read the\n[contributing guidelines](https://github.com/TomerAberbach/limit-concur/blob/main/contributing.md).\n\n## License\n\n[Apache License 2.0](https://github.com/TomerAberbach/limit-concur/blob/main/license)\n\nThis is not an official Google product.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTomerAberbach%2Flimit-concur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTomerAberbach%2Flimit-concur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTomerAberbach%2Flimit-concur/lists"}