(source: Buffer, objectStart: number, objectEnd: number, field: string)
| 549 | } |
| 550 | |
| 551 | function findObjectFieldValueBuffer(source: Buffer, objectStart: number, objectEnd: number, field: string): BufferJsonValueBounds | null { |
| 552 | if (source[objectStart] !== 0x7b) return null |
| 553 | let i = objectStart + 1 |
| 554 | while (i < objectEnd - 1) { |
| 555 | while (i < objectEnd && isJsonWhitespaceByte(source[i])) i++ |
| 556 | if (source[i] === 0x2c) { |
| 557 | i++ |
| 558 | continue |
| 559 | } |
| 560 | if (source[i] !== 0x22) { |
| 561 | i++ |
| 562 | continue |
| 563 | } |
| 564 | const keyEnd = findJsonStringEndBuffer(source, i, objectEnd) |
| 565 | if (keyEnd === -1) return null |
| 566 | const keyStart = i + 1 |
| 567 | i = keyEnd + 1 |
| 568 | while (i < objectEnd && isJsonWhitespaceByte(source[i])) i++ |
| 569 | if (source[i] !== 0x3a) continue |
| 570 | const value = findJsonValueBoundsBuffer(source, i + 1, objectEnd) |
| 571 | if (!value) return null |
| 572 | if (bufferKeyEquals(source, keyStart, keyEnd, field)) return value |
| 573 | i = value.end |
| 574 | } |
| 575 | return null |
| 576 | } |
| 577 | |
| 578 | function appendBufferJsonSegment(source: Buffer, start: number, end: number, current: string, cap: number): string { |
| 579 | if (start >= end || current.length >= cap) return current |
no test coverage detected