Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple queue to execute any function on FIFO order.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
samples
src
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

FunctionQueue

Simple queue to execute any function on FIFO order.

NPM

Build Status

Requirements

Installation

No installation is needed.

Usage

var FunctionQueue = require("function-queue")();
FunctionQueue.push(function (callback) {
    console.log("dede");
    setTimeout(function () {
        console.log("timeout");
        //you must call callback to continue queue
        callback()
    },1000);
})
FunctionQueue.push(function (callback) {
    console.log("dedeOut");
    //you must call callback to continue queue
    callback();
})

More samples at samples/ directory.

Methods

Initialize Wrapper

Sample:

var FunctionQueue = require("function-queue")();

Add Function into queue

Parameters:

  • function - Type:function - Description:Function to be added on queue. - REQUIRED
  • arg - Type:any - Description:Argument to be called within function. - OPTIONAL

Sample:

FunctionQueue.push(function (callback,arg) {
    console.log("hello " + arg); //Should print 'hello mate'
    //you must call callback to continue queue
    callback();
},"mate!")

Remove all Object from queue !

Functions already started will not be canceled.

Sample:

FunctionQueue.removeAllObjects();

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

MIT

Something went wrong with that request. Please try again.