Skip to content

Helper package that allows you to subscribe to time events based on a standard CRON expression or a timeframe value.

Notifications You must be signed in to change notification settings

Alex-Werner/kronos-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kronos-JS

NPM Version Release Date

Kronos is a simple helper package that allows you to subscribe to time events based on a standard CRON expression or a timeframe value.

Typically, you can use it to trigger a function every 5 minutes, every hour, every day, etc.

Installation

npm install kronos-js

Usage

const Kronos = require('kronos-js');
const instance = new Kronos();

const callback = (event)=>{
    console.log(event);
}

instance.subscribe('1s');
instance.on('TIME/1s', callback);

instance.subscribe('1m');
instance.on('TIME/1m', callback);

// WIll catch all subscriptions
instance.on('SUBSCRIPTIONS', (data)=>{
    console.log('SUBSCRIPTION:', data);
});
instance.on('TIME/*', callback);

Event format : TIME/${timeframe}
Timeframe format : 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 3d, 1w, 1M Catch-all : TIME/*

About

Helper package that allows you to subscribe to time events based on a standard CRON expression or a timeframe value.

Resources

Stars

Watchers

Forks

Packages

No packages published