{"id":22945120,"url":"https://github.com/seregpie/throttleasync","last_synced_at":"2025-04-01T21:43:45.670Z","repository":{"id":57140008,"uuid":"253491480","full_name":"SeregPie/throttleAsync","owner":"SeregPie","description":"Creates a throttled function.","archived":false,"fork":false,"pushed_at":"2020-04-07T15:41:26.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:58:25.334Z","etag":null,"topics":["async","delay","function","promise","throttle"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/SeregPie.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}},"created_at":"2020-04-06T12:31:12.000Z","updated_at":"2020-04-07T15:44:34.000Z","dependencies_parsed_at":"2022-09-05T01:30:18.554Z","dependency_job_id":null,"html_url":"https://github.com/SeregPie/throttleAsync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2FthrottleAsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2FthrottleAsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2FthrottleAsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeregPie%2FthrottleAsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeregPie","download_url":"https://codeload.github.com/SeregPie/throttleAsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246716842,"owners_count":20822529,"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","delay","function","promise","throttle"],"created_at":"2024-12-14T14:29:44.772Z","updated_at":"2025-04-01T21:43:45.648Z","avatar_url":"https://github.com/SeregPie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# throttleAsync\n\n`throttleAsync(func, delay = 0, trailing = false)`\n\nCreates a throttled function.\n\n| argument | description |\n| ---: | :--- |\n| `func` | A function to throttle. |\n| `delay` | A number as the delay. |\n| `trailing` | If `true`, the function is invoked on the trailing edge of the delay. |\n\nReturns a new function.\n\n## setup\n\n### npm\n\n```shell\nnpm install @seregpie/throttle-async\n```\n\n### ES module\n\n```javascript\nimport throttleAsync from '@seregpie/throttle-async';\n```\n\n### Node\n\n```javascript\nlet throttleAsync = require('@seregpie/throttle-async');\n```\n\n### browser\n\n```html\n\u003cscript src=\"https://unpkg.com/@seregpie/throttle-async\"\u003e\u003c/script\u003e\n```\n\nThe function is globally available as `throttleAsync`.\n\n## usage\n\n```javascript\nlet throttled = throttleAsync(async n =\u003e {\n  await new Promise(resolve =\u003e {\n    setTimeout(resolve, 2000);\n  });\n  return n;\n}, 1000);\nlet p0 = throttled(0);\nlet p1 = throttled(1);\nlet p2 = throttled(2);\nawait new Promise(resolve =\u003e {\n  setTimeout(resolve, 3000);\n});\nlet p3 = throttled(3);\nlet p4 = throttled(4);\nlet p5 = throttled(5);\nlet r = await Promise.all([p0, p1, p2, p3, p4, p5]);\n// =\u003e [0, 2, 2, 3, 5, 5]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseregpie%2Fthrottleasync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseregpie%2Fthrottleasync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseregpie%2Fthrottleasync/lists"}