Skip to content

Commit

Permalink
built-in typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperchupuDev committed Aug 16, 2022
1 parent a0be3f4 commit ddd5c7c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -6,6 +6,7 @@
"license": "ISC",
"homepage": "https://github.com/merencia/node-cron",
"main": "src/node-cron.js",
"types": "src/index.d.ts",
"scripts": {
"test": "nyc --reporter=html --reporter=text mocha --recursive",
"lint": "./node_modules/.bin/eslint ./src ./test",
Expand Down
37 changes: 37 additions & 0 deletions src/index.d.ts
@@ -0,0 +1,37 @@
// Definitions by: morsic <https://github.com/maximelkin>,
// burtek <https://github.com/burtek>,
// Richard Honor <https://github.com/RMHonor>
// Ata Berk YILMAZ <https://github.com/ataberkylmz>
// Alex Seidmann <https://github.com/aseidma>

import EventEmitter from 'events';

export function schedule(cronExpression: string, func: (now: Date) => void, options?: ScheduleOptions): ScheduledTask;

export function validate(cronExpression: string): boolean;

export function getTasks(): Map<string, ScheduledTask>;

export interface ScheduledTask extends EventEmitter {
start: () => this;
stop: () => this;
}

export interface ScheduleOptions {
/**
* A boolean to set if the created task is scheduled.
*
* Defaults to `true`
*/
scheduled?: boolean | undefined;
/**
* The timezone that is used for job scheduling
*/
timezone?: string;
/**
* Specifies whether to recover missed executions instead of skipping them.
*
* Defaults to `false`
*/
recoverMissedExecutions?: boolean;
}

0 comments on commit ddd5c7c

Please sign in to comment.