{"name":"perfect-debounce","version":"0.1.1","description":"[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Github Actions][github-actions-src]][github-actions-href] [![Codecov][codecov-src]][codecov-href]","repository":{"type":"git","url":"git+https://github.com/unjs/perfect-debounce.git"},"license":"MIT","sideEffects":false,"type":"module","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"build":"unbuild","dev":"vitest dev","lint":"eslint --ext .ts,.js,.mjs,.cjs .","prepack":"unbuild","release":"yarn test && standard-version && git push --follow-tags && npm publish","test":"vitest run --coverage"},"dependencies":{},"devDependencies":{"@nuxtjs/eslint-config-typescript":"latest","c8":"latest","eslint":"latest","in-range":"^3.0.0","standard-version":"latest","time-span":"^5.0.0","typescript":"latest","unbuild":"latest","vitest":"latest"},"gitHead":"a6125d86d4ee893dbfc6f89a6f421e21db584aa3","bugs":{"url":"https://github.com/unjs/perfect-debounce/issues"},"homepage":"https://github.com/unjs/perfect-debounce#readme","_id":"perfect-debounce@0.1.1","_nodeVersion":"16.14.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-ksckmiuBDEuS9PGsIoPtYTcqqAstyAMCq16PCHtblbUDTFTYTnBZy6v3cd5rYZPt0pYh3VH/+9MWbxpfriRgOg==","shasum":"920ebd3fd55ee9e38d82783fd93afe71e2693e4b","tarball":"http://registry-npm.ywwl.com/perfect-debounce/download/perfect-debounce-0.1.1.tgz","fileCount":6,"unpackedSize":9095,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiMLcTACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq4XQ//Z9E8LVPePLzye5uBTFe3uPKir6mHO3TR18eVJ5PkOgPN7O73\r\noFIgzJEo48Wn4c+jGOS11TXS2888QSj2eXhzqLdRSMEJDOLgZ32AXVgtCywl\r\nQktJtTOox2YrHQyh5HJI4LFsJZ9kr7Plt06AjRYXnlsOFl1P+w4YiY5ZZeOd\r\nL3Z3yvFXukcBo2ps7h9ZEEljBlnAva1BXFdUFmT4/DTZ6qMzoZVZIuHJuQVK\r\nuICiFxV3yoZRec/HqX3OfHlKw6qlxBS0na3joaPvAbksWmZHbUL+jc4JXk5a\r\nEb/C5+N2sBhqYsySfdTUejD4R2fbZz9WfM+yXj6bbqme0X2FYcPH2P+BAGWM\r\nfN7ED5mC4xPX2H597P5FDPDQc7HbxD26RzjgefHfHNb4QfGrIqWifrolbY31\r\n8bbc/sah/xS0X5IRFUr+7sg4eyGSrYMyhC67BFusdJxZu0wMKelrZ7EaK7Mm\r\nRjjWL/4G2dOr4P4Hs3oEUY15t5VPQ5O4Jx8+WsR3vDSfodzSnJ/75V+OdxwB\r\nWzpUKQpnijlJlI7cJDjWa6I7q/5vC9Ihs9/LAfpoyQhn1tOJqSsq6pQfJw+x\r\nj7av2wATmztbSxdFVSgyIKv7YMgZGwH3TJipoIbVHBf+DikF8i/lGpLdOhZV\r\nWMr1ylM9KjDoryRUiDTRKaiCplhl8P8vP98=\r\n=Fv5G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFcdfK3UrxGu7LPR4kVITm9BfmQoF8ABKA28bk3ec68jAiBATwTLIEBcpS11wUBbVAi2B/d6JEXG6EReMZHld5JNgg=="}],"size":3337,"noattachment":false,"key":"/perfect-debounce/-/perfect-debounce-0.1.1.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.1.1_1647359763525_0.6086065934678444"},"_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":1647359763741,"_cnpm_publish_time":1647359763741,"dist-tags":{"latest":"2.1.0"}}