Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chron

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chron

Task scheduler

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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)
}

Keywords

FAQs

Package last updated on 17 Jan 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc