(source: string, objectStart: number, objectEnd: number, field: string)
| 213 | } |
| 214 | |
| 215 | function findObjectFieldValue(source: string, objectStart: number, objectEnd: number, field: string): JsonValueBounds | null { |
| 216 | if (source.charCodeAt(objectStart) !== 0x7b) return null |
| 217 | let i = objectStart + 1 |
| 218 | while (i < objectEnd - 1) { |
| 219 | while (i < objectEnd && /\s/.test(source[i]!)) i++ |
| 220 | if (source.charCodeAt(i) === 0x2c) { |
| 221 | i++ |
| 222 | continue |
| 223 | } |
| 224 | if (source.charCodeAt(i) !== 0x22) { |
| 225 | i++ |
| 226 | continue |
| 227 | } |
| 228 | const keyEnd = findJsonStringEnd(source, i, objectEnd) |
| 229 | if (keyEnd === -1) return null |
| 230 | const key = source.slice(i + 1, keyEnd) |
| 231 | i = keyEnd + 1 |
| 232 | while (i < objectEnd && /\s/.test(source[i]!)) i++ |
| 233 | if (source.charCodeAt(i) !== 0x3a) continue |
| 234 | const value = findJsonValueBounds(source, i + 1, objectEnd) |
| 235 | if (!value) return null |
| 236 | if (key === field) return value |
| 237 | i = value.end |
| 238 | } |
| 239 | return null |
| 240 | } |
| 241 | |
| 242 | function readJsonString(source: string, bounds: JsonValueBounds | null, cap = Number.POSITIVE_INFINITY): string | undefined { |
| 243 | if (!bounds || bounds.kind !== 'string') return undefined |
no test coverage detected