GithubHelp home page GithubHelp logo

promiseq's Introduction

PromiseQ Build Status

Promise queue for node.js

This package will maintain a queue of promises and use promises to return completion of a task as well as completion of the queue.

Useful for migrations and work queues. This is inspired by promise-queue but built for Node.js and uses bluebird to provide the promises and async.queue to facilitate the queue operations.

Usage

var P = require('bluebird') //or whatever promise library you prefer such as `Q`
var PromiseQueue = require('promiseq')
var workerCount = 4 //defaults to number of cpus when left null

//setup the queue
var queue = new PromiseQueue(workerCount)

//make a job
var job = function(){
  return new P(function(resolve){
    process.nextTick(resolve)
  })
}

//add a single job
queue.push(job).then(function(){console.log('Job complete')})

//close the queue and listen for the drain
queue.close().then(function(){console.log('Queue closed and drained')})

Changelog

1.1.0

  • Deprecated the processed stat in favor of complete
  • Added failed stat that tracks error counts
  • Added succeeded stat which is (complete - failed)

1.0.0

  • Update dependencies
  • Add canAccept() function to queue to see if slots are available
  • Add allowance to allow overloading of canAccept() function
  • Fix bug related to definition of total slots
  • Update license and distributor details

0.1.0

  • Initial release

promiseq's People

Contributors

nullivex avatar petah avatar

Stargazers

Stuart Hudson avatar RoestVrijStaal avatar  avatar Steve Franks avatar Kelly Campbell avatar Ryan Munro avatar Stanislav Panferov avatar Rick Blundell avatar Mike Slattery avatar

Watchers

Ryan Munro avatar James Cloos avatar  avatar Tony Butler avatar

Forkers

baronagroup petah

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.