croner 9.0.0-dev.1 → 9.0.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/croner.d.cts CHANGED
@@ -1,487 +1,365 @@
1
- declare module "helpers/minitz" {
2
- interface TimePoint {
3
- y: number;
4
- m: number;
5
- d: number;
6
- h: number;
7
- i: number;
8
- s: number;
9
- tz: string;
10
- }
11
- /**
12
- * Converts a date/time from a specific timezone to a normal date object using the system local time
13
- *
14
- * Shortcut for minitz.fromTZ(minitz.tp(...));
15
- *
16
- * @constructor
17
- *
18
- * @param {Number} y - 1970--
19
- * @param {Number} m - 1-12
20
- * @param {Number} d - 1-31
21
- * @param {Number} h - 0-24
22
- * @param {Number} i - 0-60 Minute
23
- * @param {Number} s - 0-60
24
- * @param {string} tz - Time zone in IANA database format 'Europe/Stockholm'
25
- * @param {boolean} [throwOnInvalid] - Default is to return the adjusted time if the call happens during a Daylight-Saving-Time switch.
26
- * E.g. Value "01:01:01" is returned if input time is 00:01:01 while one hour got actually
27
- * skipped, going from 23:59:59 to 01:00:00. Setting this flag makes the library throw an exception instead.
28
- * @returns {date} - Normal date object with correct UTC and system local time
29
- */
30
- function minitz(y: number, m: number, d: number, h: number, i: number, s: number, tz: string, throwOnInvalid?: boolean): Date;
31
- namespace minitz {
32
- var fromTZISO: (localTimeStr: string, tz: string, throwOnInvalid?: boolean) => Date;
33
- var fromTZ: (tp: TimePoint, throwOnInvalid?: boolean) => Date;
34
- var toTZ: (d: Date, tzStr: string) => {
35
- y: number;
36
- m: number;
37
- d: number;
38
- h: number;
39
- i: number;
40
- s: number;
41
- tz: string;
42
- };
43
- var tp: (y: number, m: number, d: number, h: number, i: number, s: number, tz: string) => {
44
- y: number;
45
- m: number;
46
- d: number;
47
- h: number;
48
- i: number;
49
- s: number;
50
- tz: string;
51
- };
52
- var minitz: typeof import("helpers/minitz").default;
53
- }
54
- export default minitz;
55
- export { minitz };
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type CatchCallbackFn = (e: unknown, job: Cron) => void;
4
+ export type ProtectCallbackFn = (job: Cron) => void;
5
+ export interface CronOptions {
6
+ name?: string;
7
+ paused?: boolean;
8
+ kill?: boolean;
9
+ catch?: boolean | CatchCallbackFn;
10
+ unref?: boolean;
11
+ maxRuns?: number;
12
+ interval?: number;
13
+ protect?: boolean | ProtectCallbackFn;
14
+ startAt?: string | Date | CronDate;
15
+ stopAt?: string | Date | CronDate;
16
+ timezone?: string;
17
+ utcOffset?: number;
18
+ legacyMode?: boolean;
19
+ context?: unknown;
56
20
  }
57
- declare module "options" {
58
- import { CronDate } from "date";
59
- import type { Cron } from "croner";
60
- type CatchCallbackFn = (e: unknown, job: Cron) => void;
61
- type ProtectCallbackFn = (job: Cron) => void;
62
- interface CronOptions {
63
- name?: string;
64
- paused?: boolean;
65
- kill?: boolean;
66
- catch?: boolean | CatchCallbackFn;
67
- unref?: boolean;
68
- maxRuns?: number;
69
- interval?: number;
70
- protect?: boolean | ProtectCallbackFn;
71
- startAt?: string | Date | CronDate;
72
- stopAt?: string | Date | CronDate;
73
- timezone?: string;
74
- utcOffset?: number;
75
- legacyMode?: boolean;
76
- context?: unknown;
77
- }
78
- function CronOptions(options?: CronOptions): CronOptions;
79
- export { CronOptions };
21
+ /**
22
+ * Create a CronPattern instance from pattern string ('* * * * * *')
23
+ * @constructor
24
+ * @param {string} pattern - Input pattern
25
+ * @param {string} timezone - Input timezone, used for '?'-substitution
26
+ */
27
+ export declare class CronPattern {
28
+ pattern: string;
29
+ timezone?: string;
30
+ second: number[];
31
+ minute: number[];
32
+ hour: number[];
33
+ day: number[];
34
+ month: number[];
35
+ dayOfWeek: number[];
36
+ lastDayOfMonth: boolean;
37
+ starDOM: boolean;
38
+ starDOW: boolean;
39
+ constructor(pattern: string, timezone?: string);
40
+ /**
41
+ * Parse current pattern, will throw on any type of failure
42
+ * @private
43
+ */
44
+ private parse;
45
+ /**
46
+ * Convert current part (seconds/minutes etc) to an array of 1 or 0 depending on if the part is about to trigger a run or not.
47
+ */
48
+ private partToArray;
49
+ /**
50
+ * After converting JAN-DEC, SUN-SAT only 0-9 * , / - are allowed, throw if anything else pops up
51
+ * @throws On error
52
+ */
53
+ private throwAtIllegalCharacters;
54
+ /**
55
+ * Nothing but a number left, handle that
56
+ *
57
+ * @param conf Current part, expected to be a number, as a string
58
+ * @param type One of "seconds", "minutes" etc
59
+ * @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
60
+ */
61
+ private handleNumber;
62
+ /**
63
+ * Set a specific value for a specific part of the CronPattern.
64
+ *
65
+ * @param part The specific part of the CronPattern, e.g., "second", "minute", etc.
66
+ * @param index The index to modify.
67
+ * @param value The value to set, typically 0 or 1, in case of "nth weekday" it will be the weekday number used for further processing
68
+ */
69
+ private setPart;
70
+ /**
71
+ * Take care of ranges with stepping (e.g. 3-23/5)
72
+ *
73
+ * @param conf Current part, expected to be a string like 3-23/5
74
+ * @param type One of "seconds", "minutes" etc
75
+ * @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
76
+ */
77
+ private handleRangeWithStepping;
78
+ private extractNth;
79
+ /**
80
+ * Take care of ranges (e.g. 1-20)
81
+ *
82
+ * @param conf - Current part, expected to be a string like 1-20, can contain L for last
83
+ * @param type - One of "seconds", "minutes" etc
84
+ * @param valueIndexOffset - -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
85
+ */
86
+ private handleRange;
87
+ /**
88
+ * Handle stepping (e.g. * / 14)
89
+ *
90
+ * @param conf Current part, expected to be a string like * /20 (without the space)
91
+ * @param type One of "seconds", "minutes" etc
92
+ */
93
+ private handleStepping;
94
+ /**
95
+ * Replace day name with day numbers
96
+ *
97
+ * @param conf Current part, expected to be a string that might contain sun,mon etc.
98
+ *
99
+ * @returns Conf with 0 instead of sun etc.
100
+ */
101
+ private replaceAlphaDays;
102
+ /**
103
+ * Replace month name with month numbers
104
+ *
105
+ * @param conf Current part, expected to be a string that might contain jan,feb etc.
106
+ *
107
+ * @returns conf with 0 instead of sun etc.
108
+ */
109
+ private replaceAlphaMonths;
110
+ /**
111
+ * Replace nicknames with actual cron patterns
112
+ *
113
+ * @param pattern Pattern, may contain nicknames, or not
114
+ *
115
+ * @returns Pattern, with cron expression insted of nicknames
116
+ */
117
+ private handleNicknames;
118
+ /**
119
+ * Handle the nth weekday of the month logic using hash sign (e.g. FRI#2 for the second Friday of the month)
120
+ *
121
+ * @param index Weekday, example: 5 for friday
122
+ * @param nthWeekday bitmask, 2 (0x00010) for 2nd friday, 31 (ANY_OCCURRENCE, 0b100000) for any day
123
+ */
124
+ private setNthWeekdayOfMonth;
80
125
  }
81
- declare module "pattern" {
82
- /**
83
- * Constants to represent different occurrences of a weekday in its month.
84
- * - `LAST_OCCURRENCE`: The last occurrence of a weekday.
85
- * - `ANY_OCCURRENCE`: Combines all individual weekday occurrence bitmasks, including the last.
86
- * - `OCCURRENCE_BITMASKS`: An array of bitmasks, with each index representing the respective occurrence of a weekday (0-indexed).
87
- */
88
- export const LAST_OCCURRENCE = 32;
89
- export const ANY_OCCURRENCE: number;
90
- export const OCCURRENCE_BITMASKS: number[];
91
- /**
92
- * Create a CronPattern instance from pattern string ('* * * * * *')
93
- * @constructor
94
- * @param {string} pattern - Input pattern
95
- * @param {string} timezone - Input timezone, used for '?'-substitution
96
- */
97
- class CronPattern {
98
- pattern: string;
99
- timezone?: string;
100
- second: number[];
101
- minute: number[];
102
- hour: number[];
103
- day: number[];
104
- month: number[];
105
- dayOfWeek: number[];
106
- lastDayOfMonth: boolean;
107
- starDOM: boolean;
108
- starDOW: boolean;
109
- constructor(pattern: string, timezone?: string);
110
- /**
111
- * Parse current pattern, will throw on any type of failure
112
- * @private
113
- */
114
- private parse;
115
- /**
116
- * Convert current part (seconds/minutes etc) to an array of 1 or 0 depending on if the part is about to trigger a run or not.
117
- */
118
- private partToArray;
119
- /**
120
- * After converting JAN-DEC, SUN-SAT only 0-9 * , / - are allowed, throw if anything else pops up
121
- * @throws On error
122
- */
123
- private throwAtIllegalCharacters;
124
- /**
125
- * Nothing but a number left, handle that
126
- *
127
- * @param conf Current part, expected to be a number, as a string
128
- * @param type One of "seconds", "minutes" etc
129
- * @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
130
- */
131
- private handleNumber;
132
- /**
133
- * Set a specific value for a specific part of the CronPattern.
134
- *
135
- * @param part The specific part of the CronPattern, e.g., "second", "minute", etc.
136
- * @param index The index to modify.
137
- * @param value The value to set, typically 0 or 1, in case of "nth weekday" it will be the weekday number used for further processing
138
- */
139
- private setPart;
140
- /**
141
- * Take care of ranges with stepping (e.g. 3-23/5)
142
- *
143
- * @param conf Current part, expected to be a string like 3-23/5
144
- * @param type One of "seconds", "minutes" etc
145
- * @param valueIndexOffset -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
146
- */
147
- private handleRangeWithStepping;
148
- private extractNth;
149
- /**
150
- * Take care of ranges (e.g. 1-20)
151
- *
152
- * @param conf - Current part, expected to be a string like 1-20, can contain L for last
153
- * @param type - One of "seconds", "minutes" etc
154
- * @param valueIndexOffset - -1 for day of month, and month, as they start at 1. 0 for seconds, hours, minutes
155
- */
156
- private handleRange;
157
- /**
158
- * Handle stepping (e.g. * / 14)
159
- *
160
- * @param conf Current part, expected to be a string like * /20 (without the space)
161
- * @param type One of "seconds", "minutes" etc
162
- */
163
- private handleStepping;
164
- /**
165
- * Replace day name with day numbers
166
- *
167
- * @param conf Current part, expected to be a string that might contain sun,mon etc.
168
- *
169
- * @returns Conf with 0 instead of sun etc.
170
- */
171
- private replaceAlphaDays;
172
- /**
173
- * Replace month name with month numbers
174
- *
175
- * @param conf Current part, expected to be a string that might contain jan,feb etc.
176
- *
177
- * @returns conf with 0 instead of sun etc.
178
- */
179
- private replaceAlphaMonths;
180
- /**
181
- * Replace nicknames with actual cron patterns
182
- *
183
- * @param pattern Pattern, may contain nicknames, or not
184
- *
185
- * @returns Pattern, with cron expression insted of nicknames
186
- */
187
- private handleNicknames;
188
- /**
189
- * Handle the nth weekday of the month logic using hash sign (e.g. FRI#2 for the second Friday of the month)
190
- *
191
- * @param index Weekday, example: 5 for friday
192
- * @param nthWeekday bitmask, 2 (0x00010) for 2nd friday, 31 (ANY_OCCURRENCE, 0b100000) for any day
193
- */
194
- private setNthWeekdayOfMonth;
195
- }
196
- export { CronPattern };
126
+ /**
127
+ * Converts date to CronDate
128
+ *
129
+ * @param d Input date, if using string representation ISO 8001 (2015-11-24T19:40:00) local timezone is expected
130
+ * @param tz String representation of target timezone in Europe/Stockholm format, or a number representing offset in minutes.
131
+ */
132
+ export declare class CronDate {
133
+ tz: string | number | undefined;
134
+ /**
135
+ * Current milliseconds
136
+ * @type {number}
137
+ */
138
+ ms: number;
139
+ /**
140
+ * Current second (0-59), in local time or target timezone specified by `this.tz`
141
+ * @type {number}
142
+ */
143
+ second: number;
144
+ /**
145
+ * Current minute (0-59), in local time or target timezone specified by `this.tz`
146
+ * @type {number}
147
+ */
148
+ minute: number;
149
+ /**
150
+ * Current hour (0-23), in local time or target timezone specified by `this.tz`
151
+ * @type {number}
152
+ */
153
+ hour: number;
154
+ /**
155
+ * Current day (1-31), in local time or target timezone specified by `this.tz`
156
+ * @type {number}
157
+ */
158
+ day: number;
159
+ /**
160
+ * Current month (1-12), in local time or target timezone specified by `this.tz`
161
+ * @type {number}
162
+ */
163
+ month: number;
164
+ /**
165
+ * Current full year, in local time or target timezone specified by `this.tz`
166
+ */
167
+ year: number;
168
+ constructor(d?: CronDate | Date | string | null, tz?: string | number);
169
+ /**
170
+ * Check if the given date is the nth occurrence of a weekday in its month.
171
+ *
172
+ * @param year The year.
173
+ * @param month The month (0 for January, 11 for December).
174
+ * @param day The day of the month.
175
+ * @param nth The nth occurrence (bitmask).
176
+ *
177
+ * @return True if the date is the nth occurrence of its weekday, false otherwise.
178
+ */
179
+ private isNthWeekdayOfMonth;
180
+ /**
181
+ * Sets internals using a Date
182
+ */
183
+ private fromDate;
184
+ /**
185
+ * Sets internals by deep copying another CronDate
186
+ *
187
+ * @param {CronDate} d - Input date
188
+ */
189
+ private fromCronDate;
190
+ /**
191
+ * Reset internal parameters (seconds, minutes, hours) if any of them have exceeded (or could have exceeded) their normal ranges
192
+ *
193
+ * Will alway return true on february 29th, as that is a date that _could_ be out of bounds
194
+ */
195
+ private apply;
196
+ /**
197
+ * Sets internals by parsing a string
198
+ */
199
+ private fromString;
200
+ /**
201
+ * Find next match of current part
202
+ */
203
+ private findNext;
204
+ /**
205
+ * Increment to next run time recursively
206
+ *
207
+ * This function is currently capped at year 3000. Do you have a reason to go further? Open an issue on GitHub!
208
+ *
209
+ * @param pattern The pattern used to increment current state
210
+ * @param options Cron options used for incrementing
211
+ * @param doing Which part to increment, 0 represent first item of RecursionSteps-array etc.
212
+ * @return Returns itthis for chaining, or null if increment wasnt possible
213
+ */
214
+ private recurse;
215
+ /**
216
+ * Increment to next run time
217
+ *
218
+ * @param pattern The pattern used to increment current state
219
+ * @param options Cron options used for incrementing
220
+ * @param hasPreviousRun If this run should adhere to minimum interval
221
+ * @return Returns itthis for chaining, or null if increment wasnt possible
222
+ */
223
+ increment(pattern: CronPattern, options: CronOptions, hasPreviousRun: boolean): CronDate | null;
224
+ /**
225
+ * Convert current state back to a javascript Date()
226
+ *
227
+ * @param internal If this is an internal call
228
+ */
229
+ getDate(internal?: boolean): Date;
230
+ /**
231
+ * Convert current state back to a javascript Date() and return UTC milliseconds
232
+ */
233
+ getTime(): number;
197
234
  }
198
- declare module "date" {
199
- import type { CronOptions as CronOptions } from "options";
200
- import { type CronPattern } from "pattern";
201
- /**
202
- * Converts date to CronDate
203
- *
204
- * @param d Input date, if using string representation ISO 8001 (2015-11-24T19:40:00) local timezone is expected
205
- * @param tz String representation of target timezone in Europe/Stockholm format, or a number representing offset in minutes.
206
- */
207
- class CronDate {
208
- tz: string | number | undefined;
209
- /**
210
- * Current milliseconds
211
- * @type {number}
212
- */
213
- ms: number;
214
- /**
215
- * Current second (0-59), in local time or target timezone specified by `this.tz`
216
- * @type {number}
217
- */
218
- second: number;
219
- /**
220
- * Current minute (0-59), in local time or target timezone specified by `this.tz`
221
- * @type {number}
222
- */
223
- minute: number;
224
- /**
225
- * Current hour (0-23), in local time or target timezone specified by `this.tz`
226
- * @type {number}
227
- */
228
- hour: number;
229
- /**
230
- * Current day (1-31), in local time or target timezone specified by `this.tz`
231
- * @type {number}
232
- */
233
- day: number;
234
- /**
235
- * Current month (1-12), in local time or target timezone specified by `this.tz`
236
- * @type {number}
237
- */
238
- month: number;
239
- /**
240
- * Current full year, in local time or target timezone specified by `this.tz`
241
- */
242
- year: number;
243
- constructor(d?: CronDate | Date | string, tz?: string | number);
244
- /**
245
- * Check if the given date is the nth occurrence of a weekday in its month.
246
- *
247
- * @param year The year.
248
- * @param month The month (0 for January, 11 for December).
249
- * @param day The day of the month.
250
- * @param nth The nth occurrence (bitmask).
251
- *
252
- * @return True if the date is the nth occurrence of its weekday, false otherwise.
253
- */
254
- private isNthWeekdayOfMonth;
255
- /**
256
- * Sets internals using a Date
257
- */
258
- private fromDate;
259
- /**
260
- * Sets internals by deep copying another CronDate
261
- *
262
- * @param {CronDate} d - Input date
263
- */
264
- private fromCronDate;
265
- /**
266
- * Reset internal parameters (seconds, minutes, hours) if any of them have exceeded (or could have exceeded) their normal ranges
267
- *
268
- * Will alway return true on february 29th, as that is a date that _could_ be out of bounds
269
- */
270
- private apply;
271
- /**
272
- * Sets internals by parsing a string
273
- */
274
- private fromString;
275
- /**
276
- * Find next match of current part
277
- */
278
- private findNext;
279
- /**
280
- * Increment to next run time recursively
281
- *
282
- * This function is currently capped at year 3000. Do you have a reason to go further? Open an issue on GitHub!
283
- *
284
- * @param pattern The pattern used to increment current state
285
- * @param options Cron options used for incrementing
286
- * @param doing Which part to increment, 0 represent first item of RecursionSteps-array etc.
287
- * @return Returns itthis for chaining, or null if increment wasnt possible
288
- */
289
- private recurse;
290
- /**
291
- * Increment to next run time
292
- *
293
- * @param pattern The pattern used to increment current state
294
- * @param options Cron options used for incrementing
295
- * @param hasPreviousRun If this run should adhere to minimum interval
296
- * @return Returns itthis for chaining, or null if increment wasnt possible
297
- */
298
- increment(pattern: CronPattern, options: CronOptions, hasPreviousRun: boolean): CronDate | null;
299
- /**
300
- * Convert current state back to a javascript Date()
301
- *
302
- * @param internal If this is an internal call
303
- */
304
- getDate(internal?: boolean): Date;
305
- /**
306
- * Convert current state back to a javascript Date() and return UTC milliseconds
307
- */
308
- getTime(): number;
309
- }
310
- export { CronDate };
311
- }
312
- declare module "utils" {
313
- /**
314
- * Helper function to check if a variable is a function
315
- * @private
316
- *
317
- * @param {?} [v] - Variable to check
318
- * @returns {boolean}
319
- */
320
- function isFunction(v: unknown): boolean;
321
- /**
322
- * Helper function to unref a timer in both Deno and Node
323
- * @private
324
- * @param {unknown} [timer] - Timer to unref
325
- */
326
- function unrefTimer(timer: NodeJS.Timeout | number): void;
327
- export { isFunction, unrefTimer };
328
- }
329
- declare module "croner" {
330
- import { CronDate } from "date";
331
- import { CronPattern } from "pattern";
332
- import { CronOptions } from "options";
333
- /**
334
- * An array containing all named cron jobs.
335
- */
336
- const scheduledJobs: Cron[];
337
- /**
338
- * Encapsulate all internal states in the Cron instance.
339
- * Duplicate all options that can change to internal states, for example maxRuns and paused.
340
- */
341
- type CronState = {
342
- kill: boolean;
343
- blocking: boolean;
344
- /**
345
- * Start time of previous trigger, updated after each trigger
346
- *
347
- * Stored to use as the actual previous run, even while a new trigger
348
- * is started. Used by the public funtion `.previousRun()`
349
- */
350
- previousRun: CronDate | undefined;
351
- /**
352
- * Start time of current trigger, this is updated just before triggering
353
- *
354
- * This is used internally as "previous run", as we mostly want to know
355
- * when the previous run _started_
356
- */
357
- currentRun: CronDate | undefined;
358
- once: CronDate | undefined;
359
- currentTimeout: NodeJS.Timer | number | undefined;
360
- maxRuns: number | undefined;
361
- paused: boolean | undefined;
362
- pattern: CronPattern;
363
- };
364
- /**
365
- * Cron entrypoint
366
- *
367
- * @constructor
368
- * @param pattern - Input pattern, input date, or input ISO 8601 time string
369
- * @param [fnOrOptions1] - Options or function to be run each iteration of pattern
370
- * @param [fnOrOptions2] - Options or function to be run each iteration of pattern
371
- */
372
- class Cron {
373
- name: string | undefined;
374
- options: CronOptions;
375
- _states: CronState;
376
- fn?: Function;
377
- constructor(pattern: string | Date, fnOrOptions1?: CronOptions | Function, fnOrOptions2?: CronOptions | Function);
378
- /**
379
- * Find next runtime, based on supplied date. Strips milliseconds.
380
- *
381
- * @param prev - Date to start from
382
- * @returns Next run time
383
- */
384
- nextRun(prev?: CronDate | Date | string): Date | null;
385
- /**
386
- * Find next n runs, based on supplied date. Strips milliseconds.
387
- *
388
- * @param n - Number of runs to enumerate
389
- * @param previous - Date to start from
390
- * @returns - Next n run times
391
- */
392
- nextRuns(n: number, previous: Date | string): Date[];
393
- /**
394
- * Return the original pattern, if there was one
395
- *
396
- * @returns Original pattern
397
- */
398
- getPattern(): string | undefined;
399
- /**
400
- * Indicates whether or not the cron job is scheduled and running, e.g. awaiting next trigger
401
- *
402
- * @returns Running or not
403
- */
404
- isRunning(): boolean;
405
- /**
406
- * Indicates whether or not the cron job is permanently stopped
407
- *
408
- * @returns Running or not
409
- */
410
- isStopped(): boolean;
411
- /**
412
- * Indicates whether or not the cron job is currently working
413
- *
414
- * @returns Running or not
415
- */
416
- isBusy(): boolean;
417
- /**
418
- * Return current/previous run start time
419
- *
420
- * @returns Current (if running) or previous run time
421
- */
422
- currentRun(): Date | null;
423
- /**
424
- * Return previous run start time
425
- *
426
- * @returns Previous run time
427
- */
428
- previousRun(): Date | null;
429
- /**
430
- * Returns number of milliseconds to next run
431
- *
432
- * @param prev Starting date, defaults to now - minimum interval
433
- */
434
- msToNext(prev?: CronDate | Date | string): number | null;
435
- /**
436
- * Stop execution
437
- *
438
- * Running this will forcefully stop the job, and prevent furter exection. `.resume()` will not work after stopping.
439
- * It will also be removed from the scheduledJobs array if it were named.
440
- */
441
- stop(): void;
442
- /**
443
- * Pause execution
444
- *
445
- * @returns Wether pause was successful
446
- */
447
- pause(): boolean;
448
- /**
449
- * Resume execution
450
- *
451
- * @returns Wether resume was successful
452
- */
453
- resume(): boolean;
454
- /**
455
- * Schedule a new job
456
- *
457
- * @param func - Function to be run each iteration of pattern
458
- */
459
- schedule(func?: Function): Cron;
460
- /**
461
- * Internal function to trigger a run, used by both scheduled and manual trigger
462
- */
463
- private _trigger;
464
- /**
465
- * Trigger a run manually
466
- */
467
- trigger(): Promise<void>;
468
- /**
469
- * Called when it's time to trigger.
470
- * Checks if all conditions are currently met,
471
- * then instantly triggers the scheduled function.
472
- */
473
- private _checkTrigger;
474
- /**
475
- * Internal version of next. Cron needs millseconds internally, hence _next.
476
- */
477
- private _next;
478
- /**
479
- * Calculate the previous run if no previous run is supplied, but startAt and interval are set.
480
- * This calculation is only necessary if the startAt time is before the current time.
481
- * Should only be called from the _next function.
482
- */
483
- private _calculatePreviousRun;
484
- }
485
- export default Cron;
486
- export { Cron, CronOptions, CronDate, CronPattern, scheduledJobs };
235
+ /**
236
+ * An array containing all named cron jobs.
237
+ */
238
+ export declare const scheduledJobs: Cron[];
239
+ /**
240
+ * Cron entrypoint
241
+ *
242
+ * @constructor
243
+ * @param pattern - Input pattern, input date, or input ISO 8601 time string
244
+ * @param [fnOrOptions1] - Options or function to be run each iteration of pattern
245
+ * @param [fnOrOptions2] - Options or function to be run each iteration of pattern
246
+ */
247
+ export declare class Cron {
248
+ name: string | undefined;
249
+ options: CronOptions;
250
+ private _states;
251
+ private fn?;
252
+ constructor(pattern: string | Date, fnOrOptions1?: CronOptions | Function, fnOrOptions2?: CronOptions | Function);
253
+ /**
254
+ * Find next runtime, based on supplied date. Strips milliseconds.
255
+ *
256
+ * @param prev - Date to start from
257
+ * @returns Next run time
258
+ */
259
+ nextRun(prev?: CronDate | Date | string | null): Date | null;
260
+ /**
261
+ * Find next n runs, based on supplied date. Strips milliseconds.
262
+ *
263
+ * @param n - Number of runs to enumerate
264
+ * @param previous - Date to start from
265
+ * @returns - Next n run times
266
+ */
267
+ nextRuns(n: number, previous?: Date | string): Date[];
268
+ /**
269
+ * Return the original pattern, if there was one
270
+ *
271
+ * @returns Original pattern
272
+ */
273
+ getPattern(): string | undefined;
274
+ /**
275
+ * Indicates whether or not the cron job is scheduled and running, e.g. awaiting next trigger
276
+ *
277
+ * @returns Running or not
278
+ */
279
+ isRunning(): boolean;
280
+ /**
281
+ * Indicates whether or not the cron job is permanently stopped
282
+ *
283
+ * @returns Running or not
284
+ */
285
+ isStopped(): boolean;
286
+ /**
287
+ * Indicates whether or not the cron job is currently working
288
+ *
289
+ * @returns Running or not
290
+ */
291
+ isBusy(): boolean;
292
+ /**
293
+ * Return current/previous run start time
294
+ *
295
+ * @returns Current (if running) or previous run time
296
+ */
297
+ currentRun(): Date | null;
298
+ /**
299
+ * Return previous run start time
300
+ *
301
+ * @returns Previous run time
302
+ */
303
+ previousRun(): Date | null;
304
+ /**
305
+ * Returns number of milliseconds to next run
306
+ *
307
+ * @param prev Starting date, defaults to now - minimum interval
308
+ */
309
+ msToNext(prev?: CronDate | Date | string): number | null;
310
+ /**
311
+ * Stop execution
312
+ *
313
+ * Running this will forcefully stop the job, and prevent furter exection. `.resume()` will not work after stopping.
314
+ * It will also be removed from the scheduledJobs array if it were named.
315
+ */
316
+ stop(): void;
317
+ /**
318
+ * Pause execution
319
+ *
320
+ * @returns Wether pause was successful
321
+ */
322
+ pause(): boolean;
323
+ /**
324
+ * Resume execution
325
+ *
326
+ * @returns Wether resume was successful
327
+ */
328
+ resume(): boolean;
329
+ /**
330
+ * Schedule a new job
331
+ *
332
+ * @param func - Function to be run each iteration of pattern
333
+ */
334
+ schedule(func?: Function): Cron;
335
+ /**
336
+ * Internal function to trigger a run, used by both scheduled and manual trigger
337
+ */
338
+ private _trigger;
339
+ /**
340
+ * Trigger a run manually
341
+ */
342
+ trigger(): Promise<void>;
343
+ /**
344
+ * Returns number of runs left, undefined = unlimited
345
+ */
346
+ runsLeft(): number | undefined;
347
+ /**
348
+ * Called when it's time to trigger.
349
+ * Checks if all conditions are currently met,
350
+ * then instantly triggers the scheduled function.
351
+ */
352
+ private _checkTrigger;
353
+ /**
354
+ * Internal version of next. Cron needs millseconds internally, hence _next.
355
+ */
356
+ private _next;
357
+ /**
358
+ * Calculate the previous run if no previous run is supplied, but startAt and interval are set.
359
+ * This calculation is only necessary if the startAt time is before the current time.
360
+ * Should only be called from the _next function.
361
+ */
362
+ private _calculatePreviousRun;
487
363
  }
364
+
365
+ export {};