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

Function getTopLevelRawJsonStringField

src/parser.ts:823–848  ·  view source on GitHub ↗
(head: string, field: string)

Source from the content-addressed store, hash-verified

821}
822
823function getTopLevelRawJsonStringField(head: string, field: string): string | null {
824 let i = 0
825 while (i < head.length && /\s/.test(head[i]!)) i++
826 if (head.charCodeAt(i) !== 0x7b) return null
827 i++
828 while (i < head.length) {
829 while (i < head.length && /\s/.test(head[i]!)) i++
830 if (head.charCodeAt(i) === 0x2c) {
831 i++
832 continue
833 }
834 if (head.charCodeAt(i) === 0x7d) return null
835 if (head.charCodeAt(i) !== 0x22) return null
836 const keyEnd = findJsonStringEnd(head, i)
837 if (keyEnd === -1) return null
838 const key = head.slice(i + 1, keyEnd)
839 i = keyEnd + 1
840 while (i < head.length && /\s/.test(head[i]!)) i++
841 if (head.charCodeAt(i) !== 0x3a) return null
842 const value = findJsonValueBounds(head, i + 1)
843 if (!value) return null
844 if (key === field) return readJsonString(head, value) ?? null
845 i = value.end
846 }
847 return null
848}
849
850export function shouldSkipLine(line: string, threshold: string): boolean {
851 const head = line.length > RAW_HEAD_BYTES ? line.slice(0, RAW_HEAD_BYTES) : line

Callers 1

shouldSkipLineFunction · 0.85

Calls 3

findJsonStringEndFunction · 0.85
findJsonValueBoundsFunction · 0.85
readJsonStringFunction · 0.85

Tested by

no test coverage detected