{"id":19277704,"url":"https://github.com/dsnsgithub/simple-call-limiter","last_synced_at":"2026-05-16T15:34:07.183Z","repository":{"id":223335147,"uuid":"760075086","full_name":"dsnsgithub/simple-call-limiter","owner":"dsnsgithub","description":"A simple function rate limiter that delays execution of functions based on a specified delay.","archived":false,"fork":false,"pushed_at":"2024-02-26T06:23:47.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T20:05:15.887Z","etag":null,"topics":["delay","npm","ratelimit"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dsnsgithub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2024-02-19T18:30:39.000Z","updated_at":"2024-02-19T21:17:28.000Z","dependencies_parsed_at":"2024-02-19T19:08:55.885Z","dependency_job_id":null,"html_url":"https://github.com/dsnsgithub/simple-call-limiter","commit_stats":null,"previous_names":["dsnsgithub/simple-call-limiter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnsgithub%2Fsimple-call-limiter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnsgithub%2Fsimple-call-limiter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnsgithub%2Fsimple-call-limiter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsnsgithub%2Fsimple-call-limiter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsnsgithub","download_url":"https://codeload.github.com/dsnsgithub/simple-call-limiter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240381228,"owners_count":19792425,"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":["delay","npm","ratelimit"],"created_at":"2024-11-09T21:06:41.417Z","updated_at":"2026-05-16T15:34:02.152Z","avatar_url":"https://github.com/dsnsgithub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Call Limiter\n\nA simple function rate limiter that delays execution of functions based on a specified delay.\n\n## Installation\n\nYou can install [simple-call-limiter](https://www.npmjs.com/package/simple-call-limiter) via npm:\n\n```bash\nnpm install simple-call-limiter\n```\n\n## API\n\n### SimpleLimiter(delayMs: number)\n\nCreates a new instance of SimpleDelay with the specified delay in milliseconds.\n\n- `delayMs`: The delay in milliseconds between function calls.\n\n### run(fn, ...args)\n\nRuns the provided function (with arguments) after ensuring the specified delay. If multiple calls are made within the delay period, they are queued and executed sequentially.\n\n- `fn`: The function to be executed.\n- `args`: Arguments to be passed to the function.\n\nReturns a Promise that resolves when the function is executed. If you are using Typescript, the arguments are checked and the output is a promise with the output type of the function.\n\n## Typescript Example\n\n```typescript\nimport SimpleLimiter from \"simple-call-limiter\";\n\n// Create a new instance of SimpleLimiter with a delay of 1000 milliseconds\nconst limiter = new SimpleLimiter(1000);\n\nfor (let i = 0; i \u003c 5; i++) {\n\tlimiter.run(console.log, i);\n}\n\n// output\n// 0 (immediate)\n// 1 (after 1 sec)\n// 2 (after 2 sec)\n// 3 (after 3 sec)\n// 4 (after 4 sec)\n```\n\n## JavaScript Example\n```javascript\nconst SimpleLimiter = require('simple-call-limiter').default;\n\n// Create a new instance of SimpleLimiter with a delay of 1000 milliseconds\nconst limiter = new SimpleLimiter(1000);\n\nfor (let i = 0; i \u003c 5; i++) {\n\tlimiter.run(console.log, i);\n}\n```\n\n## Typescript Promise Example\n```typescript\nimport SimpleLimiter from \"simple-call-limiter\";\n\n// Create a new instance of SimpleLimiter with a delay of 1000 milliseconds\nconst limiter = new SimpleLimiter(1000);\n\nasync function asyncTest(item: string) {\n\treturn item;\n}\n\nasync function run() {\n\tfor (let i = 0; i \u003c 5; i++) {\n\t\tconst result = await limiter.run(asyncTest, \"testing\");\n\t\tconst result2 = await limiter.run(asyncTest) //! this will be flagged since asyncTest takes an argument and none is given.\n\n\t\tconsole.log(typeof result); // type information is kept (string)\n\t\tconsole.log(result);\n\t}\n}\n\nrun();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsnsgithub%2Fsimple-call-limiter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsnsgithub%2Fsimple-call-limiter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsnsgithub%2Fsimple-call-limiter/lists"}