{"id":27881746,"url":"https://github.com/oleg-putseiko/function-performer","last_synced_at":"2026-01-22T18:57:48.505Z","repository":{"id":287528615,"uuid":"964375979","full_name":"oleg-putseiko/function-performer","owner":"oleg-putseiko","description":"Performer providing API for debounce, throttle and deduplication functions","archived":false,"fork":false,"pushed_at":"2025-04-13T10:50:56.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T02:55:31.639Z","etag":null,"topics":["debounce","deduplicate","function","performer","schedule","throttle"],"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/oleg-putseiko.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-11T05:52:00.000Z","updated_at":"2025-04-12T11:09:43.000Z","dependencies_parsed_at":"2025-05-05T05:04:43.610Z","dependency_job_id":"a8317c24-4f68-4f71-8f98-1ece44b6137d","html_url":"https://github.com/oleg-putseiko/function-performer","commit_stats":null,"previous_names":["oleg-putseiko/function-performer"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/oleg-putseiko/function-performer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-putseiko%2Ffunction-performer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-putseiko%2Ffunction-performer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-putseiko%2Ffunction-performer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-putseiko%2Ffunction-performer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleg-putseiko","download_url":"https://codeload.github.com/oleg-putseiko/function-performer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-putseiko%2Ffunction-performer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28668746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T17:07:18.858Z","status":"ssl_error","status_checked_at":"2026-01-22T17:05:02.040Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["debounce","deduplicate","function","performer","schedule","throttle"],"created_at":"2025-05-05T05:04:40.177Z","updated_at":"2026-01-22T18:57:48.494Z","avatar_url":"https://github.com/oleg-putseiko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# function-performer\n\n[![Latest Release](https://badgen.net/github/release/oleg-putseiko/function-performer?icon=github\u0026cache=240)](https://github.com/oleg-putseiko/function-performer/releases)\n[![Total Downloads](https://badgen.net/npm/dt/function-performer?icon=npm\u0026cache=240)](https://www.npmjs.com/package/function-performer)\n[![Install Size](https://badgen.net/packagephobia/install/function-performer?color=purple\u0026cache=240)](https://www.npmjs.com/package/function-performer)\n[![License](https://badgen.net/npm/license/function-performer?color=black\u0026cache=240)](https://github.com/oleg-putseiko/function-performer/blob/main/LICENSE.md)\n\n\u003c/div\u003e\n\nPerformer providing API for debounce, throttle, deduplication and limiting functions.\n\n**Contents:**\n\n- [Installation](#installation)\n- [API](#api)\n  - [Constructor](#constructor)\n    - [Parameters](#parameters)\n    - [Example](#example)\n  - [debounce](#debounce)\n    - [Parameters](#parameters-1)\n    - [Example](#example-1)\n  - [throttle](#throttle)\n    - [Parameters](#parameters-2)\n    - [Example](#example-2)\n  - [deduplicate](#deduplicate)\n    - [Parameters](#parameters-3)\n    - [Example](#example-3)\n  - [limit](#limit)\n    - [Parameters](#parameters-4)\n    - [Example](#example-4)\n\n## Installation\n\n```bash\nnpm install function-performer\n\n# or\npnpm install function-performer\n\n# or\nyarn add function-performer\n```\n\n## API\n\n### Constructor\n\nType: `new (config?: PerformerConfig): Performer`\n\n#### Parameters\n\n- `config` — Optional parameter providing the performer configuration.\n  - `debounce` - An optional property that provides a debounce configuration.\n    - `interval` - The time in milliseconds during which the target function execution will be discarded. _(default value is `0`)_\n  - `throttle` - An optional property that provides a throttle configuration.\n    - `interval` - The time in milliseconds during which the target function execution will be blocked. _(default value is `0`)_\n  - `deduplicate` - An optional property that provides a deduplication configuration.\n    - `interval` - The time in milliseconds during which duplicate detection will occur after calling the target function. _(default value is `0`)_\n  - `limit` - An optional property that provides a limitation configuration.\n    - `max` - Maximum number of function calls. _(default value is `Infinity`)_\n\n#### Example\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer({\n  debounce: { interval: 100 },\n  throttle: { interval: 100 },\n  deduplication: { interval: 100 },\n  limit: { max: 5 },\n});\n```\n\n### debounce\n\nType: `(func: DebouncedFunction, ...args: unknown[]) =\u003e void`\n\nDiscards execution of operations performed within the specified interval.\n\n#### Parameters\n\n- `func` — A function whose call will be discarded.\n- `...args` — A set of parameters for the function being performed.\n\n#### Example\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer({ debounce: { interval: 100 } });\n\nconst func = (arg: number) =\u003e {\n  console.log(arg);\n};\n\nperformer.debounce(func, 1); // will be discarded\nperformer.debounce(func, 2); // will be discarded\nperformer.debounce(func, 3); // logs `3`\n\nsetTimeout(() =\u003e {\n  performer.debounce(func, 4); // logs `4`\n}, 2000);\n```\n\nTo set a configuration for specific cases, pass it to the `debounce.with` function:\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer();\n\nconst debounce = performer.debounce.with({ interval: 100 });\n\nconst func = (arg: number) =\u003e {\n  console.log(arg);\n};\n\ndebounce(func, 1); // will be discarded\ndebounce(func, 2); // will be discarded\ndebounce(func, 3); // logs `3`\n\nsetTimeout(() =\u003e {\n  debounce(func, 4); // logs `4`\n}, 2000);\n```\n\n### throttle\n\nType: `(func: ThrottledFunction, ...args: unknown[]) =\u003e void`\n\nBlocks execution of operations performed within the specified interval.\n\n#### Parameters\n\n- `func` — A function whose call will be blocked.\n- `...args` — A set of parameters for the function being performed.\n\n#### Example\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer({ throttle: { interval: 100 } });\n\nconst func = (arg: string) =\u003e {\n  console.log(arg);\n};\n\nlet time = 0;\n\n// Will be called every 10ms\nconst interval = setInterval(() =\u003e {\n  if(time \u003c 1000) {\n    performer.throttle(func, `${time}ms`); // logs `0ms`, `100ms`, `200ms`, etc.\n  } else {\n    clearInterval(interval);\n  }\n\n  time += 10;\n}, 10);\n```\n\nTo set a configuration for specific cases, pass it to the `throttle.with` function:\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer();\n\nconst throttle = performer.throttle.with({ interval: 100 });\n\nconst func = (arg: string) =\u003e {\n  console.log(arg);\n};\n\nlet time = 0;\n\n// Will be called every 10ms\nconst interval = setInterval(() =\u003e {\n  if(time \u003c 1000) {\n    throttle(func, `${time}ms`); // logs `0ms`, `100ms`, `200ms`, etc.\n  } else {\n    clearInterval(interval);\n  }\n\n  time += 10;\n}, 10);\n```\n\n### deduplicate\n\nType: `(func: DeduplicatedFunction, ...args: unknown[]) =\u003e void`\n\nDetects duplicate function calls and executes the function only once during the specified interval.\n\n#### Parameters\n\n- `func` — A function whose duplicate executions will be detected. The first parameter of the function should be the number of detected calls.\n- `...args` — A set of parameters for the function being performed.\n\n#### Example\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer({ deduplicate: { interval: 100 } });\n\nconst func1 = (count: number, arg: number) =\u003e {\n  console.log({ count, arg });\n};\n\nconst func2 = (count: number, arg: object) =\u003e {\n  console.log({ count, arg });\n};\n\nperformer.deduplicate(func1, 1); // will be blocked\nperformer.deduplicate(func1, 1); // logs `{ count: 2, arg: 1 }`\nperformer.deduplicate(func2, { foo: { bar: 'baz' } }); // will be blocked\nperformer.deduplicate(func2, { foo: { bar: 'baz' } }); // logs `{ count: 2, arg: { foo: { bar: 'baz' } } }`\nperformer.deduplicate(func2, { foo: { bar: 'qux' } }); // logs `{ count: 1, arg: { foo: { bar: 'qux' } } }`\n\nsetTimeout(() =\u003e {\n  performer.deduplicate(func2, { foo: { bar: 'baz' } }); // logs `{ count: 1, arg: { foo: { bar: 'baz' } } }`\n}, 1000);\n```\n\nTo set a configuration for specific cases, pass it to the `deduplicate.with` function:\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer();\n\nconst deduplicate = performer.deduplicate.with({ interval: 200 });\n\nconst func = (count: number, arg: number) =\u003e {\n  console.log({ count, arg });\n};\n\ndeduplicate(func, 1); // will be blocked\ndeduplicate(func, 1); // logs `{ count: 2, arg: 1 }`\n```\n\n### limit\n\nType: `(func: LimitedFunction, ...args: unknown[]) =\u003e void`\n\nLimits the maximum number of function calls.\n\n#### Parameters\n\n- `func` — A function whose number of calls will be limited.\n- `...args` — A set of parameters for the function being performed.\n\n#### Example\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer({ limit: { max: 3 } });\n\nconst func = (arg: number) =\u003e {\n  console.log(arg);\n};\n\nperformer.limit(func, 1); // logs `1`\nperformer.limit(func, 2); // logs `2`\nperformer.limit(func, 3); // logs `3`\nperformer.limit(func, 4); // will be blocked\nperformer.limit(func, 5); // will be blocked\n```\n\nTo set a configuration for specific cases, pass it to the `limit.with` function:\n\n```js\nimport { Performer } from 'function-performer';\n\nconst performer = new Performer();\n\nconst once = performer.limit.with({ max: 1 });\nconst twice = performer.limit.with({ max: 2 });\n\nconst func = (arg: number) =\u003e {\n  console.log(arg);\n};\n\nonce(func, 1); // logs `1`\nonce(func, 2); // will be blocked\nonce(func, 3); // will be blocked\n\ntwice(func, 1); // logs `1`\ntwice(func, 2); // logs `2`\ntwice(func, 3); // will be blocked\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-putseiko%2Ffunction-performer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleg-putseiko%2Ffunction-performer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-putseiko%2Ffunction-performer/lists"}