{"name":"p-debounce","version":"2.1.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":"sindresorhus.com"},"engines":{"node":">=6"},"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":"^1.4.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^3.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"b213e791ad649af0347143561513ca2c54c1e552","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@2.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-M9bMt62TTnozdZhqFgs+V7XD2MnuKCaz+7fZdlu2/T7xruI3uIE5CicQ0vx1hV7HIUYF0jF+4/R1AgfOkl74Qw==","shasum":"e79f70c6e325cbb9bddbcbec0b81025084671ad3","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-2.1.0.tgz","fileCount":5,"unpackedSize":6139,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpv8yCRA9TVsSAnZWagAAGLUP/2x+rNO3vGDa9tJcn4Hf\njna4BphXI0Qa7gSaYAy2kqGp8j9qwEtVnF+2+gdEMSPzS8PSeyM+H0PDXR78\n9pSLZU8Z9fuubcbQJ/RhoD9NHpfIFTJX03bQ01nbm6J4KEEntIb0m2PDJIve\ng96sz/md+Kre/T3nd8+Fm2mMr4tcl9fS3bovV5wssMRpBXimmO6WFT+eyqhP\ni0yelo7SODCjvHJKBYur3yVx46IVI4/xeHH04ZLr3t2VrzLDtLMre/NaBXcA\nC+Jmeb5vDecvtU15SiVya5WGgxKfXXayDgQWbjE3B2KjJnR3pdTvUpVBVB5L\nPi96/sWPbwOCXNoRs2+JREcw7o7atRauSzxQOsOW8bLZ58H3SoZlEOWwj6RC\neCOa9x8R5CinsD0vUvKpuOzFzDu2aZcMUoOcPZIJtVEkWOq0pmoYdmEdsKwO\n1Xt5bOoDjd2Tt1OWXkbmE3DDWJqBgu+/hLQqEBkKo6FydGvZ/jQPntuTKLNF\nOMNQ1pQcbPwhUewOfV0STtCaLR3Cw0LGTdoBXzzvoYqOoBnrN0npUX8J6sfK\nSVXw/wSGSwpldUwBQHFWZGehOJfCqDq51VimB/8VPNweMgae5oAqexjNr5nu\nxinLSIIjB9gdMLSeHe/gBEkdkX3wDf3msMbsEgHBiCsRoDq/qWy5pCtvb3bP\nYmvF\r\n=OGQe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE2F7XempOwt9CRhm+lhHwTloLrZ/rrOqonM/oGSjM1IAiEAxZBQkNlb4sVfUZk9HByOTpKKRM6CB7ZmrSrSEZgMrCM="}],"size":2570,"noattachment":false,"key":"/p-debounce/-/p-debounce-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_2.1.0_1554448177450_0.13740964293712787"},"_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":1554448177561,"_cnpm_publish_time":1554448177561,"dist-tags":{"latest":"6.0.0"}}