UNPKG

1.6 kBTypeScriptView Raw
1// Type definitions for node-cron 3.0
2// Project: https://github.com/node-cron/node-cron, https://github.com/merencia/node-cron
3// Definitions by: morsic <https://github.com/maximelkin>,
4// burtek <https://github.com/burtek>,
5// Richard Honor <https://github.com/RMHonor>
6// Ata Berk YILMAZ <https://github.com/ataberkylmz>
7// Alex Seidmann <https://github.com/aseidma>
8// Pedro Américo <https://github.com/ghostebony>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10import { EventEmitter } from 'events';
11
12export function schedule(cronExpression: string, func: ((now: Date | "manual" | "init") => void) | string, options?: ScheduleOptions): ScheduledTask;
13
14export function validate(cronExpression: string): boolean;
15
16export function getTasks(): Map<string, ScheduledTask>;
17
18export interface ScheduledTask extends EventEmitter {
19 now: (now?: Date) => void;
20 start: () => void;
21 stop: () => void;
22}
23
24export interface ScheduleOptions {
25 /**
26 * A boolean to set if the created task is scheduled.
27 *
28 * Defaults to `true`
29 */
30 scheduled?: boolean | undefined;
31 /**
32 * The timezone that is used for job scheduling
33 */
34 timezone?: string;
35 /**
36 * Specifies whether to recover missed executions instead of skipping them.
37 *
38 * Defaults to `false`
39 */
40 recoverMissedExecutions?: boolean;
41 /**
42 * The schedule name
43 */
44 name?: string;
45 /**
46 * Execute task immediately after creation
47 */
48 runOnInit?: boolean;
49}