https://github.com/pixtron/node-timer
EventEmitter emitting `tick` based on a given cron expression
https://github.com/pixtron/node-timer
Last synced: 5 months ago
JSON representation
EventEmitter emitting `tick` based on a given cron expression
- Host: GitHub
- URL: https://github.com/pixtron/node-timer
- Owner: pixtron
- License: mit
- Created: 2019-10-20T11:24:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-04T23:33:20.000Z (almost 3 years ago)
- Last Synced: 2024-10-16T03:24:23.012Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @pxtrn/timer
Emits `tick` based on a cron expression.
See [`cron-parser`](https://www.npmjs.com/package/cron-parser#supported-format)
for supported formats.
## Installation
`npm install --save @pxtrn/timer`
## Usage
```js
const Timer = require('@pxtrn/timer');
const timer = new Timer('00 * * * * *', {delay: 200});
timer.on('tick', () => {
console.log('Tick', new Date())
});
```
### Class: `Timer`
- `expression` {String} Cron expression. See `[cron-parser](https://www.npmjs.com/package/cron-parser#supported-format)`
- `options` {Object} Optional
- `delay`: {Integer} Delay in milliseconds. Default 0