{"name":"p-debounce","version":"3.0.0","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":"a9ad96b63eb741d9462530540c243e14a6d1cda7","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@3.0.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-2dK8+78sCGkn4EUGoM8eZ6KrB9nvIRqQaFPjJcpXs6tz05Ad8cfsAy/VW2UAqJ+0IgMFT2Vwn1PKXFFuQa7cEQ==","shasum":"ae634b5be4a438297c31cbfdc3515ded21009d43","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-3.0.0.tgz","fileCount":5,"unpackedSize":7280,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBczGCRA9TVsSAnZWagAAJakQAIcHUix4WQnRrJFiw+Rg\nk/fj8f9Gj/OSk//sgFno8YrhQyZIemBu/RQMxIUuEUnJS2nnAMCA4DejuoVh\nDdqo0WY/YwimIJRMuGzxTpigyN+i8vY0YR9u4dqcjbZMOgoESJ0nw4F7Q04Z\nbZZyn2iHIAnP8rWqPeWpU9jinQBQj0b+oX3SKQ1gVCtkZrAX71KBM2IWbHHu\n7LwRuARcFuJUoVNTd2EL02b8Q0JZMdwjEcpYtw0hCqEXx9sHtYivNH0JtyDH\na9gISzmyDs9BTjEEhAIgjtz5/1+uazGmrw5lYxN6BgICcG+a6EyqVWcEvhyb\nRGk6BLwUBEyoXDjlIMfMczfukVEiqsiiCarzmVCI/E0Dyso4SfofbPVg6IMf\nX+bnKpr6/ZQZjTIjMa0E+Q09YhCIetu7ZprHmc5i3h4MK00XVBg1ik24LV+v\nj8hYmnF5eyByV0hwC5LVsuphiUVYN0SBoML+99GlPMtNtXbOaVu0LuBWAGpK\nv/EW9Xoy3mPb+GxvjV18MCanutEogO1sqsKCCGQ8uR7T6UxBezwPaz/nRfF3\nfdSZjlmjwWEzcNiYXOvPuHc6oIUbU+Xy5i5NmVuukN7I+TIvmx9LNQfcWukd\nMKk3UFZEDXrKdSB8rKyFqPNJ9NRKntRlH66xDUqPpZVTi/xar2nqHUXBc95Y\nXpsP\r\n=5Wkk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHSuxNSvg2bEB7rfiZ4kImY38jFct+D5xIBZeB7QoMUOAiBAo/tTaNTUVGkTyeIQpqim8OZJsaZ4LRstGtnACDdCnQ=="}],"size":2717,"noattachment":false,"key":"/p-debounce/-/p-debounce-3.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_3.0.0_1610992837846_0.5550233853649027"},"_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":1610992837993,"_cnpm_publish_time":1610992837993,"dist-tags":{"latest":"6.0.0"}}