MCPcopy Index your code
hub / github.com/node-cron/node-cron / ScheduledTask

Interface ScheduledTask

src/tasks/scheduled-task.ts:135–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133 * Represents a scheduled task that can be managed and executed.
134 */
135export interface ScheduledTask {
136 id: string,
137 name?: string,
138
139 start(): void | Promise<void>;
140 stop(): void | Promise<void>;
141 getStatus(): string;
142 destroy(): void | Promise<void>;
143 execute(): Promise<any>;
144 getNextRun(): Date | null;
145
146 /** The next `count` instants this task's expression matches, from now. */
147 getNextRuns(count: number): Date[];
148 /** Whether the given date matches this task's expression. */
149 match(date: Date): boolean;
150 /** Milliseconds until the next run, or `null` when the task is stopped. */
151 msToNext(): number | null;
152 /** Whether an execution is currently in progress. */
153 isBusy(): boolean;
154 /** Remaining executions when `maxExecutions` is set, otherwise `undefined`. */
155 runsLeft(): number | undefined;
156 /** The original cron expression. */
157 getPattern(): string;
158 /**
159 * Information about the last actual execution, or `null` if the task has not
160 * run yet. `date` reflects when the execution really ran, not when a tick was
161 * checked.
162 */
163 lastRun(): LastRun | null;
164
165 on(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void
166 off(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void
167 once(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void
168}

Callers 69

scheduleFunction · 0.65
runner.test.tsFile · 0.65
startMethod · 0.65
daemon.test.tsFile · 0.65
node-cron.test.tsFile · 0.65
runner.test.tsFile · 0.65
onErrorFunction · 0.65
onFinishedFunction · 0.65

Implementers 2

InlineScheduledTasksrc/tasks/inline-scheduled-task.ts
BackgroundScheduledTasksrc/tasks/background-scheduled-task/ba

Calls

no outgoing calls

Tested by

no test coverage detected