function-queue
v0.0.12
Published
Simple queue to execute any function on FIFO order.
Downloads
174
Readme
FunctionQueue
Simple queue to execute any function on FIFO order.
Requirements
Installation
No installation is needed.
Usage
var FunctionQueue = require("./../src/function-queue.js")();
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("./../src/function-queue.js")();
Add Function into queue
Parameters:
- function - **Type:**function - **Description:**Function to be added on queue. - REQUIRED
Sample:
FunctionQueue.push(function (callback) {
console.log("dedeOut");
//you must call callback to continue queue
callback();
})
Remove all Object from queue !
Functions already started will not be canceled.
Sample:
FunctionQueue.removeAllObjects();
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request