UNPKG

2.19 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/node-cron`
3
4# Summary
5This package contains type definitions for node-cron (https://github.com/node-cron/node-cron).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-cron.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-cron/index.d.ts)
10````ts
11import { EventEmitter } from "events";
12
13/**
14 * Creates a new task to execute the given function when the cron expression ticks.
15 * @param cronExpression
16 * @param func
17 * @param options
18 */
19export function schedule(
20 cronExpression: string,
21 func: ((now: Date | "manual" | "init") => void) | string,
22 options?: ScheduleOptions,
23): ScheduledTask;
24
25/**
26 * To validate whether the expression is a cron expression or not
27 * @param cronExpression
28 */
29export function validate(cronExpression: string): boolean;
30
31/**
32 * Get the list of tasks created using the `schedule` function
33 */
34export function getTasks(): Map<string, ScheduledTask>;
35
36export interface ScheduledTask extends EventEmitter {
37 now: (now?: Date) => void;
38 start: () => void;
39 stop: () => void;
40}
41
42export interface ScheduleOptions {
43 /**
44 * A boolean to set if the created task is scheduled.
45 *
46 * Defaults to `true`
47 */
48 scheduled?: boolean | undefined;
49 /**
50 * The timezone that is used for job scheduling
51 */
52 timezone?: string;
53 /**
54 * Specifies whether to recover missed executions instead of skipping them.
55 *
56 * Defaults to `false`
57 */
58 recoverMissedExecutions?: boolean;
59 /**
60 * The schedule name
61 */
62 name?: string;
63 /**
64 * Execute task immediately after creation
65 */
66 runOnInit?: boolean;
67}
68
69````
70
71### Additional Details
72 * Last updated: Tue, 07 Nov 2023 20:08:00 GMT
73 * Dependencies: none
74
75# Credits
76These definitions were written 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), and [Pedro Américo](https://github.com/ghostebony).
77
\No newline at end of file