MCPcopy Create free account
hub / github.com/getagentseal/codeburn / findObjectFieldValueBuffer

Function findObjectFieldValueBuffer

src/parser.ts:551–576  ·  view source on GitHub ↗
(source: Buffer, objectStart: number, objectEnd: number, field: string)

Source from the content-addressed store, hash-verified

549}
550
551function 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
578function appendBufferJsonSegment(source: Buffer, start: number, end: number, current: string, cap: number): string {
579 if (start >= end || current.length >= cap) return current

Callers 6

parseLargeUsageBufferFunction · 0.85
parseLargeJsonlBufferFunction · 0.85

Calls 4

isJsonWhitespaceByteFunction · 0.85
findJsonStringEndBufferFunction · 0.85
bufferKeyEqualsFunction · 0.85

Tested by

no test coverage detected