{"_id":"@benjaming61001/use-throttle","_rev":"7-09a1e02703450717d4f571b33068b72c","name":"@benjaming61001/use-throttle","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@benjaming61001/use-throttle","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@benjaming61001/use-throttle@1.0.0","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"de2d5c61cb6909387ad6ed6847147e39ac28aa08","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.0.0.tgz","fileCount":7,"integrity":"sha512-nLR7DKl712EDpXk1kyhWNXTA2GtckMXDGaBsWhuNwJ9i+y/ZZ9CVDGs1tdlNNGPcmhojr0tzFFE2gQGkro384A==","signatures":[{"sig":"MEQCIEXDvU+mSjgCB9sPCpmTbbXzHtWSXUceyye6XeoP/mrtAiANsiyFjROq4f43nmDaroBImKISD6gtVvuPOXFDeXxyDQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5423},"main":"index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"8c09af38e02637ab098cba421b8655493ba46387","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"benjaming61001","email":"pavin5356@gmail.com"},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"10.9.2","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.0.0_1762801709268_0.2690605782100468","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@benjaming61001/use-throttle","version":"1.0.1","keywords":[],"author":"","license":"MIT","_id":"@benjaming61001/use-throttle@1.0.1","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"7eb605fbfc56335934d81c6e82a0ca58bdf6fb92","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.0.1.tgz","fileCount":7,"integrity":"sha512-An4/worK5Scnzzx0z5HDpyhOJhJE9nVLV0yh5Ez9V4H7XnbMlIyvTcCxIqqrOypudSk9UybMXWvCDH+xmW0pzw==","signatures":[{"sig":"MEUCIQC7isvnDSw4ZPsDtjFBWFY72OHfbX1nKQVFwP+9LiJwLgIgJsCUhgzAfQvJydZYOcL0XILmnQ68V8oWKOgWP1lsbAA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5424},"main":"index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"7ef0f0ed531e2d51e1da8e787001ea96407dc7ff","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"benjaming61001","email":"pavin5356@gmail.com"},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"10.9.2","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.0.1_1762801906793_0.7682510556067654","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@benjaming61001/use-throttle","version":"1.0.2","keywords":[],"author":"","license":"MIT","_id":"@benjaming61001/use-throttle@1.0.2","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"7239008f02bda65e0af46c504e988b5fb22e22a2","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.0.2.tgz","fileCount":7,"integrity":"sha512-AD95kh+4ePmMo+zc/DAx26jSSX6M7hh0F72UNJEFXvN6XRGIv/gJVl5jStxeEwnPUCiXmbmgCrQr+ltPhrzUiw==","signatures":[{"sig":"MEUCIQCViK5VKin0krOzYYEvnRahhyoydZ9tee9gl6aUbemQGQIgPR7DxecekZA50PrnkAKP9+t3Fhl3liH54GgdOTawdiE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5414},"main":"index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"a9f65d8e331d86c30b5cac0f17a083bac5a0c5c7","scripts":{"test":"echo \"Error: no test specified\"","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"benjaming61001","email":"pavin5356@gmail.com"},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"11.6.2","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"24.11.1","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.0.2_1763563732768_0.24431339950145148","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@benjaming61001/use-throttle","version":"1.0.3","keywords":[],"author":"","license":"MIT","_id":"@benjaming61001/use-throttle@1.0.3","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"b9c277eb16350e9d1200af7cc683047a2cbf5f85","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.0.3.tgz","fileCount":7,"integrity":"sha512-s6m/klXtjrOAvNGaXPHA6FNcIEYe2eJE2rLrAJWx+XrfTtLspdY09h5Au8t3URxggYzOlTCWQ4bDp/TjTBej/A==","signatures":[{"sig":"MEYCIQDbvFcwy3cDdcfQX/pO4l0wceq48wv5lGPpenYWStTmhQIhAJZhEWL7LyThkFMXK76DQIhVkznM7vHwRdQXKxWhRPn1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@benjaming61001%2fuse-throttle@1.0.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5414},"main":"index.js","types":"dist/index.d.ts","module":"dist/index.mjs","gitHead":"5c3c6db58b552193486a997258514e2a59349277","scripts":{"test":"echo \"Error: no test specified\"","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:11111592-8640-4bce-a26a-636e098dad1c"}},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"11.9.0","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.0.3_1772998341071_0.8552045028947923","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@benjaming61001/use-throttle","version":"1.0.4","keywords":[],"author":"","license":"MIT","_id":"@benjaming61001/use-throttle@1.0.4","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"4621eb6c6817f179c0904382533981da824df546","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.0.4.tgz","fileCount":7,"integrity":"sha512-IRVg5edGBhZ6ceas7FYNyBDUcqbTDX9CqusM8wN9jZPAKrqiqkqAqOpQsqtaH5I+lWLKpYBrf56fMZeEO6e8SA==","signatures":[{"sig":"MEYCIQDjZ1gbAMcU0Yv+If2lqfAEtphCmqQRqLLRzsTO1dTN4QIhANVplB1qO2GzrWAtkEmk/+0+WPZ29TBx8rlcceNekNO2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5563},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a9f65d8e331d86c30b5cac0f17a083bac5a0c5c7","scripts":{"test":"echo \"Error: no test specified\"","build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"benjaming61001","email":"pavin5356@gmail.com"},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"11.13.0","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.0.4_1780898072775_0.9716890649344672","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@benjaming61001/use-throttle","version":"1.1.0","keywords":["throttle","typescript","javascript","util","utility","performance","optimization","event-handler","rate-limiting"],"author":"","license":"MIT","_id":"@benjaming61001/use-throttle@1.1.0","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"homepage":"https://github.com/Benjaming61001/use-throttle#readme","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"dist":{"shasum":"992db29d60334f94780349d5f15ed7f9f1548ef5","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.1.0.tgz","fileCount":7,"integrity":"sha512-48F8IKhDurV5D+UuJ5IcUVIvxp47pCt+cBBGEztTQPdmyyWG0sitFAaIcdLWb0rmkJlSgKUipqhL/qM59xdhzA==","signatures":[{"sig":"MEUCIFSvPrq+EJzlr5MRzaaWaN0PHLF2/xSg6jH97vJndMxHAiEAo+z6lVsYYSPW+kHiWIO72PM1h3LHpw77MEYtE13dFxY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@benjaming61001%2fuse-throttle@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":8208},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"beefff7750fdd093ca76e8f6e9d949425df1533b","scripts":{"lint":"oxlint src/","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts","format":"oxfmt src/","lint:fix":"oxlint src/ --fix","format:fix":"oxfmt src/ --write","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:11111592-8640-4bce-a26a-636e098dad1c"}},"repository":{"url":"git+https://github.com/Benjaming61001/use-throttle.git","type":"git"},"_npmVersion":"11.13.0","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","directories":{},"_nodeVersion":"24.16.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","oxfmt":"^0.54.0","oxlint":"^1.69.0","vitest":"^4.1.8","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/use-throttle_1.1.0_1780997537989_0.40056159985808426","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@benjaming61001/use-throttle","version":"1.1.1","description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup src/index.ts --format cjs,esm --dts","prepublishOnly":"npm run build","test":"vitest run","test:watch":"vitest","lint":"oxlint src/","lint:fix":"oxlint src/ --fix","format":"oxfmt src/","format:fix":"oxfmt src/ --write"},"repository":{"type":"git","url":"git+https://github.com/Benjaming61001/use-throttle.git"},"keywords":["throttle","typescript","javascript","util","utility","performance","optimization","event-handler","rate-limiting"],"author":"","license":"MIT","bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"homepage":"https://github.com/Benjaming61001/use-throttle#readme","devDependencies":{"oxfmt":"^0.54.0","oxlint":"^1.69.0","tsup":"^8.5.0","typescript":"^5.9.3","vitest":"^4.1.8"},"gitHead":"4ee5aa43dc44c7646fe157e75834996ff7cd3cdf","_id":"@benjaming61001/use-throttle@1.1.1","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-tzB4wMyUjwHEidvO2o/wOsKY/zkuIO+eCuV3Lm8vvrnQ6FmnYpeMBtuEoe3R6eSbjuYKYf3Q4T5ADVDgd9n+IQ==","shasum":"93330ee390f90bc29d9d787afadc881a39a0901e","tarball":"https://registry.npmjs.org/@benjaming61001/use-throttle/-/use-throttle-1.1.1.tgz","fileCount":7,"unpackedSize":8300,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@benjaming61001%2fuse-throttle@1.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCVGKXN8strbPQ+jw2oYCu/pXW4arQkFTRAgAXyab8JXwIgYFTv5X7N4WrmkQg1d5GG9H9z7OtXga4jnNC5eAQ7Ovs="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:11111592-8640-4bce-a26a-636e098dad1c"}},"directories":{},"maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/use-throttle_1.1.1_1780999609917_0.6710317132752548"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-10T19:08:29.186Z","modified":"2026-06-09T10:06:50.357Z","1.0.0":"2025-11-10T19:08:29.462Z","1.0.1":"2025-11-10T19:11:46.970Z","1.0.2":"2025-11-19T14:48:52.978Z","1.0.3":"2026-03-08T19:32:21.240Z","1.0.4":"2026-06-08T05:54:32.934Z","1.1.0":"2026-06-09T09:32:18.114Z","1.1.1":"2026-06-09T10:06:50.079Z"},"bugs":{"url":"https://github.com/Benjaming61001/use-throttle/issues"},"license":"MIT","homepage":"https://github.com/Benjaming61001/use-throttle#readme","keywords":["throttle","typescript","javascript","util","utility","performance","optimization","event-handler","rate-limiting"],"repository":{"type":"git","url":"git+https://github.com/Benjaming61001/use-throttle.git"},"description":"A lightweight TypeScript throttle function implementation that fires on the leading edge, preserving this context and parameters.","maintainers":[{"name":"benjaming61001","email":"pavin5356@gmail.com"}],"readme":"# use-throttle\n\nA lightweight TypeScript throttle function implementation that fires on the leading edge, preserving `this` context and parameters.\n\n## Installation\n\n```bash\nnpm install @benjaming61001/use-throttle\n```\n\n```bash\nbun add @benjaming61001/use-throttle\n```\n\n```bash\nyarn add @benjaming61001/use-throttle\n```\n\n```bash\npnpm add @benjaming61001/use-throttle\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { throttle } from '@benjaming61001/use-throttle'\n\nconst throttledScroll = throttle((event: Event) => {\n  console.log('Scroll event:', event.target)\n}, 200)\n\nwindow.addEventListener('scroll', throttledScroll)\n```\n\n### Cancel & Flush\n\n```typescript\nconst throttledSave = throttle((data: FormData) => {\n  api.save(data)\n}, 1000)\n\n// Cancel pending execution\nthrottledSave.cancel()\n\n// Flush pending execution immediately\nthrottledSave.flush()\n```\n\n### Preserving Context\n\n```typescript\nclass ScrollController {\n  position = 0\n\n  handleScroll = throttle((event: Event) => {\n    console.log(this.position) // `this` is preserved\n    this.position = window.scrollY\n  }, 100)\n}\n```\n\n## API\n\n### `throttle(func, limit)`\n\nCreates a throttled version of a function that only invokes `func` at most once per every `limit` milliseconds. The function fires on the leading edge of the timeout.\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `func` | `(...args: TArgs) => void` | The function to throttle |\n| `limit` | `number` | The number of milliseconds to throttle invocations to |\n\n**Returns:** A throttled function with `cancel()` and `flush()` methods.\n\n### `cancel()`\n\nCancels any pending throttled function execution.\n\n### `flush()`\n\nImmediately executes the throttled function if there's a pending call, then cancels any further pending execution.\n\n## Development\n\n```bash\nbun install\nbun run test        # run tests\nbun run test:watch  # watch mode\nbun run build       # build package\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}