Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
limited-request-queue
Advanced tools
Interactively manage concurrency for outbound requests.
const RequestQueue = require('limited-request-queue');
const queue = new RequestQueue()
.on('item', (url, data, done) => {
yourRequestLib(url, () => done());
})
.on('end', () => console.log('Queue completed!'));
const urls = ['http://domain.com/dir1/', 'http://domain.com/dir2/'];
urls.forEach(url => queue.enqueue(new URL(url)));
setTimeout(queue.pause, 500);
setTimeout(queue.resume, 5000);
Node.js >= 10
is required. To install, type this at the command line:
npm install limited-request-queue
new RequestQueue(options);
All methods from EventEmitter
are available.
.dequeue(id)
Removes a queue item from the queue. Returns true
if a queue item was removed and false
if not. Use of this function is likely not needed as items are auto-dequeued when their turn is reached.
.enqueue(url[, data, options])
Adds a URL to the queue. Returns a queue item ID on success.
url
must a URL
instance.data
is optional and can be of any type.options
is an optional Object
that overrides any defined options in the constructor (except for maxSockets
)..isPaused
Returns true
if the queue is currently paused and false
if not.
.length
Returns the total number of items in the queue, active and inactive.
.numActive
Returns the number of items whose requests are currently in progress.
.numQueued
Returns the number of items that have not yet made requests.
.pause()
Pauses the queue, but will not pause any active requests.
.resume()
Resumes the queue.
options.ignorePorts
Type: Boolean
Default value: true
Whether or not to treat identical hosts of different ports as a single concurrent group. Example: when true
, http://mydomain.com:80 and http://mydomain.com:8080 may not have outgoing connections at the same time, but http://mydomain.com:80 and http://yourdomain.com:8080 will.
options.ignoreProtocols
Type: Boolean
Default value: true
Whether or not to treat identical hosts of different protocols as a single concurrent group. Example: when true
, http://mydomain.com and https://mydomain.com may not have outgoing connections at the same time, but http://mydomain.com and https://yourdomain.com will.
options.ignoreSubdomains
Type: Boolean
Default value: true
Whether or not to treat identical domains of different subdomains as a single concurrent group. Example: when true
, http://mydomain.com and http://www.mydomain.com may not have outgoing connections at the same time, but http://mydomain.com and http://www.yourdomain.com will.
This option is not available in the browser version (due to extreme file size).
options.maxSockets
Type: Number
Default value: Infinity
The maximum number of connections allowed at any given time. A value of 0
will prevent anything from going out. A value of Infinity
will provide no concurrency limiting.
options.maxSocketsPerHost
Type: Number
Default value: 2
The maximum number of connections per host allowed at any given time. A value of 0
will prevent anything from going out. A value of Infinity
will provide no per-host concurrency limiting.
options.rateLimit
Type: Number
Default value: 0
The number of milliseconds to wait before each request. For a typical rate limiter, also set maxSockets
to 1
.
end
Called when the last item in the queue has been completed/dequeued.
item
Called when a queue item's turn has been reached. Arguments are: url
, data
, done
. Call the done
function when your item's operations are complete.
FAQs
Interactively manage concurrency for outbound requests.
The npm package limited-request-queue receives a total of 9,946 weekly downloads. As such, limited-request-queue popularity was classified as popular.
We found that limited-request-queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.