queue / 3.0.7 last updated 6 months ago created on Nov 4th 2012
Install
npm install --save queue
Clone
git clone git@github.com:jessetane/queue.git
maintainers
versions
18 total
| 3.0.7 | 6 months ago | jessetane |
| 3.0.6 | 8 months ago | jessetane |
| 3.0.5 | 8 months ago | jessetane |
| 3.0.4 | 8 months ago | jessetane |
| 3.0.3 | 8 months ago | jessetane |
| 3.0.2 | 8 months ago | jessetane |
| 3.0.1 | 8 months ago | jessetane |
| 3.0.0 | 8 months ago | jessetane |
| 2.2.0 | a year ago | jessetane |
| 2.1.2 | a year ago | jessetane |
| 2.1.1 | a year ago | jessetane |
| 2.1.0 | a year ago | jessetane |
| 2.0.0 | a year ago | jessetane |
| 1.0.2 | a year ago | jessetane |
| 1.0.1 | 2 years ago | jessetane |
| 1.0.0 | 2 years ago | jessetane |
| 0.0.2 | 2 years ago | jessetane |
| 0.0.1 | 2 years ago | jessetane |
readme
Asynchronous function queue with adjustable concurrency.
Why
Async is a big library offering various approaches to dealing with asynchrony; queue is a small library offering a single, flexible abstraction.
How
This module exports a class Queue that implements most of the Array API. Pass async functions (ones that accept a callback) to an instance's additive array methods. Processing begins when you call q.start().
Install
npm install queue
Test
npm testnpm run test-browser
Example
npm run example
Require
var queue = require('queue')
Constructor
var q = queue([opts])
Where opts may contain inital values for:
q.concurrencyq.timeout
Instance methods
q.start([cb])
cb, if passed, will be called when the queue empties or when an error occurs.
q.stop()
Stops the queue. can be resumed with q.start().
q.end([err])
Stop and empty the queue immediately.
Instance methods mixed in from Array
Mozilla has docs on how these methods work here.
q.push(element1, ..., elementN)
q.unshift(element1, ..., elementN)
q.splice(index , howMany[, element1[, ...[, elementN]]])
q.pop()
q.shift()
q.slice(begin[, end])
q.reverse()
q.indexOf(searchElement[, fromIndex])
q.lastIndexOf(searchElement[, fromIndex])
Properties
q.concurrency
Max number of jobs the queue should process concurrently, defaults to Infinity.
q.timeout
Milliseconds to wait for a job to execute its callback.
q.length
Jobs pending + jobs to process (readonly).
Events
q.emit('success', result, job)
After a job executes its callback.
q.emit('error', err, job)
After a job passes an error to its callback.
q.emit('timeout', continue, job)
After q.timeout milliseconds have elapsed and a job has not executed its callback.
q.emit('end'[, err])
After all jobs have been processed
Releases
The latest stable release is published to npm. Abbreviated changelog below:
- 3.0.x
- Change the default concurrency to
Infinity - Allow
q.start()to accept an optional callback executed onq.emit('end')
- Change the default concurrency to
- 2.x
- Major api changes / not backwards compatible with 1.x
- 1.x
- Early prototype
License
Copyright © 2014 Jesse Tane jesse.tane@gmail.com
This work is free. You can redistribute it and/or modify it under the terms of the WTFPL.
No Warranty. The Software is provided "as is" without warranty of any kind, either express or implied, including without limitation any implied warranties of condition, uninterrupted use, merchantability, fitness for a particular purpose, or non-infringement.
