
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Run easily queue of tasks.
It is available with bower or npm:
bower install queuer.js
npm install queuer.js
Include queuer.min.js
to the HTML, and the queuer
object is now available in the global scope:
<script type="text/javascript" src="/path/to/bower_components/queuer.js/dist/queuer.min.js"></script>
Alternately, you can use a module manager to avoid global scoping:
var queuer = require('queuer.js');
// or es6 import
import queuer from 'queuer.js';
var queue = queuer();
queue.task('task1', function(payload, queue) {
// the payload will be either the result of the previous task
// or the initial payload given to the queue if it is the first task
// the queue argument is the task's queue
console.log('I am a task');
// if you want to deal with async task you must return a promise.
});
queue(initialPayload) // You can pass an initial payload to the queue
.then(function(payload) {
// everything worked
// the payload is the result returned by the last task
})
.catch(function(error) {
// an error occured, the queue was stopped
});
The queue is an event emitter. That means you can emit or listen events on it. The queue already emit some events:
EVENT_TASK_START
: A task was started.EVENT_TASK_STOP
: A task was stopped.EVENT_TASK_START
: A task threw an error.EVENT_CANCEL
: The queue was canceled.To register an event listener use on(event, listener)
or once(event, listener)
method on the queue:
queue.on(queue.EVENT_TASK_START, function(taskName, payload) {
// taskName was started with the given payload
// other task events have the save listener signature
});
queue.once(queue.EVENT_CANCEL, function() {
// the queue was cancelled
// we use once instead of on because it will happen only once
});
As the queue is given as an argument to the task, you can use it in tasks to listen or to emit some custom event as you wish:
queue.task('task1', function(payload, queue) {
queue.once(queue.EVENT_CANCEL, function() {
// the queue was canceled, we use this to cancel our task's asynchronous operations
});
queue.on('myCustomEvent', function(data) {
// we listen to our custom event
});
});
queue.emit('myCustomEvent', 'test');
The queue exposes a shorcut method to cancel it queue.cancel()
. You can pass arguments to it if you wish, they will be forwarded across the cancel event.
make install
make build
or make build-dev
(unminified version)
make watch
make test
All contributions are welcome and must pass the tests. If you add a new feature, please write tests for it.
This application is available under the MIT License.
FAQs
Run easily queue of tasks.
The npm package queuer.js receives a total of 29 weekly downloads. As such, queuer.js popularity was classified as not popular.
We found that queuer.js 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.