(text: string, i: number)
| 468 | } |
| 469 | |
| 470 | function parseKeyPart(text: string, i: number): { value: string; end: number } | null { |
| 471 | const ch = text[i]; |
| 472 | if (ch === '"') { |
| 473 | let j = i + 1; |
| 474 | while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1; |
| 475 | if (j >= text.length) return null; |
| 476 | const value = decodeBasicString(text.slice(i + 1, j)); |
| 477 | return value === null ? null : { value, end: j + 1 }; |
| 478 | } |
| 479 | if (ch === "'") { |
| 480 | const j = text.indexOf("'", i + 1); |
| 481 | return j === -1 ? null : { value: text.slice(i + 1, j), end: j + 1 }; |
| 482 | } |
| 483 | let j = i; |
| 484 | while (j < text.length && /[A-Za-z0-9_-]/.test(text[j]!)) j++; |
| 485 | return j === i ? null : { value: text.slice(i, j), end: j }; |
| 486 | } |
| 487 | |
| 488 | const SIMPLE_ESCAPES: Record<string, string> = { |
| 489 | b: String.fromCharCode(8), t: String.fromCharCode(9), n: String.fromCharCode(10), f: String.fromCharCode(12), |
no test coverage detected