Wondering what’s next for npm?Check out our public roadmap! »

timebot

0.0.2 • Public • Published

timebot

Tiny JS utility for managing multiple timeouts and intervals. Timebot provides a centralized and organized way of managing timed asynchronous functions. Also, since it will only run one interval on the system, it can be a lot more efficient than running separate intervals.

  1. Allows pausing and resuming of queued timeouts
  2. Use a tag on timeouts to isolate and perform actions on only groups of timeouts
  3. Use it in the browser and with node.js
 
//to set an ever looping timeout (interval)
timebot.set({period:400,loop:true},function(i){
  console.log('looped ' + i + ' times');
});
 
//to set a timeout to execute 3 times
timebot.set({period:1200,loop:3},function(i){
  console.log('looped ' + i + ' times');
});
 
//create a timeout with a tag (for organization)
timebot.set({tag:'tag1',period:1000,loop:true},function(i){
  console.log('looped tag1 ' + i + ' times');
});
 
//pause all timeouts
timebot.pause();
 
//resume timeouts
timebot.resume();
 
//only pause timeouts that are tagged 'tag1' - pause, resume, and clear can all take a tag
timebot.pause('tag1');
 
//clear all timeouts
timebot.clear();
 

Install

npm i timebot

DownloadsWeekly Downloads

4

Version

0.0.2

License

ISC

Last publish

Collaborators

  • avatar