compulsive

Time based event loop process queue

compulsive

Time based process

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,
    taskfunction() {}
  }
  ...
]
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,
    taskfunction() {
      // 100 from call to execution 
    }
  },
  {
    wait: 200,
    taskfunction() {
      // 100 + 200 = 300ms from call to execution 
    }
  }
]);
 
 

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.