{"_id":"@avatijs/debounce","_rev":"2-6621f9e745b4cd3df3af41e42d1b381a","name":"@avatijs/debounce","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.1":{"name":"@avatijs/debounce","version":"0.1.1","keywords":["avati","typescript","debounce","debouncer","throttle","throttling","delay","function control","rate limit","rate limiting","utility","helper","JavaScript","timing","event handling","event control","performance","optimization","function delay","input control","API calls"],"author":{"url":"https://khaled.ee/","name":"Khaled Sameer","email":"khaled.smq@hotmail.com"},"license":"MIT","_id":"@avatijs/debounce@0.1.1","maintainers":[{"name":"khaledsqm","email":"khaled.smq@hotmail.com"}],"homepage":"https://avati.io/","bugs":{"url":"https://github.com/KhaledSMQ/avati/issues","email":"khaled.smq@hotmail.com"},"dist":{"shasum":"8a31f6021a9caed2b1655fb44356c383a39ee66b","tarball":"https://registry.npmjs.org/@avatijs/debounce/-/debounce-0.1.1.tgz","fileCount":13,"integrity":"sha512-I+rT8oGM0U92iOpHyeK0G/d1qbVnPgLF2BNM1Tc5hiF93XTuMaplfQdnY4uYoqXl9o3zwrzzPyZaqKGYfg+vDA==","signatures":[{"sig":"MEUCIQCKNSz2iz47vQuesCAFrBGIbhEPW7WkkQeAwVPj384FVgIgTsBVpBpJW8l8cP808dDe0lmCnNB6wfsi2KCfiEBvh7M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":96744},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","unpkg":"./dist/umd/index.min.js","module":"./dist/esm/index.js","browser":"./dist/umd/index.js","engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","default":"./dist/umd/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"c75b9a02559531f2bf2673359aa0dcf919ee3471","scripts":{"size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","test":"jest","build":"npm run clean && npm run build:types && npm run build:prod","clean":"rimraf dist","watch":"webpack --mode=development --watch","analyze":"npm run analyze:size && npm run analyze:deps && npm run analyze:duplicates","build:dev":"webpack --mode development --progress","typecheck":"tsc --noEmit","build:prod":"webpack --mode production --progress","size:check":"bundlesize","size:watch":"bundlesize --watch","analyze:why":"webpack --mode production --display-reasons","build:types":"tsc --emitDeclarationOnly --outDir dist/types","analyze:deps":"madge --circular --extensions ts ./src/index.ts","analyze:full":"webpack --mode production --stats detailed","analyze:size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","analyze:tree":"webpack --mode production --display-used-exports","watch:silent":"webpack --mode=development --watch --silent","prepublishOnly":"npm run build","analyze:modules":"webpack --mode production --display-modules","analyze:detailed":"webpack --config webpack.analysis.config.js","size:compression":"bundlesize --compression","analyze:duplicates":"jscpd src"},"_npmUser":{"name":"khaledsqm","email":"khaled.smq@hotmail.com"},"jsdelivr":"./dist/umd/index.min.js","bundlesize":[{"path":"./dist/esm/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/cjs/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/umd/*.js","maxSize":"3 kB","compression":"brotli"}],"repository":{"url":"git+https://github.com/KhaledSMQ/avati.git","type":"git","directory":"packages/debounce"},"_npmVersion":"10.9.0","description":"Debounce package part of Avati project","directories":{},"sideEffects":false,"_nodeVersion":"20.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","jscpd":"^4.0.5","madge":"^8.0.0","eslint":"^8.57.1","rimraf":"^6.0.1","ts-jest":"^29.2.5","webpack":"^5.96.1","ts-loader":"^9.5.1","bundlesize":"^0.18.2","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/node":"^22.9.1","webpack-cli":"^5.1.4","dependency-cruiser":"^16.6.0","source-map-explorer":"^2.5.3","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.2","@typescript-eslint/parser":"^8.15.0","@typescript-eslint/eslint-plugin":"^8.15.0"},"_npmOperationalInternal":{"tmp":"tmp/debounce_0.1.1_1732138083208_0.9250345676247336","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"@avatijs/debounce","version":"0.1.2","keywords":["avati","scheduler","batch","task-queue","priority-queue","async","typescript","debounce","debouncer","throttle","throttling","delay","function control","rate limit","rate limiting","utility","helper","JavaScript","timing","event handling","event control","performance","optimization","function delay","input control","API calls"],"author":{"url":"https://khaled.ee/","name":"Khaled Sameer","email":"khaled.smq@hotmail.com"},"license":"MIT","_id":"@avatijs/debounce@0.1.2","maintainers":[{"name":"khaledsqm","email":"khaled.smq@hotmail.com"}],"homepage":"https://avati.io/","bugs":{"url":"https://github.com/KhaledSMQ/avati/issues","email":"khaled.smq@hotmail.com"},"dist":{"shasum":"b581f2a5256aedcb358c2cd2b594f35604e292d4","tarball":"https://registry.npmjs.org/@avatijs/debounce/-/debounce-0.1.2.tgz","fileCount":19,"integrity":"sha512-xq6qwa+rPk8Sa8NGWvKIeGew2aUzsgXBcroIPKrTtG/eFqIlXCrxKKyqj0b+VwfogsDX+lw0WLky9dGda7q04Q==","signatures":[{"sig":"MEUCIGG5otncRsmvCXDkGLhfV5VowekSOP1FlfFDNTk9AjalAiEAyCqXZyCn9EBgbWo0Gs+N2U6OMHBq8Y/Wo/IzM1w/yxY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":207574},"main":"./dist/cjs/index.js","types":"./dist/types/index.d.ts","unpkg":"./dist/umd/index.min.js","module":"./dist/esm/index.js","browser":"./dist/umd/index.js","engines":{"node":">=18.20.5"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","default":"./dist/umd/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"45902cf3fc3c657b7e7d4055600c78870d4dbabb","scripts":{"size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","test":"jest --config jest.config.js","build":"npm run clean && npm run build:types && npm run build:prod","clean":"rimraf dist","watch":"webpack --mode=development --watch","analyze":"npm run analyze:size && npm run analyze:deps && npm run analyze:duplicates","build:dev":"webpack --mode development --progress","typecheck":"tsc --noEmit","build:prod":"webpack --mode production","check-deps":"depcheck --config .depcheckrc","size:check":"bundlesize","size:watch":"bundlesize --watch","analyze:why":"webpack --mode production --display-reasons","build:types":"tsc --emitDeclarationOnly","analyze:deps":"madge --circular --extensions ts ./src/index.ts","analyze:full":"webpack --mode production --stats detailed","analyze:size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","analyze:tree":"webpack --mode production --display-used-exports","watch:silent":"webpack --mode=development --watch --silent","prepublishOnly":"npm run build","analyze:modules":"webpack --mode production --display-modules","analyze:detailed":"webpack --config webpack.analysis.config.js","size:compression":"bundlesize --compression","analyze:duplicates":"jscpd src"},"_npmUser":{"name":"khaledsqm","email":"khaled.smq@hotmail.com"},"jsdelivr":"./dist/umd/index.min.js","bundlesize":[{"path":"./dist/esm/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/cjs/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/umd/*.js","maxSize":"3 kB","compression":"brotli"}],"repository":{"url":"git+https://github.com/KhaledSMQ/avati.git","type":"git","directory":"packages/debounce"},"_npmVersion":"10.9.0","description":"Debounce package part of Avati project","directories":{},"sideEffects":false,"_nodeVersion":"20.14.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","jscpd":"^4.0.5","madge":"^8.0.0","eslint":"^8.57.1","rimraf":"^6.0.1","ts-jest":"^29.2.5","webpack":"^5.96.1","depcheck":"^1.4.7","ts-loader":"^9.5.1","bundlesize":"^0.18.2","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/node":"^22.9.1","webpack-cli":"^5.1.4","dependency-cruiser":"^16.6.0","source-map-explorer":"^2.5.3","terser-webpack-plugin":"^5.3.10","webpack-bundle-analyzer":"^4.10.2","@typescript-eslint/parser":"^8.15.0","@typescript-eslint/eslint-plugin":"^8.15.0"},"_npmOperationalInternal":{"tmp":"tmp/debounce_0.1.2_1732354254495_0.8553073762722814","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"@avatijs/debounce","version":"0.1.3","description":"Debounce package part of Avati project","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","browser":"./dist/umd/index.js","unpkg":"./dist/umd/index.min.js","jsdelivr":"./dist/umd/index.min.js","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js","default":"./dist/umd/index.js"},"./package.json":"./package.json"},"sideEffects":false,"engines":{"node":">=18.20.5"},"bundlesize":[{"path":"./dist/esm/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/cjs/index.js","maxSize":"3 kB","compression":"brotli"},{"path":"./dist/umd/*.js","maxSize":"3 kB","compression":"brotli"}],"scripts":{"build":"npm run clean && npm run build:types && npm run build:prod","build:dev":"webpack --mode development --progress","build:prod":"webpack --mode production","build:types":"tsc --emitDeclarationOnly","watch":"webpack --mode=development --watch","watch:silent":"webpack --mode=development --watch --silent","clean":"rimraf dist","prepublishOnly":"npm run build","test":"jest --config jest.config.js","typecheck":"tsc --noEmit","size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","analyze:deps":"madge --circular --extensions ts ./src/index.ts","size:check":"bundlesize","size:watch":"bundlesize --watch","size:compression":"bundlesize --compression","check-deps":"depcheck --config .depcheckrc","analyze":"npm run analyze:size && npm run analyze:deps && npm run analyze:duplicates","analyze:size":"webpack --mode production --json > stats.json && webpack-bundle-analyzer stats.json","analyze:detailed":"webpack --config webpack.analysis.config.js","analyze:duplicates":"jscpd src","analyze:why":"webpack --mode production --display-reasons","analyze:tree":"webpack --mode production --display-used-exports","analyze:modules":"webpack --mode production --display-modules","analyze:full":"webpack --mode production --stats detailed"},"author":{"name":"Khaled Sameer","email":"khaled.smq@hotmail.com","url":"https://khaled.ee/"},"homepage":"https://avati.io/","bugs":{"url":"https://github.com/KhaledSMQ/avati/issues","email":"khaled.smq@hotmail.com"},"repository":{"type":"git","url":"git+https://github.com/KhaledSMQ/avati.git","directory":"packages/debounce"},"license":"MIT","publishConfig":{"access":"public"},"keywords":["avati","scheduler","batch","task-queue","priority-queue","async","typescript","debounce","debouncer","throttle","throttling","delay","function control","rate limit","rate limiting","utility","helper","JavaScript","timing","event handling","event control","performance","optimization","function delay","input control","API calls"],"devDependencies":{"@types/jest":"^29.5.14","@types/node":"^22.9.1","@typescript-eslint/eslint-plugin":"^8.15.0","@typescript-eslint/parser":"^8.15.0","bundlesize":"^0.18.2","depcheck":"^1.4.7","dependency-cruiser":"^16.6.0","eslint":"^8.57.1","jest":"^29.7.0","jscpd":"^4.0.5","madge":"^8.0.0","rimraf":"^6.0.1","source-map-explorer":"^2.5.3","terser-webpack-plugin":"^5.3.10","ts-jest":"^29.2.5","ts-loader":"^9.5.1","typescript":"^5.6.3","webpack":"^5.96.1","webpack-bundle-analyzer":"^4.10.2","webpack-cli":"^5.1.4"},"_id":"@avatijs/debounce@0.1.3","gitHead":"e5f126bc5123d136da2b59b27cc8617b6f5a9764","_nodeVersion":"20.14.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-67cJSbwuiFMgszZJEGsZtVL1AEH9iTP5OPDT4TzA+UQ+lh+2hGMrTG0Ez0M7uVqpTGB2pfMJcXp7VwdhtjS/6Q==","shasum":"8b393384a5f1a492f3d0e4af75798a8c6b35fc54","tarball":"https://registry.npmjs.org/@avatijs/debounce/-/debounce-0.1.3.tgz","fileCount":19,"unpackedSize":207682,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEVa4ixBkV8NJxmI7cxEHTFcJCbl97PW4Ku3O0NvqxanAiApUw+xnCWjClI6QCg77g2ukWwot/g8WVvCwf+qHcdy/Q=="}]},"_npmUser":{"name":"khaledsqm","email":"khaled.smq@hotmail.com"},"directories":{},"maintainers":[{"name":"khaledsqm","email":"khaled.smq@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/debounce_0.1.3_1732382651753_0.4689870095001092"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-20T21:28:03.049Z","modified":"2024-11-23T17:24:12.144Z","0.1.1":"2024-11-20T21:28:03.421Z","0.1.2":"2024-11-23T09:30:54.674Z","0.1.3":"2024-11-23T17:24:11.956Z"},"bugs":{"url":"https://github.com/KhaledSMQ/avati/issues","email":"khaled.smq@hotmail.com"},"author":{"name":"Khaled Sameer","email":"khaled.smq@hotmail.com","url":"https://khaled.ee/"},"license":"MIT","homepage":"https://avati.io/","keywords":["avati","scheduler","batch","task-queue","priority-queue","async","typescript","debounce","debouncer","throttle","throttling","delay","function control","rate limit","rate limiting","utility","helper","JavaScript","timing","event handling","event control","performance","optimization","function delay","input control","API calls"],"repository":{"type":"git","url":"git+https://github.com/KhaledSMQ/avati.git","directory":"packages/debounce"},"description":"Debounce package part of Avati project","maintainers":[{"name":"khaledsqm","email":"khaled.smq@hotmail.com"}],"readme":"# TypeScript Debounce\n\n[![npm version](https://badge.fury.io/js/@avatijs%2Fdebounce.svg)](https://badge.fury.io/js/@avatijs%2Fdebounce)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)\n[![License](https://img.shields.io/npm/l/@avatijs%2Fdebounce.svg)](https://github.com/KhaledSMQ/avati/blob/master/LICENSE)\n\n## Introduction\n\nTypeScript Debounce is an elegant, robust debounce utility that brings the power of controlled function execution to your TypeScript applications. It provides a clean, type-safe API for managing function call rates, preventing resource overuse, and improving application performance.\n\n### 🌟 Why Another Debounce Library?\n\nWhile there are many debounce implementations available, this library stands out by offering:\n\n- **Full TypeScript Support**: Built from the ground up with TypeScript, providing complete type safety and excellent IDE integration\n- **Promise-Based API**: Modern async/await support with proper error handling\n- **Configurable Execution**: Control both leading and trailing edge execution\n- **Resource Management**: Built-in cleanup and cancellation support\n- **Debug Support**: Comprehensive logging for development troubleshooting\n- **Maximum Wait Time**: Guarantee execution for long-running debounce periods\n- **Zero Dependencies**: Lightweight and self-contained\n\n## 🎯 When You Need This\n\nDebouncing is crucial in many common development scenarios:\n\n1. **Search Input Handling**\n   ```typescript\n   // Without debounce - Makes API call on every keystroke\n   searchInput.addEventListener('input', async (e) => {\n       const results = await searchAPI(e.target.value); // 🔴 Excessive API calls\n   });\n\n   // With debounce - Waits for user to stop typing\n   const debouncedSearch = debounce(async (value: string) => {\n       const results = await searchAPI(value);\n   }, { wait: 300 }); // ✅ Single API call after typing stops\n   ```\n\n2. **Window Resize Handling**\n   ```typescript\n   // Without debounce - Recalculates layout on every resize event\n   window.addEventListener('resize', () => {\n       recalculateLayout(); // 🔴 Performance bottleneck\n   });\n\n   // With debounce - Controlled recalculation\n   const debouncedResize = debounce(() => {\n       recalculateLayout();\n   }, { wait: 150 }); // ✅ Smooth performance\n   ```\n\n3. **Form Validation**\n   ```typescript\n   // Without debounce - Validates on every change\n   input.addEventListener('input', async (e) => {\n       await validateField(e.target.value); // 🔴 Excessive validation\n   });\n\n   // With debounce - Validates after user stops typing\n   const debouncedValidate = debounce(async (value: string) => {\n       await validateField(value);\n   }, { wait: 400 }); // ✅ Efficient validation\n   ```\n\n4. **Real-time Saving**\n   ```typescript\n   // Without debounce - Saves on every change\n   editor.on('change', async (content) => {\n       await saveContent(content); // 🔴 Too many save operations\n   });\n\n   // With debounce - Intelligently batches saves\n   const debouncedSave = debounce(async (content: string) => {\n       await saveContent(content);\n   }, { wait: 1000 }); // ✅ Optimized saving\n   ```\n\n## 🚀 Installation\n\n```bash\nnpm install typescript-debounce\n# or\nyarn add typescript-debounce\n# or\npnpm add typescript-debounce\n```\n\n## 📘 Quick Start\n\n```typescript\nimport { debounce } from '@avatijs/debounce';\n\n// Create a debounced function\nconst debouncedFn = debounce(async (value: string) => {\n    const result = await api.search(value);\n    updateUI(result);\n}, {\n    wait: 300,                // Wait 300ms after last call\n    leading: false,           // Don't execute on leading edge\n    trailing: true,           // Execute on trailing edge\n    maxWait: 1000,           // Maximum time to wait\n    debug: true,             // Enable debug logging\n    onError: console.error    // Error handling\n});\n\n// Use the debounced function\ntry {\n    await debouncedFn('search term');\n} catch (error) {\n    handleError(error);\n}\n```\n\n## Features\n\n- **Type Safety**: Full TypeScript support with intelligent type inference\n- **Promise Support**: Built-in handling of async functions\n- **Cancellation**: Support for AbortController and manual cancellation\n- **Maximum Wait**: Configure maximum delay before forced execution\n- **Edge Control**: Configure execution on leading and/or trailing edge\n- **Debug Mode**: Comprehensive logging for development\n- **Error Handling**: Robust error handling with custom callbacks\n- **Resource Management**: Automatic cleanup of resources\n- **Memory Efficient**: Proper cleanup and memory management\n\n## Demo\n\nCheckout the [Demo](https://codepen.io/khaledsmq/pen/wvVVYYe) to see TypeScript Debounce in action.\n\n## Changelog\n\nPlease see [CHANGELOG](./CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nI welcome contributions from developers of all experience levels. If you have an idea, found a bug, or want to improve something, I encourage you to get involved!\n\n### How to Contribute\n1. Read [Contributing Guide](https://github.com/KhaledSMQ/avati/blob/master/Contributing.md) for details on how to get started.\n2. Fork the repository and make your changes.\n3. Submit a pull request, and we’ll review it as soon as possible.\n\n## License\n\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/KhaledSMQ/avati/blob/master/LICENSE)\n\nAvati is open-source and distributed under the [MIT License](https://github.com/KhaledSMQ/avati/blob/master/LICENSE).\n\n---\n<div align=\"center\">\n\n[![Follow on Twitter](https://img.shields.io/twitter/follow/KhaledSMQ.svg?style=social)](https://x.com/khaledsmq_)\n[![Follow on LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue.svg)](https://www.linkedin.com/in/khaledsmq/)\n[![Follow on Medium](https://img.shields.io/badge/Medium-Follow-black.svg)](https://medium.com/@khaled.smq)\n[![Made with ❤️](https://img.shields.io/badge/Made%20with-❤️-red.svg)](https://github.com/KhaledSMQ)\n[![Star on GitHub](https://img.shields.io/github/stars/KhaledSMQ/avati.svg?style=social)](https://github.com/KhaledSMQ/avati/stargazers)\n[![Follow on GitHub](https://img.shields.io/github/followers/KhaledSMQ.svg?style=social&label=Follow)](https://github.com/KhaledSMQ)\n\n</div>\n","readmeFilename":"README.md"}