{"id":19912377,"url":"https://github.com/nesterow/limiter","last_synced_at":"2026-05-14T09:31:42.903Z","repository":{"id":247859614,"uuid":"827046472","full_name":"nesterow/limiter","owner":"nesterow","description":"A promise pool with RPS limiter.","archived":false,"fork":false,"pushed_at":"2024-07-11T15:10:50.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T22:46:08.757Z","etag":null,"topics":["javascript","promise","promise-pool","promise-queue","request-throttler","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nesterow.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-10T23:13:14.000Z","updated_at":"2024-07-11T15:10:54.000Z","dependencies_parsed_at":"2024-07-11T02:26:34.145Z","dependency_job_id":null,"html_url":"https://github.com/nesterow/limiter","commit_stats":null,"previous_names":["nesterow/limiter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesterow%2Flimiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesterow%2Flimiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesterow%2Flimiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nesterow%2Flimiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nesterow","download_url":"https://codeload.github.com/nesterow/limiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241341722,"owners_count":19947104,"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":["javascript","promise","promise-pool","promise-queue","request-throttler","typescript"],"created_at":"2024-11-12T21:29:10.520Z","updated_at":"2026-05-14T09:31:42.846Z","avatar_url":"https://github.com/nesterow.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Limiter\n\nA promise pool with RPS limiter.\n\nFeatures:\n\n- [x] TypeScript first\n- [x] Limits parrallel promises execution\n- [x] Limits RPS (requests per second), evenly distributes the requests over time\n- [x] Able to retry\n- [x] Simple API\n- [x] Simple async/await flow\n- [x] Allows to handle errors silently using onError callback\n- [x] Works with any runtime (Bun/Deno/Node)\n\n## Install\n\n```bash\nbun add github:nesterow/limiter # or pnpm\n```\n\n## API\n\n- limit - default 10\n- maxRetry - number of retries, use Infinity to retry until dead\n- rps - if set throttles task execution based on provided rate per second\n- onError() - if set, the errors are handled silently\n\n```typescript\nlimiter = new Limiter({\n  limit?: number;\n  maxRetry?: number;\n  rps?: number;\n  onError?: (error: Error) =\u003e Promise\u003cvoid\u003e | void;\n})\n```\n\n## Usage\n\n### Add tasks\n\n```typescript\nimport { Limiter } from \"@nesterow/limiter\";\n\nconst limiter = new Limiter({\n  limit: 20,\n});\n\nconst task = () =\u003e {\n  await fetch(url);\n};\n\nlimiter.process(task);\nlimiter.process(task);\nlimiter.process(task);\n\nawait limiter.done();\n```\n\n### Batch processing\n\n```typescript\nimport { Limiter } from \"@nesterow/limiter\";\n\nconst task = () =\u003e {\n  await fetch(\"https://my.api.xyz\");\n};\n\nconst limiter = new Limiter({\n  limit: 10,\n});\n\n// process 100 tasks, 10 at the same time\nawait limiter.process(...Array.from({ length: 100 }, () =\u003e task()));\n```\n\n### Limit RPS\n\n```typescript\nimport { Limiter } from \"@nesterow/limiter\";\n\nconst execEvery100ms = () =\u003e {\n  await fetch(\"https://my.api.xyz\");\n};\n\nconst limiter = new Limiter({\n  limit: 20,\n  rps: 10,\n});\n\n// trottle every 100ms\nawait limiter.process(...Array.from({ length: 100 }, () =\u003e execEvery100ms()));\n```\n\n### Retry\n\n```typescript\nimport { Limiter, LimiterRetryError } from \"@nesterow/limiter\";\n\nconst retry5times = () =\u003e {\n  await fetch(\"https://my.api.xyz\");\n  throw new Error(\"Connection refused\");\n};\n\nconst limiter = new Limiter({\n  limit: 20,\n  maxRetry: 5,\n});\n\nfor (let i = 0; i \u003c 100; i++) {\n  try {\n    await limiter.process(...Array.from({ length: 100 }, () =\u003e retry5times()));\n  } catch (e) {\n    if (e instanceof LimiterRetryError) {\n      // Logger.log(e)\n    }\n  }\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnesterow%2Flimiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnesterow%2Flimiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnesterow%2Flimiter/lists"}