{"name":"perfect-debounce","version":"1.0.0","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":{".":{"types":"./dist/index.d.ts","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 . && prettier --check src test","lint:fix":"eslint --ext .ts,.js,.mjs,.cjs . --fix && prettier -w src test","release":"pnpm test && pnpm build && changelogen --release --push && npm publish","test":"vitest run --coverage"},"devDependencies":{"@types/node":"^18.16.3","@vitest/coverage-c8":"^0.31.0","changelogen":"^0.5.3","eslint":"^8.39.0","eslint-config-unjs":"^0.1.0","in-range":"^3.0.0","prettier":"^2.8.8","time-span":"^5.1.0","typescript":"^5.0.4","unbuild":"^1.2.1","vitest":"^0.31.0"},"packageManager":"pnpm@8.4.0","gitHead":"984406de0d31a49a35b8929197162a49ba26ec0f","bugs":{"url":"https://github.com/unjs/perfect-debounce/issues"},"homepage":"https://github.com/unjs/perfect-debounce#readme","_id":"perfect-debounce@1.0.0","_nodeVersion":"16.19.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==","shasum":"9c2e8bc30b169cc984a58b7d5b28049839591d2a","tarball":"http://registry-npm.ywwl.com/perfect-debounce/download/perfect-debounce-1.0.0.tgz","fileCount":6,"unpackedSize":9239,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHEwdoeYAzVkahbR4TrBg6nLpS2LaqEpU4Kq5xuFCHH+AiEAhtOU+lMgZxSEGjjIWEj8fjuRYYJguBDTlmc7dsAkAok="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkUut4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq36g/+OyTTjU8xbBx21YdNym1EnVl0zyKDhefmtXbIJhku9feR+JJ9\r\nW9FpWWiyh4/oFHg5xo0avdmtAxM6rlnU9KWvRckCLOazOQILrK4Wa6TL1ElH\r\nCjouXEvOiwCFcGru7QQTKRa7AOEQqVRzT3TKrLEjg4UzhU2mb6yFLQ/NnLH0\r\nIujDgWlOefL0+a20FrBT4+5c8HR04qHajNyD8hiNjth9OEK8GisGknpUzl1l\r\nVhmGV9KmSOl+jejREIi1LxEzmer0ez34LZzD/jiP2VNE9AhAkuHhj32bocIw\r\nIWTasE3/ht0KmYd3K82+PQ8IEFvm4BNP0IL9g+AsM+oHhzYpf6/aNFDnTi/k\r\nmCVuRNiPbhEyixx9garKM0jfq/QXZ167usYmsloOsOzW9a+ocJMK7z8xhyXZ\r\nMGICIeODNciZEL1HMZGqrmdXSNJcx0xyqOM9Ihh4BY5EHWh2h5+Vf2RIZdsA\r\nEtQ9K30odHoPsO7K19h2IYpug0kAcv3YadTBNdByQ6SKoleHj4MTq9sd5RP4\r\nBQ3YbB8jjcV1e8wnvjtrolAhUTNXy0zY8/Wzjx/xRbzsOX0ZKU1Wu9M+t/CE\r\nLPpHghRP5h09G6bIaMiz+dMnkkr82xzjp76TUX+TlaHQaBzRXWcN42NgAJ8Z\r\ntQlVCN1sRLPwroN9g6jFuaxnrXTYOxzZycA=\r\n=OClE\r\n-----END PGP SIGNATURE-----\r\n","size":3406,"noattachment":false,"key":"/perfect-debounce/-/perfect-debounce-1.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_1.0.0_1683155832605_0.050683142885539434"},"_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":1683155832783,"_cnpm_publish_time":1683155832783,"dist-tags":{"latest":"2.1.0"}}