Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

built-in typescript support #368

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}