{"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":{"integrity":"sha512-64byRbF0/AirwbuHqB3/ZpMG9/nckDa6ZA0yd6UnaQNwbbemCOwvz2sL5sjXLHhZHADyiwLm0M5qMhltUUx+TA==","shasum":"7633adff3bcd92cdfe13370c2f46e87bdb946a1b","tarball":"http://registry-npm.ywwl.com/debounce/download/debounce-3.0.0.tgz","fileCount":5,"unpackedSize":8589,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCzKt/qCymUJeUSORoEV8vOAjlAN+xyAMBiYEPgbQx7aAIhANNehQ9/Gt4TZNSrh5C5Cgq8X6hYrLAyRukII9RMhnz1"}],"size":3343,"noattachment":false,"key":"/debounce/-/debounce-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/debounce_3.0.0_1762108658317_0.435524262188004"},"_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","publish_time":1762108658510,"_cnpm_publish_time":1762108658510,"dist-tags":{"latest":"4.0.0"}}