JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 770820
  • Score
    100M100P100Q190041F
  • License MIT

In memory queue system prioritizing tasks

Package Exports

  • grouped-queue
  • grouped-queue/lib/subqueue

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (grouped-queue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Grouped Queue Build Status

In memory queue system prioritizing tasks.

Documentation

Installation

$ npm install --save grouped-queue

Methods

Constructor

The constructor take an optionnal array of tasks group. The first String name will be the first queue to be emptied, the second in second, etc.

var Queue = require('grouped-queue');

var queue = new Queue([ 'first', 'second', 'third' ]);

Queue#add add( [group], task )

Add a task into a group queue. If no group name is specified, default (the last one to be runned) will be use.

Implicitly, each time you add a task, the queue will start emptying (if not already running).

Each tasks runned in the queue will receive a callback function to call once finished.

queue.add(function( cb ) {
  DB.fetch().then( cb );
});

Pro tip

Bind your tasks with context and arguments!

var task = function( models, cb ) {
  /* you get `models` data here! */
};
queue.add( task.bind(null, models) );

That's all?

Yes!

Events

end

This event is called each time the queue emptied itself.

Todos

  • Add named task support to prevent duplicate tasks to be runned
  • Allow sub-queues to run multiple tasks concurrently

Contributing

Style Guide: Please base yourself on Idiomatic.js style guide with two space indent
Unit test: Unit test are wrote in Mocha. Please add a unit test for every new feature or bug fix. npm test to run the test suite.
Documentation: Add documentation for every API change. Feel free to send corrections or better docs!
Pull Requests: Send fixes PR on the master branch. Any new features should be send on the wipbranch.

License

Copyright (c) 2013 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.