cron-es6

1.0.3 • Public • Published

cron-es6

NPM

Is just an ES6 (ECMAScript 2015) node cron wrapper around cron npm package.

Install

To install this package just run:

npm install cron-es6

Basic usage example

Here is an example of creating your cron job with cron-es6 package:

hello.cron.js file

const BaseCron = require('cron-es6');

module.exports = class Hello extends BaseCron {

    constructor() {
        super('Hello', '* * * * * *');
    }

    //override
    async onTick() {
        console.log('Hello from cron job.');
    }

    //override
    async onComplete() {
        console.log('Finished.');
    }

};

In some other .js file:

const Hello = require('./hello.cron');

let hello = new Hello();
hello.start();

Available functions

  • start - starts the cron job
  • stop - stops the cron job
  • async onTick - function which will be triggered on each tick
  • async onComplete - function which will be triggered when the job is stopped
  • isCronRunning - checks if the cron job is running
  • getCronInstance - will return you an instance of CronJob from wrapped cron npm package

Cron Ranges

  • Seconds: 0-59
  • Minutes: 0-59
  • Hours: 0-23
  • Day of Month: 1-31
  • Months: 0-11 (Jan-Dec)
  • Day of Week: 0-6 (Sun-Sat)

Contribution

Feel free to contribute by forking this repository, making changes, and submitting pull requests. For any questions or advice place an issue on this repository.

License

MIT

Package Sidebar

Install

npm i cron-es6

Weekly Downloads

14

Version

1.0.3

License

MIT

Unpacked Size

7.6 kB

Total Files

7

Last publish

Collaborators

  • nempet