UNPKG

2.35 kBTypeScriptView Raw
1export = CronParser
2
3declare class CronDate {
4 addYear(): void
5 addMonth(): void
6 addDay(): void
7 addHour(): void
8 addMinute(): void
9 addSecond(): void
10
11 subtractYear(): void
12 subtractMonth(): void
13 subtractDay(): void
14 subtractHour(): void
15 subtractMinute(): void
16 subtractSecond(): void
17
18 getDate(): number
19 getFullYear(): number
20 getDay(): number
21 getMonth(): number
22 getHours(): number
23 getMinutes(): number
24 getSeconds(): number
25 getMilliseconds(): number
26 getTime(): number
27 getUTCDate(): number
28 getUTCFullYear(): number
29 getUTCDay(): number
30 getUTCMonth(): number
31 getUTCHours(): number
32 getUTCMinutes(): number
33 getUTCSeconds(): number
34
35 toISOString(): string
36 toJSON(): string
37
38 setDate(d: number): void
39 setFullYear(y: number): void
40 setDay(d: number): void
41 setMonth(m: number): void
42 setHours(h: number): void
43 setMinutes(m: number): void
44 setSeconds(s: number): void
45 setMilliseconds(s: number): void
46
47 getTime(): number
48 toString(): string
49 toDate(): Date
50}
51
52interface ParserOptions {
53 currentDate?: string | number | Date
54 startDate?: string | number | Date
55 endDate?: string | number | Date
56 iterator?: boolean
57 utc?: boolean
58 tz?: string
59}
60
61declare class CronExpression {
62 constructor(fields: {}, options: {})
63
64 /** Find next suitable date */
65 next(): CronDate
66 /** Find previous suitable date */
67 prev(): CronDate
68
69 /** Check if next suitable date exists */
70 hasNext(): boolean
71 /** Check if previous suitable date exists */
72 hasPrev(): boolean
73
74 /** Iterate over expression iterator */
75 iterate(steps: number, callback?: (item: CronDate, i: number) => any): CronDate[]
76
77 /** Reset expression iterator state */
78 reset(): void
79
80 /** Parse input expression (async) */
81 parse(expression: string, options?: ParserOptions, callback?: () => any): CronExpression
82}
83
84interface StringResult {
85 variables: { [key: string]: string },
86 expressions: CronExpression[],
87 errors: { [key: string]: string }
88}
89
90declare namespace CronParser {
91 /** Wrapper for CronExpression.parse method */
92 function parseExpression(expression: string, options?: ParserOptions): CronExpression
93 /** Parse crontab file */
94 function parseFile(filePath: string, callback: (err: any, data: StringResult) => any): void
95 /** Parse content string */
96 function parseString(data: string): StringResult
97}
\No newline at end of file