{"name":"p-debounce","version":"3.0.1","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":"e073518702b69db9637760a12717a7c99dd0a4b9","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@3.0.1","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-7n7FWY/f4gmVkd6BwC2EZRbTnAmZbL/Zdrc3qbJRnwkb3OUp4HbPlEN1XybpQk0MML6RDDdePMFIr4dOXXfPNw==","shasum":"51c38b03aa09f319ec507f1d8aba831949c8bbf2","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-3.0.1.tgz","fileCount":5,"unpackedSize":7313,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCxXhCRA9TVsSAnZWagAAp1sQAIpCLM27eimfckm3YSU+\nQxvUK9Qd/zRZVnCBqbL+UTmNXdaUpJInAFqNfRBVyk6sRZpbkLKkvyYCt+NO\nc0AkISFa0Cht0gSpX8X0gr9vCY9sCC2CU64o7mxDg1jDA+YPNEKN9wIXewu/\nbOQ4QjrPcZJKRbt04XOi8NbLJQg3xWGgYuBV31tglcnc6m64OASpbhhwz9bB\n9ekzzCt8tQLQwPraHeX2YircqLAv3tluSYCt9gnQt57fCEx8Zc4ArDqEtYJv\nKFhawI6gZxNrA9b6qE7v1gehvBJyVagDoAV0EFGgVPsoXz5502VUCs1MlG+U\nS/gXPpqTbYs6ItETtJ6wQhIF89jXVGkzTuJw6hz/OBnoG2FDbYKLDJph7O2N\n7cgYPHIicLbRN6sakiW18ALlnfQ36Nb6lLZoRkwKGrtYCLbev0K53ShElCCw\ngAXO/Mcbt0arZKzRhmCByoX+M7TW7b+29jWEtNtLZmGgeLRW/N+mnvHn4tZA\nnnniSnV0CKEo833DNMYhqo8Oc6UbiOykcOz76LQd5jVsggxzGfuYHifu5Jdi\nnWR65Wp0JSZGseUyqK4Toz7VBhyR1D0q5my63c1yG9SJ0LeoHZsjxh/WJTv1\nfHLpudxadBzdM3wNn5nooEfx8JzgrQZ286CEdVfzK3pr0IQwLCAZ29Rpt3u8\nGmnb\r\n=clOp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFKE/ahxF+h69SKc3nzgMU7S0Vju6xdwfa1ho2tkui2iAiEA1iIF6jjrEk2iFV5k75XAXs36c6xlBlytn88GHkPUZDo="}],"size":2725,"noattachment":false,"key":"/p-debounce/-/p-debounce-3.0.1.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_3.0.1_1611339233180_0.34449890013638496"},"_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":1611339233290,"_cnpm_publish_time":1611339233290,"dist-tags":{"latest":"6.0.0"}}