(expr: string)
| 81 | * Returns null if invalid or unsupported syntax. |
| 82 | */ |
| 83 | export function parseCronExpression(expr: string): CronFields | null { |
| 84 | const parts = expr.trim().split(/\s+/) |
| 85 | if (parts.length !== 5) return null |
| 86 | |
| 87 | const expanded: number[][] = [] |
| 88 | for (let i = 0; i < 5; i++) { |
| 89 | const result = expandField(parts[i]!, FIELD_RANGES[i]!) |
| 90 | if (!result) return null |
| 91 | expanded.push(result) |
| 92 | } |
| 93 | |
| 94 | return { |
| 95 | minute: expanded[0]!, |
| 96 | hour: expanded[1]!, |
| 97 | dayOfMonth: expanded[2]!, |
| 98 | month: expanded[3]!, |
| 99 | dayOfWeek: expanded[4]!, |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Compute the next Date strictly after `from` that matches the cron fields, |
no test coverage detected