{"_id":"@rexxars/p-ratelimit","_rev":"2-99e12917aa948d99b316445aef7aa0b8","name":"@rexxars/p-ratelimit","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@rexxars/p-ratelimit","version":"1.0.0","description":"Promise-based utility to make sure you don’t call rate-limited APIs too quickly.","repository":{"type":"git","url":"git+https://github.com/natesilva/p-ratelimit.git"},"license":"MIT","author":{"name":"Nate Silva","email":"nate@natesilva.com"},"main":"build/src/index.js","types":"build/src/index.d.ts","scripts":{"test":"ava","coverage":"nyc --extension .ts --reporter lcov --reporter text ava","prepare":"del-cli build && tsc","prettier":"prettier --write \"{src,test}/**/*.?(ts|json)\""},"keywords":["ratelimit","concurrency","promise","promises","limit","throttle","tokenbucket"],"engines":{"node":">=10.23.0"},"devDependencies":{"@types/node":"^10.17.48","ava":"^3.14.0","del-cli":"^3.0.1","np":"^7.0.0","nyc":"^15.1.0","prettier":"^2.2.1","testdouble":"^3.16.1","ts-node":"^9.1.1","tslint":"^6.1.3","typescript":"^4.1.2"},"dependencies":{},"volta":{"node":"10.23.0","npm":"6.14.9"},"gitHead":"846eff858367c09aafa9931c12ec12164c0a7403","bugs":{"url":"https://github.com/natesilva/p-ratelimit/issues"},"homepage":"https://github.com/natesilva/p-ratelimit#readme","_id":"@rexxars/p-ratelimit@1.0.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-zjiOpP8q6muRyaE5j+w2JhSu8Vukpeuj66gcM2zhlaqj75Plh8G/zc98a3w/HV+PUMe69fvVeo94XqBH7hDvDA==","shasum":"620381e094cfbe98d61881dd29016fa04198dd81","tarball":"https://registry.npmjs.org/@rexxars/p-ratelimit/-/p-ratelimit-1.0.0.tgz","fileCount":21,"unpackedSize":18351,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8DHpCRA9TVsSAnZWagAASqMQAI/I/+vJeEHE4OOYXMSa\nORCEDXBrTt3AaCYr1WL9fuvrn0w5jMSUYBxfYUuc0Y1XN4gAqelCNMUOJKiR\nVtfplCs9uen1iS0h1pIUXpUSrUVssjQECLmnAuXKy1sovwdfTNJdeiUt5LyX\nNxSZrUEHChpXQ3BdM8h0d+VrHpmYxACQEdiJ4KUIA3bmfW3r8vvRZqhevcHQ\n+uhDqvgY0eRVjdQEloi/8YOoYu1h3ISleXPwwMZ3qBFT3sc03JKqO7YjJG/c\nPZS2cccXAPJmcE9UEv0RZrbr/RFpRi9dWKjTyrDHu9sLXIz6gi9qp9HmC2WZ\nj214zusAgUmwym9ShdTPruLYPejs5S1Jf3y0M5iVV7bn8vB9zbAfi7HmlrFY\nrf1oFLGh3y0Ik/QzLIzzKRU3AZ0710JuHC4RJQEKSFYzucTqvUlpVmNvlUAM\n89Q8QvS5GhFYXVe79R8PqH8pjWiZAsSVCdjArmpZRyMATrGVdvghrWKAT78b\nbjWgiT6QMSsWtyGL5QY5OfT3WDfNYN0PE7FwGtaBAWhZdEPhSo20Oe+ek/vy\ne8aUNl+4Q1geygX4sMYBueHhQxXyhLV5HwXElcEZtWiBe+mrErls/+uN6Y9Z\nayn/5jYtk2xiCS5GgjvysmRIrwNLKgAZ0xPlFGF57GsCyq73rLUGQxVncPpP\nZXon\r\n=llPf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDC0BkAF6w93JhiDKg+Ysbt0tkNqJN8NLtL5LmaMLm7uQIgCW8gThIxzlYb35Vj+KCI0b0PCABgvJL+vg+wBgylgLk="}]},"_npmUser":{"name":"rexxars","email":"espen@hovlandsdal.com"},"directories":{},"maintainers":[{"name":"rexxars","email":"espen@hovlandsdal.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-ratelimit_1.0.0_1609576937086_0.5704242779737361"},"_hasShrinkwrap":false},"1.0.1":{"name":"@rexxars/p-ratelimit","version":"1.0.1","description":"Promise-based utility to make sure you don’t call rate-limited APIs too quickly.","repository":{"type":"git","url":"git+https://github.com/natesilva/p-ratelimit.git"},"license":"MIT","author":{"name":"Nate Silva","email":"nate@natesilva.com"},"main":"build/src/index.js","types":"build/src/index.d.ts","scripts":{"test":"ava","coverage":"nyc --extension .ts --reporter lcov --reporter text ava","prepare":"del-cli build && tsc","prettier":"prettier --write \"{src,test}/**/*.?(ts|json)\""},"keywords":["ratelimit","concurrency","promise","promises","limit","throttle","tokenbucket"],"engines":{"node":">=10.23.0"},"devDependencies":{"@types/node":"^10.17.48","ava":"^3.14.0","del-cli":"^3.0.1","np":"^7.0.0","nyc":"^15.1.0","prettier":"^2.2.1","testdouble":"^3.16.1","ts-node":"^9.1.1","tslint":"^6.1.3","typescript":"^4.1.2"},"dependencies":{},"volta":{"node":"10.23.0","npm":"6.14.9"},"gitHead":"daa6a139e36a1c4df47fd887f0d822a295cb1e79","bugs":{"url":"https://github.com/natesilva/p-ratelimit/issues"},"homepage":"https://github.com/natesilva/p-ratelimit#readme","_id":"@rexxars/p-ratelimit@1.0.1","_nodeVersion":"14.15.1","_npmVersion":"6.14.10","dist":{"integrity":"sha512-vfocCHeESEVxIoG8y84flJVtJDsZr2siTaH2PEhhs4sTNumkmecDVxpX5lr0jHJyiSp28AjAUStsxbHYRz/dZA==","shasum":"a79724fb18fa07793263c14249875c6241d3ee59","tarball":"https://registry.npmjs.org/@rexxars/p-ratelimit/-/p-ratelimit-1.0.1.tgz","fileCount":21,"unpackedSize":18699,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf8DP4CRA9TVsSAnZWagAAsCAP+wUV40bTFMxgbM4oEfmI\nUnO1A+U0AwPmJgREcBtAepSKix/kvqDBjmpAnXgP29b7RRHCK0XF6ec+UAdj\nvxKL8+Hftjas7b0tA9fqC6aOljzOPzsGDbJFIdDz2b6QqUa39KckaT1ZmX3X\nAkxMazQZJ3b5n0Nl7NaX1cCfQiNUjByol1FVE/+cXxcdAWRPzUD0+c+sRZs0\nhniv5he+7ssjlcmHky3cGiVkykUPZE5Yj+1FMPnPoRXtVfY3Q1UJbMDccUbo\nGApRPhhmIDkiAoVpNM0hQaHQyjMSKLNs7Kxn5s//AnxE2g7QfuMcNP/N3u7u\nc5QemnHZFzQR43ZF9GBg/QUEn7/H0TGFY2pQkDhIol0hiT2IXNc1Ave8pY7e\ncOxsO3IE/3peUQQzYnqBwvkD2o7D8Mtpv8mSFtYlWL0wV4keP8a1WsvLgSwG\ndzg3Z4kSNI8tC5JRvnyaoaAklYE+zjVGMr6ANi2Bs4twRiiLz9fiuFPfLYUA\nvj9HeZW9Eexxqj1zszN5wwThE+GD51gnj8wwsZwbdn+rAA6jjv1uiWHrQdVC\nRzlHJhXEtRe9T8rXmnQNMA19klVPf8tR/0m+ywjiAqBbVOyCgu71rnkhm4li\nwZ5ypKlLjNXZyE7zyu7GY2/9VfceJfOUYJP/nexEn1AQnSEcHUpltm5fb4Co\ncNb6\r\n=uy5k\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCHwlP7ei8RGNDk3+TWS/w701G6ljsKY9A2ZtTosbIWI4CIQCXsLyXrEAPCHldaazLDKZq8iKhGvKt9h/oTYGrhB6GbQ=="}]},"_npmUser":{"name":"rexxars","email":"espen@hovlandsdal.com"},"directories":{},"maintainers":[{"name":"rexxars","email":"espen@hovlandsdal.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-ratelimit_1.0.1_1609577464434_0.8411261750809609"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-02T08:42:17.052Z","1.0.0":"2021-01-02T08:42:17.274Z","modified":"2022-04-06T19:42:58.177Z","1.0.1":"2021-01-02T08:51:04.602Z"},"maintainers":[{"name":"rexxars","email":"espen@hovlandsdal.com"}],"description":"Promise-based utility to make sure you don’t call rate-limited APIs too quickly.","homepage":"https://github.com/natesilva/p-ratelimit#readme","keywords":["ratelimit","concurrency","promise","promises","limit","throttle","tokenbucket"],"repository":{"type":"git","url":"git+https://github.com/natesilva/p-ratelimit.git"},"author":{"name":"Nate Silva","email":"nate@natesilva.com"},"bugs":{"url":"https://github.com/natesilva/p-ratelimit/issues"},"license":"MIT","readme":"# p-ratelimit [![npm](https://img.shields.io/npm/v/p-ratelimit.svg)](https://www.npmjs.com/package/p-ratelimit) [![license](https://img.shields.io/github/license/natesilva/p-ratelimit.svg)](https://github.com/natesilva/p-ratelimit/blob/master/LICENSE) [![node](https://img.shields.io/node/v/p-ratelimit.svg)](https://www.npmjs.com/package/p-ratelimit)\n\n> Makes sure you don’t call rate-limited APIs too quickly.\n\nThis is an easy-to-use utility for calling rate-limited APIs. It will prevent you from exceeding rate limits by queueing requests that would go over your rate limit quota.\n\nRate-limits can be applied across multiple servers if you use Redis.\n\nIt works with any API function that returns a Promise.\n\n## Install\n\n```\n$ npm i @rexxars/p-ratelimit\n```\n\n## What’s different\n\n- **True rate limiting**\n  - Utilities like [p-limit](https://github.com/sindresorhus/p-limit) control how many functions are running concurrently. That won’t prevent you from exceeding limits on APIs that use token-bucket throttling.\n  - **p-ratelimit** supports both concurrency and rate limits.\n- **Works across API families**\n  - Utilities like [Lodash throttle](https://lodash.com/docs#throttle) create separate quotas for each API function.\n  - **p-ratelimit** can enforce a single shared quota for all functions in an API family.\n- **Minimal implementation**\n  - Utilities like [limiter](https://github.com/jhurliman/node-rate-limiter) provide low-level tooling that requires you to manage tokens and provide your own queue.\n  - **p-ratelimit** requires minimal modification to your existing code.\n- **Made for Promises and TypeScript friendly**\n  - A rate-limited function returns the same Promise type as the original function.\n\n## Changes in @rexxars-fork\n\n- Targets ES5 - replaces some of the internal uses of ES6 classes with functions/closures\n- Removes redis quota manager because of the more browser-focused target\n- Removes some internal functions which were not used, reducing bundle size\n\nSee [https://github.com/natesilva/p-ratelimit](natesilva) for the original version!\n\n## Example\n\n```javascript\nconst { pRateLimit } = require('p-ratelimit');\n// import { pRateLimit } from 'p-ratelimit';       // TypeScript\n\n// create a rate limiter that allows up to 30 API calls per second,\n// with max concurrency of 10\nconst limit = pRateLimit({\n  interval: 1000, // 1000 ms == 1 second\n  rate: 30, // 30 API calls per interval\n  concurrency: 10, // no more than 10 running at once\n  maxDelay: 2000, // an API call delayed > 2 sec is rejected\n});\n\nasync function main() {\n  // original WITHOUT rate limiter:\n  result = await someFunction(42);\n  // with rate limiter:\n  result = await limit(() => someFunction(42));\n}\n\nmain();\n```\n\n## Configuration\n\nThe `Quota` configuration object passed to `pRateLimit` offers the following configuration settings:\n\n### If you care about rate limiting\n\nSet both of these:\n\n- `interval`: the interval over which to apply the rate limit, in milliseconds\n- `rate`: how many API calls to allow over the interval period\n\n### If you care about limiting concurrency\n\n- `concurrency`: how many concurrent API calls to allow\n\n### If you care about both rate limiting and concurrency\n\nIf you want both rate limiting and concurrency, use all three of the above settings (`interval`, `rate`, `concurrency`).\n\n### Other options\n\n- `maxDelay`: the maximum amount of time to wait (in milliseconds) before rejecting an API request with `RateLimitTimeoutError` (default: `0`, no timeout)\n- `fastStart` (Redis only): if true, immediately begin processing requests using the full quota, instead of waiting several seconds to discover other servers (default: `false`)\n\nIf you make an API request that would exceed rate limits, it’s queued and delayed until it can run within the rate limits. Setting `maxDelay` will cause the API request to fail if it’s delayed too long.\n\n## License\n\nMIT © Nate Silva\n","readmeFilename":"README.md"}