MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / parseField

Function parseField

packages/agent-core/src/tools/cron/cron-expr.ts:96–112  ·  view source on GitHub ↗
(field: string, min: number, max: number, name: string)

Source from the content-addressed store, hash-verified

94}
95
96function 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

Callers 1

parseCronExpressionFunction · 0.85

Calls 1

addTermFunction · 0.85

Tested by

no test coverage detected