(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY)
| 240 | } |
| 241 | |
| 242 | function readJsonString(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY): string | undefined { |
| 243 | if (!bounds || bounds.kind !== 'string') return undefined |
| 244 | let out = '' |
| 245 | for (let i = bounds.start + 1; i < bounds.end - 1 && out.length < cap; i++) { |
| 246 | const ch = source[i]! |
| 247 | if (ch !== '\\') { |
| 248 | out += ch |
| 249 | continue |
| 250 | } |
| 251 | const next = source[++i] |
| 252 | if (!next) break |
| 253 | if (next === 'n') out += '\n' |
| 254 | else if (next === 'r') out += '\r' |
| 255 | else if (next === 't') out += '\t' |
| 256 | else if (next === 'b') out += '\b' |
| 257 | else if (next === 'f') out += '\f' |
| 258 | else if (next === 'u' && i + 4 < bounds.end) { |
| 259 | const hex = source.slice(i + 1, i + 5) |
| 260 | const code = Number.parseInt(hex, 16) |
| 261 | if (Number.isFinite(code)) out += String.fromCharCode(code) |
| 262 | i += 4 |
| 263 | } else { |
| 264 | out += next |
| 265 | } |
| 266 | } |
| 267 | return out |
| 268 | } |
| 269 | |
| 270 | function readJsonNumberField(source: string, objectBounds: JsonValueBounds | null, field: string): number | undefined { |
| 271 | if (!objectBounds || objectBounds.kind !== 'object') return undefined |
no outgoing calls
no test coverage detected