(_key: string, value: string)
| 67 | |
| 68 | const QUOTED_VALUE_REGEXP = /^"(?<value>.*)"$/; |
| 69 | function parseValue(_key: string, value: string) { |
| 70 | if (value === "null") return null; |
| 71 | if (value === "true") return true; |
| 72 | if (value === "false") return false; |
| 73 | const match = value.match(QUOTED_VALUE_REGEXP); |
| 74 | if (match) return match.groups?.value as string; |
| 75 | if (!isNaN(+value)) return +value; |
| 76 | return value; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Parse an INI config string into an object. |