{"name":"p-debounce","version":"4.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":"1be433d4f1922d4e8496edb7eac5afa960625cb0","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@4.0.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-4Ispi9I9qYGO4lueiLDhe4q4iK5ERK8reLsuzH6BPaXn53EGaua8H66PXIFGrW897hwjXp+pVLrm/DLxN0RF0A==","shasum":"348e3f44489baa9435cc7d807f17b3bb2fb16b24","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-4.0.0.tgz","fileCount":5,"unpackedSize":7302,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfqNfCRA9TVsSAnZWagAAQ4EP/3Q35fznsS1cpAcUTkOu\nvOvpCHf43NJhvJZis76WXFny+fhjjoGc3aQmKacYtiXv0ecZrpEktgnEJKox\nEZ4y/6mADtqT4jv68yNGUfMSYy/2jsqQXfKr0eivQabVe5qw70t+Ay5GBuQN\njcnZRXfw5Ysz0GJ2CcFLHwfbmc4xbhMLZExgZ2PEOppWEmer6/hp51LjghlZ\nVNOtB+8VaaJBpzzWASsNbz3gymMY1cDwaq2upcjsr3WoY07es+2s/rGWKDeG\neIb1Zk1wBTTqO6T3299FvX0AqQl4kD8t6zHyPAzRBrdMZ26G5BCOZiYOiu0T\ngYVdy+GphP7w4pxW+jq2yDOmnwsnpUuZARyJVQiWTTaJVxfuYCpVYsitt7/W\nJ3BMr1Txxcs1lNsRRTREX8EgMlfcE1/UaCjqqKj+5DPE3QQPSdOdyqqMTxUN\nHycwMaOCKtcE7MPlSiR2X6GJ3FRf1tcKqTnl9nPhgUZPC4Ur/cg36DzddxSl\nHvwXIi1MmYf0jINPpCBrNbaStyPtqjXT5seUcAvAXZUbtOdNmF1mICuOoK8G\nIC3pHR+etSGxpCfWc5/b2MwRYxWOWS/cni4Y525ABhG04vIeGtecaQLvD4Mw\nIAgTAfGAMOkNNrr4C0Efy4DaxGfwhNfCe++7jqSoOsAH0bGbhahwUKczwkdO\naYtE\r\n=q72I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAuyX1XksmtcZ2mPEDU86Tbu7FqZXgrB8n7FcrQx7wA8AiEAreGGNW8hIA2bYrgpnUv6PYkpSwqjwJIDj29v01eBXkg="}],"size":2737,"noattachment":false,"key":"/p-debounce/-/p-debounce-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_4.0.0_1618912095435_0.21708815423302696"},"_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":1618912095621,"_cnpm_publish_time":1618912095621,"dist-tags":{"latest":"6.0.0"}}