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

Function findJsonContainerEndBuffer

src/parser.ts:495–518  ·  view source on GitHub ↗
(source: Buffer, start: number, open: number, close: number, limit = source.length)

Source from the content-addressed store, hash-verified

493}
494
495function findJsonContainerEndBuffer(source: Buffer, start: number, open: number, close: number, limit = source.length): number {
496 let depth = 0
497 let inString = false
498 for (let i = start; i < limit; i++) {
499 const ch = source[i]
500 if (inString) {
501 if (ch === 0x5c) {
502 i++
503 } else if (ch === 0x22) {
504 inString = false
505 }
506 continue
507 }
508 if (ch === 0x22) {
509 inString = true
510 } else if (ch === open) {
511 depth++
512 } else if (ch === close) {
513 depth--
514 if (depth === 0) return i
515 }
516 }
517 return -1
518}
519
520function findJsonValueBoundsBuffer(source: Buffer, start: number, limit = source.length): BufferJsonValueBounds | null {
521 let i = start

Callers 4

parseLargeJsonlBufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected