Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nemanjapetrovic/cron-es6
ES6 (ECMAScript 2015) node cron wrapper around https://www.npmjs.com/package/cron npm package.
https://github.com/nemanjapetrovic/cron-es6
cron cron-es6 es6-javascript job node-cron node-cron-wrapper scheduler
Last synced: about 5 hours ago
JSON representation
ES6 (ECMAScript 2015) node cron wrapper around https://www.npmjs.com/package/cron npm package.
- Host: GitHub
- URL: https://github.com/nemanjapetrovic/cron-es6
- Owner: nemanjapetrovic
- License: mit
- Created: 2018-10-24T21:02:35.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-07T09:53:52.000Z (4 months ago)
- Last Synced: 2025-01-10T11:33:36.317Z (9 days ago)
- Topics: cron, cron-es6, es6-javascript, job, node-cron, node-cron-wrapper, scheduler
- Language: JavaScript
- Size: 53.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cron-es6
[![NPM](https://nodei.co/npm/cron-es6.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/cron-es6/)
Is just an ES6 (ECMAScript 2015) node cron wrapper around *[cron](https://www.npmjs.com/package/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](https://www.npmjs.com/package/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](CONTRIBUTING)
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](LICENSE)