{"id":22903964,"url":"https://github.com/json2d/debounce-by-key","last_synced_at":"2025-09-07T02:33:17.106Z","repository":{"id":57158901,"uuid":"102169943","full_name":"json2d/debounce-by-key","owner":"json2d","description":"useful for employing a group of functions within a single debounce scope and/or employing a single function across a group of debounce scopes","archived":false,"fork":false,"pushed_at":"2017-09-02T03:25:48.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-04T05:18:14.269Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/json2d.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}},"created_at":"2017-09-02T03:25:41.000Z","updated_at":"2022-10-28T21:02:45.000Z","dependencies_parsed_at":"2022-09-07T12:10:28.263Z","dependency_job_id":null,"html_url":"https://github.com/json2d/debounce-by-key","commit_stats":null,"previous_names":["bitstrider/debounce-by-key"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Fdebounce-by-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Fdebounce-by-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Fdebounce-by-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json2d%2Fdebounce-by-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/json2d","download_url":"https://codeload.github.com/json2d/debounce-by-key/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246604619,"owners_count":20804100,"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":[],"created_at":"2024-12-14T02:39:34.885Z","updated_at":"2025-04-01T07:56:50.276Z","avatar_url":"https://github.com/json2d.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# debounce-by-key\n[![debounce-by-key](https://img.shields.io/npm/v/debounce-by-key.svg)]()\n[![debounce-by-key](https://img.shields.io/npm/l/debounce-by-key.svg)]()\n\nuseful for employing a group of functions within a single debounce scope and/or employing a single function across a group of debounce scopes\n\n## Installation\n\n```sh\nnpm install debounce-by-key --save\n```\n\n## Usage\n\nThis module provides a single function that takes a single options arg (*optional*) and returns a `Promise` that *resolves* if the debounce state is **non-blocking**, and *rejects* if its **blocking**.\n\n### debounce([options])\n- options `{Object}`\n- return: `Promise`\n\n#### [options]\n- `key` the string identifier of the debounce scope. Defaults to `''`\n- `duration` the time in milliseconds of the **blocking** state. Defaults to `1000`\n\n## Example\n\n```javascript\nconst debounce = require('debounce-by-key')\n\nconst sayHi = ()=\u003e{console.log('hello world')}\n\n\n/* no-args */\ndebounce().then(sayHi)\ndebounce().then(sayHi) //⛔ will not run\n\n\n/* multiple functions, single scope */\ndebounce({key:'say hi'}).then(() =\u003e console.log('hola mundo') )\ndebounce({key:'say hi'}).then(() =\u003e console.log('hello world') ) //⛔ will not run\ndebounce({key:'say hi'}).then(() =\u003e console.log('bonjour monde') ) //⛔ will not run\n\n\n/* single function, mutliple scopes */\ndebounce({key:'say hi 1'}).then(sayHi)\ndebounce({key:'say hi 2'}).then(sayHi) //✅ will run\n\n\n/* duration arg */\nconst d = () =\u003e debounce({key:'say hi 3', duration:1000}).then(sayHi)\n\nd()\nsetTimeout(d,500) //⛔ will not run\nsetTimeout(d,1500) //✅ will run\n\n\n\n```\n\n## Tests\n\n```sh\nnpm install\nnpm test\n```\n\n## Dependencies\n\nNone\n\n## Dev Dependencies\n\n- [tap](https://github.com/tapjs/node-tap): A Test-Anything-Protocol library\n\n\n## License\n\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Fdebounce-by-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjson2d%2Fdebounce-by-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson2d%2Fdebounce-by-key/lists"}