{"name":"p-debounce","version":"3.0.2","description":"Debounce promise-returning & async functions","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-debounce.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","debounce","debounced","limit","limited","concurrency","throttle","throat","limited","interval","rate","batch","ratelimit","task","queue","async","await","promises","bluebird"],"devDependencies":{"ava":"^3.15.0","in-range":"^2.0.0","time-span":"^4.0.0","tsd":"^0.14.0","xo":"^0.37.1","yoctodelay":"^1.1.0"},"gitHead":"2eee95247f1dadb26a02ca328a2b44055fdc0caa","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@3.0.2","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-I5Tswd6ow31zGbudKRtKBlgI85n6BQrXdsuv1cN7MjNP3xCRSVsX8L57SzIegEx+b77LXzvGt5GJcXr7gBsiXA==","shasum":"8bc7aa524e512b8572f75c6a41858b7a2222a1ee","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-3.0.2.tgz","fileCount":5,"unpackedSize":7298,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYXzzCRA9TVsSAnZWagAAnUcP/3uHHN5u1fQEXGZI0xuP\nwdpfqhHSikiH7Wsco7Mh2TYvZSX3jNBi6a++SiD9jJerJJuvADkTDMbkzYKt\nEbeq04+3YyjyDF8H0Mu7y1FH0jMwxsbnoJO4rB/IEmA7Smmto6Ex2EaBwgWo\neS2GGM7wNiBqJleScLaLiyZoAJOeOcmB3kD9tmh4o+579QCC8FJF12xtywGa\nfywPumZ/GQXIRBfBI/kWDJXNROyTmXGygjIbHRt47APFr1toGdxUSZ9++FAo\nf2sqjcSVQPn21zaKKJXFP+jFUISPrXRrUHrCg4ZN43WC+p3ha/U6/59sseDv\n2+sFL9VOXiTdz+0hETGy/e4PrKMkC6JG38G7NTymLYMkZ0819N7b6SJZ71lY\nsk7cZ/SHKR2NGJR/oe1QdK5Ijq18eZ5ZR9qYEknuHWzR8YHG5X84D212OsVW\nRMrmRgMf2ZC3YJFfBJJnHSusdNpaN5cA+i77VmUY3sy2ibV4f6JZ70fE05HO\na2TpU/m+3yr2mx4xUbX5IH+x1rxqFdfw64fedSJuowZpMAHgbjPcUigkNNCj\ntwPlDAjTFZi/Q0/4ekEY7iu/uMyinEDhIBT3zFSBnLjLmqJ9WwIwOQgGBYR9\nJ0C04QjybPLRyOSrkIz9HAuLJn42LmBzaAHKDej0ElMEPJhdtvLSvz+s3npa\n3VfT\r\n=pKEP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0IwpZA1GCffXiVD/RKl58mxEIyeeAjxHCukP7/CSBlQIhAMR+PcKCEfP3KbEjmnlc2chTcuuIXz4f71yZOPssBum0"}],"size":2731,"noattachment":false,"key":"/p-debounce/-/p-debounce-3.0.2.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_3.0.2_1617001714866_0.7834370578263965"},"_hasShrinkwrap":false,"readme":"# p-debounce\n\n> [Debounce](https://css-tricks.com/debouncing-throttling-explained-examples/) promise-returning & async functions\n\n## Install\n\n```\n$ npm install p-debounce\n```\n\n## Usage\n\n```js\nimport pDebounce from 'p-debounce';\n\nconst expensiveCall = async input => input;\n\nconst debouncedFn = pDebounce(expensiveCall, 200);\n\nfor (const number of [1, 2, 3]) {\n\tconsole.log(await debouncedFn(number));\n}\n//=> 3\n//=> 3\n//=> 3\n```\n\n## API\n\n### pDebounce(fn, wait, options?)\n\nReturns a function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.\n\n#### fn\n\nType: `Function`\n\nPromise-returning/async function to debounce.\n\n#### wait\n\nType: `number`\n\nMilliseconds to wait before calling `fn`.\n\n#### options\n\nType: `object`\n\n##### before\n\nType: `boolean`\\\nDefault: `false`\n\nCall the `fn` on the [leading edge of the timeout](https://css-tricks.com/debouncing-throttling-explained-examples/#article-header-id-1). Meaning immediately, instead of waiting for `wait` milliseconds.\n\n### pDebounce.promise(function_)\n\nExecute `function_` unless a previous call is still pending, in which case, return the pending promise. Useful, for example, to avoid processing extra button clicks if the previous one is not complete.\n\n#### function_\n\nType: `Function`\n\nPromise-returning/async function to debounce.\n\n```js\nimport {setTimeout as delay} from 'timers/promises';\nimport pDebounce from 'p-debounce';\n\nconst expensiveCall = async value => {\n\tawait delay(200);\n\treturn value;\n}\n\nconst debouncedFn = pDebounce.promise(expensiveCall);\n\nfor (const number of [1, 2, 3]) {\n\tconsole.log(await debouncedFn(number));\n}\n//=> 1\n//=> 2\n//=> 3\n```\n\n## Related\n\n- [p-throttle](https://github.com/sindresorhus/p-throttle) - Throttle promise-returning & async functions\n- [p-limit](https://github.com/sindresorhus/p-limit) - Run multiple promise-returning & async functions with limited concurrency\n- [p-memoize](https://github.com/sindresorhus/p-memoize) - Memoize promise-returning & async functions\n- [debounce-fn](https://github.com/sindresorhus/debounce-fn) - Debounce a function\n- [More…](https://github.com/sindresorhus/promise-fun)\n","publish_time":1617001715023,"_cnpm_publish_time":1617001715023,"dist-tags":{"latest":"6.0.0"}}