(field: string, min: number, max: number, name: string)
| 94 | } |
| 95 | |
| 96 | function parseField(field: string, min: number, max: number, name: string): Set<number> { |
| 97 | if (field === '') { |
| 98 | throw new Error(`cron ${name} field is empty`); |
| 99 | } |
| 100 | const out = new Set<number>(); |
| 101 | const terms = field.split(','); |
| 102 | for (const term of terms) { |
| 103 | if (term === '') { |
| 104 | throw new Error(`cron ${name} field has empty term in list`); |
| 105 | } |
| 106 | addTerm(out, term, min, max, name); |
| 107 | } |
| 108 | if (out.size === 0) { |
| 109 | throw new Error(`cron ${name} field matches no values`); |
| 110 | } |
| 111 | return out; |
| 112 | } |
| 113 | |
| 114 | // Cron numeric fields are digit-only. `Number(...)` would otherwise |
| 115 | // accept `''` (→ 0), `'1e1'`, `'0x10'`, `'+5'`, `' 3 '`, etc. — none |
no test coverage detected