()
| 101 | return Math.max(50, Math.min(MAX_LIMIT, Math.floor(num))); |
| 102 | } |
| 103 | |
| 104 | function readScheduleConfig(): CyScheduleConfig { |
| 105 | try { |
| 106 | if (!fs.existsSync(CONFIG_PATH)) return { ...DEFAULT_SCHEDULE }; |
| 107 | const raw = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8")); |
| 108 | return { |
| 109 | enabled: Boolean(raw.enabled), |
| 110 | target: typeof raw.target === "string" ? raw.target.trim() : "", |
| 111 | times: Array.isArray(raw.times) ? raw.times.map(String).filter(isValidTime).slice(0, 12) : [], |
| 112 | limit: normalizeLimit(raw.limit), |
| 113 | }; |
| 114 | } catch { |
| 115 | return { ...DEFAULT_SCHEDULE }; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | function writeScheduleConfig(config: CyScheduleConfig): void { |
no test coverage detected