( key: TKey, )
| 113 | } |
| 114 | return value ?? CONFIG_DEFAULTS[key]; |
| 115 | } |
| 116 | |
| 117 | async function setConfigValue<TKey extends keyof BananaConfig>( |
| 118 | key: TKey, |
| 119 | value: BananaConfig[TKey], |
| 120 | ): Promise<void> { |
| 121 | const db = await getDb(); |
| 122 | db.data![key] = value; |
| 123 | await db.write(); |
| 124 | } |
| 125 | |
| 126 | function parseSizeInput(raw: string): number | null { |
| 127 | const normalized = raw.trim().toLowerCase(); |
| 128 | if (!normalized) return null; |
| 129 | |
| 130 | const match = normalized.match(/^(\d+(?:\.\d+)?)(b|kb|mb|gb)?$/); |
no test coverage detected