
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
Time based event loop process queue
Install the module with: npm install compulsive
Wait ms, execute callback.
Loop ms, execute callback.
Repeat count times, every ms, execute callback.
Queue tasks.
// list
[
{
wait: ms,
task: function() {}
}
...
]
var compulsive = require("compulsive");
compulsive.wait( 10, function() {
// Will execute in 10ms
// ... doesn't use setTimeout.
});
compulsive.loop( 50, function( control ) {
// Will execute every 50ms
// ... doesn't use setTimeout or setInterval.
// The loop can be stopped via:
control.stop();
});
compulsive.repeat( 5, 100, function( control ) {
// Will execute 5 times, every 100ms
// ... doesn't use setTimeout or setInterval.
// The repeater loop can be stopped via:
control.stop();
});
compulsive.queue([
{
wait: 100,
task: function() {
// 100 from call to execution
}
},
{
wait: 200,
task: function() {
// 100 + 200 = 300ms from call to execution
}
}
]);
Add compulsive api to your constructor's prototype:
var compulsive = require("compulsive"),
priv = new require("es6-collections").WeakMap();
function Nodebot() {
//... various nodebot constructor tasks
this.servos = {
right: new Servo(9),
left: new Servo(10)
};
priv.set( this, {
step: null
});
}
// Exposure grants the end dev control
// over stepping positions (0-180˚)
Nodebot.STEPS = {
// Step: [ R, L ]
right: { right: 120, left: 60 },
left: { right: 60, left: 120 }
};
// Augment the Nodebot prototype
// with compulsive APIs
[ "wait", "loop", "queue" ].forEach(function( api ) {
Nodebot.prototype[ api ] = compulsive[ api ];
});
Nodebot.prototype.step = function() {
var p, next, last, degrees;
p = priv.get(this);
last = p.step;
next = last === "right" ? "left" : "right";
degrees = Nodebot.STEPS[ next ];
Object.keys( this.servos ).forEach(function( servo ) {
servo.move( degrees[ servo ] );
});
};
Nodebot.prototype.walk = function() {
this.loop( 1000, this.step.bind(this) );
};
module.exports = Nodebot;
var Nodebot = require("nodebot"), ,
bot = new Nodebot();
bot.walk();
All contributions must adhere to the the Idiomatic.js Style Guide, by maintaining the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Copyright (c) 2012 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license.
FAQs
Time based event loop process queue
The npm package compulsive receives a total of 35 weekly downloads. As such, compulsive popularity was classified as not popular.
We found that compulsive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.