{"name":"p-debounce","version":"2.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":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","debounce","debounced","limit","limited","concurrency","throttle","throat","limited","interval","rate","batch","ratelimit","task","queue","async","await","promises","bluebird"],"devDependencies":{"ava":"^1.3.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^3.0.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"7a7706e941366e61c5816b00f1acd6f0b99cefd9","bugs":{"url":"https://github.com/sindresorhus/p-debounce/issues"},"homepage":"https://github.com/sindresorhus/p-debounce#readme","_id":"p-debounce@2.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-CDfiUq7JoYDTukEIdyH5F+aBKM83aoquDN6Yf/eGyPuY9f7RLWMI+FqK8XlUx4Hskz9F0f4iVPHQOXsDVKkN1w==","shasum":"4c3465749891ddb432e8a86246392206fa30018e","tarball":"http://registry-npm.ywwl.com/p-debounce/download/p-debounce-2.0.0.tgz","fileCount":5,"unpackedSize":5401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJch+lhCRA9TVsSAnZWagAApVwQAIsGY5HrFJkjUkFEY2Qd\niucZ/deqv+lnZikNM9Aiy0emOje+w7sBCa7zBmOGH+PLAuzmvapTyL3ySsZx\ncRu7Y3OcH95eyt+tHU4jXWG4pZh5ESr5odBMQIlIL7uubGys7plGGOn+q1dR\nKbSHZ9u+p9FWYvlhH+tspOWus+a4GBwhIv7H6Av5JkG/Yu5hNtKxv/QUBmMi\nZ9K2c3lerr8YlVqLsjltbz4FXfM/gG+t40Pc0h2HJULQdoLiGTAshHaIE5i3\nmbR+KoJcpzbJ4tdBYkPi1qSS6jcDMxeMpyRGEcd8iYKrhPXroN4dfFo/Wnjm\n9d7ar8eKrLfEIRjGUExJGDn15bPClPZHxsWC71p3ZJDObAsB9f0ZrKy2ipuF\n63GQW80Hd+Vfd26lletxy633UUtgvRUmJCBW2eyYeGUpQpp8OUVGvcGojrMd\npgv8io09G5uj3nXRei6+pwVRAyYhV92GSn0LiljYLaVJeCZqP15+E0KvlxP+\ndC3f6SkKEm7yJi0L1AZYBOqJMoqcyK4Z7meQ5TVmre0Ym2WlIZcMUpRpHDsL\n3h87o4WsNf5SQgxCozywcazueZeL+6muwKZXKBd+Qh+9KhXNztlh68IQYpR0\nAw0sc4qi60xPosfjeXzvVjVHlK5D59lpwZwiExMPW2x/SwsIp3qAlGm2aMXH\nBFg9\r\n=Q9ew\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGj+OvGPKM5itYW7k37UhFzGno+o3ryZqDVB3ppBknYGAiEAvfUPdcVg4SjM2joWo8WRWJLGk99dz7g9oazH59y3P6k="}],"size":2414,"noattachment":false,"key":"/p-debounce/-/p-debounce-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-debounce_2.0.0_1552410976359_0.4206259313205092"},"_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":1552410976483,"_cnpm_publish_time":1552410976483,"dist-tags":{"latest":"6.0.0"}}