{"_id":"debounce","_rev":"4132968","name":"debounce","description":"Delay function calls until a set time elapses after the last invocation","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-03-01T18:41:06.000Z","created":"2013-08-21T18:08:51.880Z","3.0.0":"2025-11-02T18:37:38.510Z","2.2.0":"2024-10-14T16:38:31.183Z","2.1.1":"2024-09-09T16:01:14.394Z","2.1.0":"2024-05-25T10:42:51.554Z","2.0.0":"2023-11-15T18:55:03.719Z","1.2.1":"2021-03-09T18:32:25.739Z","1.2.0":"2018-08-14T14:00:34.193Z","1.1.0":"2017-10-30T15:30:34.054Z","1.0.2":"2017-04-21T16:54:56.614Z","1.0.0":"2014-06-21T18:38:11.876Z","0.0.3":"2013-08-21T18:30:31.260Z","0.0.2":"2013-08-21T18:08:51.880Z"},"users":{"lmartins":true,"sahilsk":true,"bartmichu":true,"ash":true,"arkanciscan":true,"wenbing":true,"r3nya":true,"davidbraun":true,"vutran":true,"quocnguyen":true,"scottfreecode":true,"mysticatea":true,"travis346":true,"troyblank":true,"spkjess":true,"gamersdelight":true},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"versions":{"3.0.0":{"name":"debounce","version":"3.0.0","description":"Delay function calls until a set time elapses after the last invocation","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && node --test"},"keywords":["debounce","debouncing","function","throttle","invoke","limit","limited","interval","rate","batch","rate-limit"],"devDependencies":{"xo":"^0.56.0"},"gitHead":"cc34d9071e15cc548c23b9bc9441bebb5c81024d","types":"./index.d.ts","_id":"debounce@3.0.0","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"homepage":"https://github.com/sindresorhus/debounce#readme","_nodeVersion":"20.19.5","_npmVersion":"11.6.1","dist":{"shasum":"7633adff3bcd92cdfe13370c2f46e87bdb946a1b","size":3343,"noattachment":false,"key":"/debounce/-/debounce-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/debounce_3.0.0_1762108658317_0.435524262188004"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-11-02T18:37:38.510Z","publish_time":1762108658510,"_source_registry_name":"default","_cnpm_publish_time":1762108658510},"2.2.0":{"name":"debounce","version":"2.2.0","description":"Delay function calls until a set time elapses after the last invocation","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"funding":"https://github.com/sponsors/sindresorhus","exports":{"types":"./index.d.ts","default":"./index.js"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && node --test"},"keywords":["debounce","debouncing","function","throttle","invoke","limit","limited","interval","rate","batch","ratelimit"],"devDependencies":{"sinon":"^17.0.1","xo":"^0.56.0"},"xo":{"rules":{"unicorn/prefer-module":"off"}},"_id":"debounce@2.2.0","gitHead":"12050fccb40bc34c7b8d03067a12a7e9fb2266df","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"homepage":"https://github.com/sindresorhus/debounce#readme","_nodeVersion":"22.6.0","_npmVersion":"10.6.0","dist":{"shasum":"f895fa2fbdb579a0f0d3dcf5dde19657e50eaad5","size":3035,"noattachment":false,"key":"/debounce/-/debounce-2.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-2.2.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_2.2.0_1728923910988_0.7269666090014484"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-14T16:38:31.183Z","publish_time":1728923911183,"_source_registry_name":"default","_cnpm_publish_time":1728923911183},"2.1.1":{"name":"debounce","version":"2.1.1","description":"Delay function calls until a set time elapses after the last invocation","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"funding":"https://github.com/sponsors/sindresorhus","exports":{"types":"./index.d.ts","default":"./index.js"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && node --test"},"keywords":["debounce","debouncing","function","throttle","invoke","limit","limited","interval","rate","batch","ratelimit"],"devDependencies":{"sinon":"^17.0.1","xo":"^0.56.0"},"xo":{"rules":{"unicorn/prefer-module":"off"}},"_id":"debounce@2.1.1","gitHead":"dc9d9ecc3e00bfa9ad56edd1144c539ec8c09ec8","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"homepage":"https://github.com/sindresorhus/debounce#readme","_nodeVersion":"18.20.4","_npmVersion":"10.6.0","dist":{"shasum":"8ae1d5233ec5abd1c8edf3e994a9286a73d0f4ff","size":2932,"noattachment":false,"key":"/debounce/-/debounce-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-2.1.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_2.1.1_1725897674192_0.7640689216993264"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-09-09T16:01:14.394Z","publish_time":1725897674394,"_source_registry_name":"default","_cnpm_publish_time":1725897674394},"2.1.0":{"name":"debounce","version":"2.1.0","description":"Delay function calls until a set time elapses after the last invocation","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"funding":"https://github.com/sponsors/sindresorhus","exports":{"types":"./index.d.ts","default":"./index.js"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && node --test"},"keywords":["debounce","debouncing","function","throttle","invoke","limit","limited","interval","rate","batch","ratelimit"],"devDependencies":{"sinon":"^17.0.1","xo":"^0.56.0"},"xo":{"rules":{"unicorn/prefer-module":"off"}},"_id":"debounce@2.1.0","gitHead":"312a06ebd5aa5134d007ce7964cde04ce98e32bd","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"homepage":"https://github.com/sindresorhus/debounce#readme","_nodeVersion":"18.20.2","_npmVersion":"10.6.0","dist":{"shasum":"eab25eaf254b848fcfccffbde75bdaa44842caa3","size":2895,"noattachment":false,"key":"/debounce/-/debounce-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-2.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_2.1.0_1716633771389_0.8632625473268731"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-05-25T10:42:51.554Z","publish_time":1716633771554,"_source_registry_name":"default","_cnpm_publish_time":1716633771554},"2.0.0":{"name":"debounce","version":"2.0.0","description":"Delay function calls until a set time elapses after the last invocation","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/debounce.git"},"funding":"https://github.com/sponsors/sindresorhus","exports":{"types":"./index.d.ts","default":"./index.js"},"main":"./index.js","types":"./index.d.ts","sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && node --test"},"keywords":["debounce","debouncing","function","throttle","invoke","limit","limited","interval","rate","batch","ratelimit"],"devDependencies":{"sinon":"^17.0.1","xo":"^0.56.0"},"xo":{"rules":{"unicorn/prefer-module":"off"}},"gitHead":"1b1d4d8de8bee33578c8b855407cdd31454422b0","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"homepage":"https://github.com/sindresorhus/debounce#readme","_id":"debounce@2.0.0","_nodeVersion":"21.1.0","_npmVersion":"9.2.0","dist":{"shasum":"b2f914518a1481466f4edaee0b063e4d473ad549","size":2798,"noattachment":false,"key":"/debounce/-/debounce-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-2.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_2.0.0_1700074503532_0.7553481672169307"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-15T18:55:03.719Z","publish_time":1700074503719,"_source_registry_name":"default","_cnpm_publish_time":1700074503719},"1.2.1":{"name":"debounce","description":"Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked","version":"1.2.1","repository":{"type":"git","url":"git://github.com/component/debounce.git"},"main":"index.js","scripts":{"test":"minijasminenode test.js"},"license":"MIT","keywords":["function","throttle","invoke"],"devDependencies":{"minijasminenode":"^1.1.1","sinon":"^1.17.7","mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"gitHead":"8be734c4b5b5a58a517f2441e0d90242a4a564cd","bugs":{"url":"https://github.com/component/debounce/issues"},"homepage":"https://github.com/component/debounce#readme","_id":"debounce@1.2.1","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"shasum":"38881d8f4166a5c5848020c11827b834bcb3e0a5","size":4207,"noattachment":false,"key":"/debounce/-/debounce-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-1.2.1.tgz"},"_npmUser":{"name":"stephenmathieson","email":"me@stephenmathieson.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_1.2.1_1615314745500_0.8416718637080391"},"_hasShrinkwrap":false,"publish_time":1615314745739,"_cnpm_publish_time":1615314745739},"1.2.0":{"name":"debounce","description":"Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked","version":"1.2.0","repository":{"type":"git","url":"git://github.com/component/debounce.git"},"main":"index.js","scripts":{"test":"minijasminenode test.js"},"license":"MIT","keywords":["function","throttle","invoke"],"devDependencies":{"minijasminenode":"^1.1.1","sinon":"^1.17.7","mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"gitHead":"f4afbd34e3e15be33d2f261b3ec67ecddaf4a4f6","bugs":{"url":"https://github.com/component/debounce/issues"},"homepage":"https://github.com/component/debounce#readme","_id":"debounce@1.2.0","_npmVersion":"6.1.0","_nodeVersion":"10.4.0","_npmUser":{"name":"stephenmathieson","email":"me@stephenmathieson.com"},"dist":{"shasum":"44a540abc0ea9943018dc0eaa95cce87f65cd131","size":3337,"noattachment":false,"key":"/debounce/-/debounce-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-1.2.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_1.2.0_1534255234037_0.9098299467781039"},"_hasShrinkwrap":false,"publish_time":1534255234193,"_cnpm_publish_time":1534255234193},"1.1.0":{"name":"debounce","description":"Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked","version":"1.1.0","repository":{"type":"git","url":"git://github.com/component/debounce.git"},"main":"index.js","scripts":{"test":"minijasminenode test.js"},"license":"MIT","keywords":["function","throttle","invoke"],"devDependencies":{"minijasminenode":"^1.1.1","sinon":"^1.17.7","mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"gitHead":"e2ce8d2b92e6666a7444b4c9ca40eda57c3404a1","bugs":{"url":"https://github.com/component/debounce/issues"},"homepage":"https://github.com/component/debounce#readme","_id":"debounce@1.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"stephenmathieson","email":"me@stephenmathieson.com"},"dist":{"shasum":"6a1a4ee2a9dc4b7c24bb012558dbcdb05b37f408","size":3299,"noattachment":false,"key":"/debounce/-/debounce-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce-1.1.0.tgz_1509377433149_0.48635850357823074"},"directories":{},"publish_time":1509377434054,"_cnpm_publish_time":1509377434054,"_hasShrinkwrap":false},"1.0.2":{"name":"debounce","description":"Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked","version":"1.0.2","repository":{"type":"git","url":"git://github.com/component/debounce.git"},"main":"index.js","scripts":{"test":"minijasminenode test.js"},"license":"MIT","keywords":["function","throttle","invoke"],"devDependencies":{"minijasminenode":"^1.1.1","sinon":"^1.17.7","mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"gitHead":"359b502dad1e4f56c50086371d3b8faa0d5862b2","bugs":{"url":"https://github.com/component/debounce/issues"},"homepage":"https://github.com/component/debounce#readme","_id":"debounce@1.0.2","_shasum":"503cc674d8d7f737099664fb75ddbd36b9626dc6","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"dist":{"shasum":"503cc674d8d7f737099664fb75ddbd36b9626dc6","size":2893,"noattachment":false,"key":"/debounce/-/debounce-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-1.0.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/debounce-1.0.2.tgz_1492793694896_0.8119447159115225"},"directories":{},"publish_time":1492793696614,"_cnpm_publish_time":1492793696614,"_hasShrinkwrap":false},"1.0.0":{"name":"debounce","description":"Creates and returns a new debounced version of the passed function that will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked","version":"1.0.0","repository":{"type":"git","url":"git://github.com/component/debounce"},"main":"index.js","license":"MIT","keywords":["function","throttle","invoke"],"dependencies":{"date-now":"1.0.1"},"devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"gitHead":"0b58e834ede3bead70c09af22375e1d62671d7b9","bugs":{"url":"https://github.com/component/debounce/issues"},"homepage":"https://github.com/component/debounce","_id":"debounce@1.0.0","scripts":{},"_shasum":"0948af513d2e4ce407916f8506a423d3f9cf72d8","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"0948af513d2e4ce407916f8506a423d3f9cf72d8","size":2157,"noattachment":false,"key":"/debounce/-/debounce-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-1.0.0.tgz"},"directories":{},"publish_time":1403375891876,"_cnpm_publish_time":1403375891876,"_hasShrinkwrap":false},"0.0.3":{"name":"debounce","description":"fn debounce","version":"0.0.3","main":"index.js","dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"readmeFilename":"Readme.md","_id":"debounce@0.0.3","dist":{"shasum":"4241a7fbfce811a94a178069e5e250bf8b75c886","size":1672,"noattachment":false,"key":"/debounce/-/debounce-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-0.0.3.tgz"},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1377109831260,"_cnpm_publish_time":1377109831260,"_hasShrinkwrap":false},"0.0.2":{"name":"debounce","description":"fn debounce","version":"0.0.2","main":"index.js","dependencies":{},"devDependencies":{"mocha":"*","should":"*"},"component":{"scripts":{"debounce/index.js":"index.js"}},"readmeFilename":"Readme.md","_id":"debounce@0.0.2","dist":{"shasum":"701aea92febb6696511faaef79f740ed8ba6260b","size":1651,"noattachment":false,"key":"/debounce/-/debounce-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/debounce/download/debounce-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.2","_npmUser":{"name":"mattmueller","email":"mattmuelle@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1377108531880,"_cnpm_publish_time":1377108531880,"_hasShrinkwrap":false}},"readme":"# debounce\n\n> Delay function calls until a set time elapses after the last invocation\n\n## Install\n\n```sh\nnpm install debounce\n```\n\n## Usage\n\n```js\nimport debounce from 'debounce';\n\nfunction resize() {\n\tconsole.log('height', window.innerHeight);\n\tconsole.log('width', window.innerWidth);\n}\n\nwindow.onresize = debounce(resize, 200);\n```\n\nTo check if the debounce delay is currently active:\n\n```js\nwindow.onresize.isPending;\n```\n\nTo later clear the timer and cancel currently scheduled executions:\n\n```js\nwindow.onresize.clear();\n```\n\nExecute immediately only if a call is pending (and reset the timer):\n\n```js\nwindow.onresize.flush();\n```\n\nTo execute immediately and reset the timer if it was previously set:\n\n```js\nwindow.onresize.trigger();\n```\n\n## API\n\n### debounce(fn, wait, options?)\n\nCreates a debounced function that delays execution until `wait` milliseconds have passed since its last invocation.\n\nSet the `immediate` option to `true` to execute the function immediately at the start of the `wait` interval, preventing issues such as double-clicks on a button.\n\nThe returned function has the following methods:\n\n- `.isPending` indicates whether the debounce delay is currently active.\n- `.clear()` cancels any scheduled executions.\n- `.flush()` if an execution is scheduled then it will be immediately executed and the timer will be cleared.\n- `.trigger()` executes the function immediately and clears the timer if it was previously set.\n\n## Related\n\n- [p-debounce](https://github.com/sindresorhus/p-debounce) - Similar but handles promises\n- [throttleit](https://github.com/sindresorhus/throttleit) - Throttle a function to limit its execution rate\n","_attachments":{},"homepage":"https://github.com/sindresorhus/debounce#readme","bugs":{"url":"https://github.com/sindresorhus/debounce/issues"},"license":"MIT"}