{"name":"dettle","version":"1.0.3","keywords":["tiny","debounce","throttle"],"_id":"dettle@1.0.3","homepage":"https://github.com/fabiospampinato/dettle#readme","bugs":{"url":"https://github.com/fabiospampinato/dettle/issues"},"dist":{"shasum":"0276262eaa8bc06a6d6ce98dc209d344ba708029","tarball":"http://registry-npm.ywwl.com/dettle/download/dettle-1.0.3.tgz","fileCount":18,"integrity":"sha512-uWHJmmxWyQweX4ZyHyaQpTsU3m+7NTnMnA2O2upPGEywRCtomy2iAVFQJa0WZZkWI+bjTuOzR/IZCQZFC2QlwQ==","signatures":[{"sig":"MEQCIAIC1uGNrYY7R4sf21Q72IGbC4DdPHKvF62ZkHzqyw0lAiARuP8Nk9wRp6mxIG4XYdijpIH1Pu7eVH5aRzY9MrpY1g==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":13532,"size":4072,"noattachment":false,"key":"/dettle/-/dettle-1.0.3.tgz"},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","exports":"./dist/index.js","gitHead":"740fa485b7ca6059f2ab0f11712f40dbcd68645f","scripts":{"test":"tsex test","clean":"tsex clean","compile":"tsex compile","test:watch":"tsex test --watch","compile:watch":"tsex compile --watch","prepublishOnly":"tsex prepare"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"repository":{"url":"git+https://github.com/fabiospampinato/dettle.git","type":"git"},"_npmVersion":"10.2.3","description":"A tiny fully-featured debounce and throttle implementation.","directories":{},"_nodeVersion":"18.19.0","_hasShrinkwrap":false,"devDependencies":{"fava":"^0.3.2","tsex":"^4.0.2","typescript":"^5.5.2"},"_npmOperationalInternal":{"tmp":"tmp/dettle_1.0.3_1719762425915_0.42727674475084076","host":"s3://npm-registry-packages"},"readme":"# Dettle\n\nA tiny fully-featured debounce and throttle implementation.\n\n## Install\n\n```sh\nnpm install --save dettle\n```\n\n## Usage\n\n```ts\nimport {debounce, throttle} from 'dettle';\n\nconst fn = () => console.log ( 'Fired!' );\n\n// Debouncing\n// The following options are supported:\n// `leading`: whether the function should be called when the timeout is created, defaults to `false`\n// `trailing`: whether the function should be called when the timeout expires, defaults to `true`\n// `maxWait`: the maximum amount of time that can pass before the function is called, defaults to `Infinity`\n\nconst debounced = debounce ( fn, 1000, {\n  leading: false,\n  trailing: true,\n  maxWait: Infinity\n});\n\ndebounced (); // Schedule function for execution\ndebounced (); // Re-schedule function for execution\n\ndebounced.flush (); // Execute the function immediately, if there's a scheduled execution\ndebounced.cancel (); // Cancel the scheduled execution\n\n// Throttling\n// The API for throttling is basically the same, except that:\n// - `leading`: is `true` by default rather than `false`\n// - `maxWait`: is set implicitly for you to be equal to the wait time\n\nconst throttled = throttle ( fn, 1000, {\n  leading: true,\n  trailing: true\n});\n\nthrottled (); // Call the function immediately\nthrottled (); // Schedule function for execution\n\nthrottled.flush (); // Execute the function immediately, if there's a scheduled execution\nthrottled.cancel (); // Cancel the scheduled execution\n```\n\n## License\n\nMIT © Fabio Spampinato\n","publish_time":1719762426072,"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_cnpm_publish_time":1719762426072,"dist-tags":{"latest":"1.0.5"}}