MCPcopy Index your code
hub / github.com/codeaashu/claude-code / sliceBytes

Function sliceBytes

src/utils/bash/bashParser.ts:677–700  ·  view source on GitHub ↗
(P: ParseState, startByte: number, endByte: number)

Source from the content-addressed store, hash-verified

675}
676
677function sliceBytes(P: ParseState, startByte: number, endByte: number): string {
678 if (P.isAscii) return P.src.slice(startByte, endByte)
679 // Find char indices for byte offsets. Build byte table if needed.
680 const L = P.L
681 if (!L.byteTable) byteAt(L, 0)
682 const t = L.byteTable!
683 // Binary search for char index where byte offset matches
684 let lo = 0
685 let hi = P.src.length
686 while (lo < hi) {
687 const m = (lo + hi) >>> 1
688 if (t[m]! < startByte) lo = m + 1
689 else hi = m
690 }
691 const sc = lo
692 lo = sc
693 hi = P.src.length
694 while (lo < hi) {
695 const m = (lo + hi) >>> 1
696 if (t[m]! < endByte) lo = m + 1
697 else hi = m
698 }
699 return P.src.slice(sc, lo)
700}
701
702function leaf(P: ParseState, type: string, tok: Token): TsNode {
703 return mk(P, type, tok.start, tok.end, [])

Callers 6

mkFunction · 0.85
parseSimpleCommandFunction · 0.85
parseSubscriptIndexFunction · 0.85
tryParseBraceExprFunction · 0.85
tryParseBraceLikeCatFunction · 0.85
parseCaseItemFunction · 0.85

Calls 1

byteAtFunction · 0.85

Tested by

no test coverage detected