chr

chron

NodeJS task scheduler

Showing:

Popularity

Downloads/wk

4

GitHub Stars

1

Maintenance

Last Commit

4yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Chron

NodeJS task scheduler.

Install

npm install chron

Usage

var chron = new require("chron")();

chron.add(10, doSomething); // called every 10 seconds
chron.add(1.5, doSomething); // called every 1.5 seconds

function doSomething() {
    console.log("doing..");
}

The advantage of the scheduler is it only has one timer, even if you have hundreds of tasks. It calculates when the next task needs to run and schedules a timer.

API

  • chron.add(period, task)
  • chron.remove(task)
  • chron.clear()
  • chron.pause()
  • chron.resume()

A task is a function that receives a parameter that you can use to control the task execution (the next calls).

function doSomething($) {
    $.pause();   // will stop executing, you need to store
                 // a reference to $ to be able to resume
    $.resume();  // resume the previsouly paused task
    $.remove();  // completely remove the task - equal to chron.remove(task)
}

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial