habitants-async-queue
v0.0.3
Published
[](https://travis-ci.org/habitants/async-queue)
Readme
Async Queue 
Manages methods that need to be run in sequence and at a particular rate. It will never return perfect values, because computation takes time, but it should be pretty close.
Example
var asyncQueue = require('habitants-async-queue');
var newUnit = new Unit('adsf');
var startTime = new Date();
newUnit.move(startTime);
newUnit.build(startTime);
function Unit (id) {
this.id = id;
this.actionQueue = [];
this.move = asyncQueue(function (startTime) {
var processTime = new Date() - startTime;
// should be 1000 (give or take)
}, function () { return 1000; });
this.build = asyncQueue(function (startTime) {
var processTime = new Date() - startTime;
// shoudl be 6000 (give or take)
}, function () { return 5000; });
}Usage
var asyncQueue = require('habitants-async-queue');asyncQueue(actionMethod, costMethod)
actionMethod is the function to be called.
costMethod is a function that returns how long to wait before calling actionMethod.
Installation
npm install habitants-async-queueTests
npm test