{"id":17835060,"url":"https://github.com/namesmt/kontroll","last_synced_at":"2025-10-10T08:08:48.608Z","repository":{"id":212044239,"uuid":"730581447","full_name":"NamesMT/kontroll","owner":"NamesMT","description":"Tiny, dead-simple package for function behavior controls like debounce, throttle, countdown","archived":false,"fork":false,"pushed_at":"2025-06-17T05:17:35.000Z","size":453,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T08:08:46.680Z","etag":null,"topics":["behavior","control","debounce","function","invoke","limit","throttle"],"latest_commit_sha":null,"homepage":"https://www.jsdocs.io/package/kontroll","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/NamesMT.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-12T08:34:49.000Z","updated_at":"2025-07-23T19:58:33.000Z","dependencies_parsed_at":"2024-08-24T04:32:22.112Z","dependency_job_id":"de5c78c2-e31f-41d0-bd5d-815e57a7546e","html_url":"https://github.com/NamesMT/kontroll","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":0.35,"last_synced_commit":"131e2e71d64e8f7573440585bf8c63d0f98e1de4"},"previous_names":["namesmt/kontroll"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/NamesMT/kontroll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fkontroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fkontroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fkontroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fkontroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NamesMT","download_url":"https://codeload.github.com/NamesMT/kontroll/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NamesMT%2Fkontroll/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003294,"owners_count":26083555,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["behavior","control","debounce","function","invoke","limit","throttle"],"created_at":"2024-10-27T20:16:43.608Z","updated_at":"2025-10-10T08:08:48.567Z","avatar_url":"https://github.com/NamesMT.png","language":"TypeScript","readme":"# kontroll ![TypeScript](https://img.shields.io/badge/♡-%23007ACC.svg?logo=typescript\u0026logoColor=white)\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Codecov][codecov-src]][codecov-href]\n[![License][license-src]][license-href]\n[![Bundlejs][bundlejs-src]][bundlejs-href]\n\n**kontroll** (\"control\") is a tiny, dead-simple package for function behavior controls like debounce, countdown, throttle (limit).\n\n## Features\n\n- **100% coverage!**\n- **Self-explained**: for real, every functions and options have TSDoc comments to explain their behavior plus examples at a **hover** *(based on your IDE)*, apart from the already intuitive logic path.\n  - [![jsDocs.io][jsDocs-src]][jsDocs-href]\n- **Clearable**: you can stop pending timers by calling the returned clearer function or use the `clear(key)` function.\n- **Promise aware**: avoid duplicated call if your promise haven't settled.\n\n## Usage\n\n### Install package:\n```sh\n# npm\nnpm install kontroll\n\n# yarn\nyarn add kontroll\n\n# pnpm (recommended)\npnpm install kontroll\n```\n\n### Import and use:\n\n```js\n// This package exports ESM only.\nimport {\n  clear,\n  countdown, // Can be understand as throttle no leading (execute at end of throttle instead of lead)\n  debounce,\n  getInstance,\n  throttle,\n} from 'kontroll'\n\nconst doSum = (...numbers) =\u003e console.log(numbers.reduce((acc, cur) =\u003e acc + cur, 0))\nconst createDoSum = (...numbers) =\u003e () =\u003e doSum(numbers)\n\nconst clearCountdown = countdown(1000, createDoSum(1, 2), { key: 'defined', replace: false })\nconst clearDebounce = debounce(1000, createDoSum(3, 4), { key: 34, leading: false })\nconst resetThrottle = throttle(1000, createDoSum(5, 6), { trailing: false })\n\nconst debounceInstance = getInstance(34) // { timer: Timeout, callback: \u003cfn\u003e, finishing: false }\n```\n\n## **Notice**\n\n### `key` behavior\n\nKontroll follows a key-first strategy, as long as things share the same key, they share the same timer.\n\nIf a `options.key` is not present, key are taken as `callback.toString()`.\n\n*While `kontroll` supports a key-less usage, its recommended to set your key for production code, for better performance and expected behavior.*\n\nThe following cases are debounced as their callback body is the same:\n```js\n// * Case 1, (arrow) function with unchanged/variable-only body\ndebounce(1000, () =\u003e console.log(variable))\n\n// * Case 2, callback / function returned by a function\nconst sumOneTwo = createDoSum(1, 2)\ndebounce(1000, sumOneTwo) // All this\ndebounce(1000, createDoSum(3, 4)) // 3 lines are\ndebounce(1000, createDoSum(5, 6)) // same key\n```\n\nBe notice, for something like\n```js\ndebounce(1000, () =\u003e console.log('hi'))\ndebounce(1000, () =\u003e console.log('hello'))\n```\nThe automated key are different for the two calls (because they have different callback body), so they are timed separately.\n\nIn you wish them to have the same timer, you can manually set `options.key` like: `debounce(1000, () =\u003e {}, { key: 'KEY' })`\n\nNote: the storage to check the key is set globally, if you use `kontroll` in your library, you should prefix the key with your package name.\n\n## License\n\n[MIT](./LICENSE) License © 2024 [NamesMT](https://github.com/NamesMT)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/kontroll?labelColor=18181B\u0026color=F0DB4F\n[npm-version-href]: https://npmjs.com/package/kontroll\n[npm-downloads-src]: https://img.shields.io/npm/dm/kontroll?labelColor=18181B\u0026color=F0DB4F\n[npm-downloads-href]: https://npmjs.com/package/kontroll\n[codecov-src]: https://img.shields.io/codecov/c/gh/namesmt/kontroll/main?labelColor=18181B\u0026color=F0DB4F\n[codecov-href]: https://codecov.io/gh/namesmt/kontroll\n[license-src]: https://img.shields.io/github/license/namesmt/kontroll.svg?labelColor=18181B\u0026color=F0DB4F\n[license-href]: https://github.com/namesmt/kontroll/blob/main/LICENSE\n[bundlejs-src]: https://img.shields.io/bundlejs/size/kontroll?labelColor=18181B\u0026color=F0DB4F\n[bundlejs-href]: https://bundlejs.com/?q=kontroll\n[jsDocs-src]: https://img.shields.io/badge/Check_out-jsDocs.io---?labelColor=18181B\u0026color=F0DB4F\n[jsDocs-href]: https://www.jsdocs.io/package/kontroll\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Fkontroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnamesmt%2Fkontroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnamesmt%2Fkontroll/lists"}