{"name":"perfect-debounce","version":"0.0.0","license":"MIT","_id":"perfect-debounce@0.0.0","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-sl/CobAxFFHhkRrsFBjpDuWOK9LtYmXNhVH1zEjknBkIjdRhYDDL8ksNw7x0UtQpyPfezF6XFU1XcafBbsUAGA==","shasum":"6a272f6627cf841387e3f71632ccfda318d81b1c","tarball":"http://registry-npm.ywwl.com/perfect-debounce/download/perfect-debounce-0.0.0.tgz","fileCount":1,"unpackedSize":71,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiL5caACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpMdg/8CNY7Lbnyu/YjA57NWXzGfrvFVlgIyMx5dWL+GE5Kx779pd1y\r\n85n0GhdLqzxT5UDK52FsbwaQQI/Zs253e+pXRpSuSEqJ9XfgG5fhdBA4jBkN\r\nGgxVtQqwhOTMMNoM8/vGJFsY8bXslKGvUdeQPCRGlwrW32CIARJJ5M3Ohq5h\r\nYbO7CQ3nLp/9rYkcvnCVlsBUt9mp17TVOJId5k/TJBHReJeqqPlOle9T2rnN\r\nH9nhXw0cOX8yd45d3atB5hqE96OqDpMN+n3fioi5iPjCxn4EirrHVrJk+r6k\r\nZyP0nZuWr2xOEc+i7XbamQrk6+V//PeaLMFDh96tu+nHd0jUNrXyX6uFlpTL\r\nhcD22HHU8UkZd75yYC0C22PiQJpf8Wbl6A51n1xVLWc1v/TaGCYaYaIKvn/j\r\nliAS93GSIoi8rS6pmY3UYVSuo5/R1m3Hvrhawvc0Fg+kgae2CeapSdEy1q1D\r\nGvaTBkut8ZFuFgDlVi2RKni8wAErl40Xo9W//wZ+Os/gE1hrMqTAk3yKwkYu\r\nZLQVAIw5m3ocPejubD/hnY9VejVg/DsWISHmuPutV7ErsD17g/gdfCSS9+cw\r\nnqnAAyveYeTWmLt4p/X/9HN8OuMJs/pxNDBUicxSdxOy1tF00p/cbQ8y8pkS\r\nTwhV+AB3AGprYsBw/eY76Lp2BsVKdc4dg+Y=\r\n=5+ul\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCj69/LCHq9KlJa6gqobzCOrx3Py7cAMw+aITbhuSy4QgIhAOgFW8v+FaQ+B5CsozwxoNzwhzfotTW0crW0eARHMcDA"}],"size":162,"noattachment":false,"key":"/perfect-debounce/-/perfect-debounce-0.0.0.tgz"},"_npmUser":{"name":"pi0","email":"pyapar@gmail.com"},"directories":{},"maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/perfect-debounce_0.0.0_1647286042845_0.663483255153158"},"_hasShrinkwrap":false,"readme":"# perfect-debounce\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n[![Codecov][codecov-src]][codecov-href]\n\n> An improved debounce function with Promise support.\n\n- Well tested debounce implementation\n- Native Promise support\n- Avoid duplicate calls while promise is being resolved\n- Configurable `trailing` and `leading` behavior\n\n## Usage\n\nInstall package:\n\n```sh\n# npm\nnpm install perfect-debounce\n\n# yarn\nyarn add perfect-debounce\n\n# pnpm\npnpm add perfect-debounce\n```\n\nImport:\n\n```js\n// ESM\nimport { debounce } from 'perfect-debounce'\n\n// CommonJS\nconst { debounce } = require('perfect-debounce')\n```\n\nDebounce function:\n\n```js\nconst debounced = debounce(async () => {\n  // Some heavy stuff\n}, 25)\n```\n\nWhen calling `debounced`, it will wait at least for `25ms` as configured before actually calling our function. This helps to avoid multiple calls.\n\nTo avoid initial wait, we can set `leading: true` option. It will cause function to be immediately called if there is no other call:\n\n```js\nconst debounced = debounce(async () => {\n  // Some heavy stuff\n}, 25, { leading: true })\n```\n\nIf executing async function takes longer than debounce value, duplicate calls will be still prevented a last call will happen. To disable this behavior, we can set `trailing: false` option:\n\n```js\nconst debounced = debounce(async () => {\n  // Some heavy stuff\n}, 25, { trailing: false })\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with 💛\n\nBased on [sindresorhus/p-debounce](https://github.com/sindresorhus/p-debounce).\n\nPublished under [MIT License](./LICENSE).\n\n<!-- Badges -->\n[npm-version-src]: https://img.shields.io/npm/v/perfect-debounce?style=flat-square\n[npm-version-href]: https://npmjs.com/package/perfect-debounce\n\n[npm-downloads-src]: https://img.shields.io/npm/dm/perfect-debounce?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/perfect-debounce\n\n[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/perfect-debounce/ci/main?style=flat-square\n[github-actions-href]: https://github.com/unjs/perfect-debounce/actions?query=workflow%3Aci\n\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/perfect-debounce/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/perfect-debounce\n","publish_time":1647286042970,"_cnpm_publish_time":1647286042970,"dist-tags":{"latest":"2.1.0"}}