Gathering detailed insights and metrics for concurrent-queue
Gathering detailed insights and metrics for concurrent-queue
Gathering detailed insights and metrics for concurrent-queue
Gathering detailed insights and metrics for concurrent-queue
queue
asynchronous function queue with adjustable concurrency
async-limiter
asynchronous function queue with adjustable concurrency
d3-timer
An efficient queue capable of managing thousands of concurrent animations.
concurrent-tasks
A simple task runner which will run tasks concurrently while maintaining limits.
npm install concurrent-queue
Typescript
Module System
Node Version
NPM Version
JavaScript (90.36%)
Makefile (9.64%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
26 Stars
86 Commits
3 Forks
1 Watchers
1 Branches
1 Contributors
Updated on Sep 20, 2024
Latest Version
7.0.2
Package Id
concurrent-queue@7.0.2
Size
8.89 kB
NPM Version
3.10.10
Node Version
6.10.3
Published on
Sep 05, 2017
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Fifo queue with concurrency control
1var cq = require('concurrent-queue') 2 3var queue = cq().limit({ concurrency: 2 }).process(function (task, cb) { 4 console.log(task + ' started') 5 setTimeout(function () { 6 cb(null, task) 7 }, 1000) 8}) 9 10for (var i = 1; i <= 10; i++) queue('task '+i, function (err, task) { 11 console.log(task + ' done') 12})
or with promises:
1var cq = require('concurrent-queue') 2 3var queue = cq().limit({ concurrency: 2 }).process(function (task) { 4 return new Promise(function (resolve, reject) { 5 console.log(task + ' started') 6 setTimeout(resolve.bind(undefined, task), 1000) 7 }) 8}) 9 10for (var i = 1; i <= 10; i++) queue('task '+i).then(function (task) { 11 console.log(task + ' done') 12})
1var cq = require('concurrent-queue')
Create a queue.
Push an item to the queue. Once the item has been processed, the optional callback will be executed with arguments determined by the processor.
Returns a promise that will be resolved or rejected once the item is processed.
Configure the queue's processor
function, to be invoked as concurrency allows with a queued item to be acted upon.
The processor
argument should be a function with signature function (item [, cb])
. If the processor function signature included a callback, an error-first style callback will be passed which should be executed upon completion. If no callback is provided in the function signature, and the processor function returns a Promise
, the item will be considered complete once the promise is resolved/rejected.
This function returns a reference to queue
.
Set queue limits with a limits object. Valid limit properties are:
concurrency
- (default: Infinity
) - determine how many items in the queue will be processed concurrentlymaxSize
- (default: Infinity
) - determine how many items may be pending in the queue before additional items are no longer accepted. When an item is added that would exceed this, the callback
associated with the item will be invoked with an error and/or the promise
returned by queue()
will be rejected.softMaxSize
- (default: Infinity
) - determine how many items may be pending before the queue begins producing warnings on the softLimitReached
eventuate property.This function returns a reference to queue
.
enqueued
is an eventuate. Use this to supply a function that will be executed when an item is added to the queue. The function will be passed an object with the following properties:
item
- The queued item that is being processedrejected
is an eventuate. Register a function to be executed when an item is rejected from the queue. This can happen, for example, when maxSize is exceeded. The function will be passed an object with the following properties:
item
- The item that was rejected from the queueerr
- An error containing the reason for rejectionsoftLimitReached
is an eventuate. Register a function to be executed when the configured soft size limit has been reached or exceeded. This function will be executed any time an item is added to the queue
when the queue.limit
meets or exceeds the softMaxSize
value. The function will be passed an object with the following properties:
size
- the queue.size
processingStarted
is an eventuate. Register a function to be executed once an item has transitioned from pending
to processing
. The function will be passed an object with the following properties:
item
- The queued item that is being processedprocessingEnded
is an eventuate. Register a function to be executed once processing of an item has completed or failed. The function will be passed an object with the following properties:
item
- The queued item that was processederr
- Will be present if there was an error while processing the itemdrained
is an eventuate. Register a function to be executed each time the queue is fully drained (no items pending or processing).
A numeric value representing the number of items in queue, waiting to be processed.
A boolean value indicating whether the queue is in a drained state (no items pending or processing).
An array of items waiting to be processed.
The processor function is one has been configured via queue.process()
,
otherwise undefined
. This is a read-only (getter) property.
An array of items currently being processed.
An integer property representing the number of concurrent queue items that will be processed. This defaults to Infinity
, but may be re-assigned. An integer value must be assigned to this property. This property may also be set by calling the limit()
function and passing an object with the concurrency
property. Setting this property to 0
will halt the queue (once all in-process items are complete), while setting it to Infinity
removes all limits.
An integer property representing the maximum number of items that may be pending in the queue. This defaults to Infinity
, but may be re-assigned. An integer value must be assigned to this property. This property may also be set by calling the limit()
function and passing an object with the maxSize
property.
An integer property representing the maximum number of items that may be pending in the queue before warnings are produced. This defaults to Infinity
, but may be re-assigned. An integer value must be assigned to this property. This property may also be set by calling the limit()
function and passing an object with the softMaxSize
property.
1var errors = require('concurrent-queue/errors') 2var MaxSizeExceededError = errors.MaxSizeExceededError
Constructor for errors representing the queue.maxSize
constraint being exceeded. This is supplied to the callback and/or promise rejection when an item cannot be queued due to queue.maxSize
constraints. Example:
1var cq = require('concurrent-queue'), 2 MaxSizeExceededError = require('concurrent-queue/errors').MaxSizeExceededError 3 4queue = cq().limit({ maxSize: 100, concurrency: 1 }).process(function (item, cb) { 5 // do something 6}) 7 8queue({}, function (err, result) { 9 if (err instanceof MaxSizeExceededError) { 10 // the queue is full 11 } 12 else if (err) { 13 // otherwise an error happened while processing... 14 } 15})
With npm do:
npm install concurrent-queue
npm test [--dot | --spec] [--phantom] [--grep=pattern]
Specifying --dot
or --spec
will change the output from the default TAP style.
Specifying --phantom
will cause the tests to run in the headless phantom browser instead of node.
Specifying --grep
will only run the test files that match the given pattern.
npm run browser-test
This will run the tests in all browsers (specified in .zuul.yml). Be sure to educate zuul first.
npm run coverage [--html]
This will output a textual coverage report. Including --html
will also open
an HTML coverage report in the default browser.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More