MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / byteAt

Function byteAt

source code/utils/bash/bashParser.ts:168–196  ·  view source on GitHub ↗
(L: Lexer, charIdx: number)

Source from the content-addressed store, hash-verified

166}
167
168function byteAt(L: Lexer, charIdx: number): number {
169 // Fast path: ASCII-only prefix means char idx == byte idx
170 if (L.byteTable) return L.byteTable[charIdx]!
171 // Build table on first non-trivial lookup
172 const t = new Uint32Array(L.len + 1)
173 let b = 0
174 let i = 0
175 while (i < L.len) {
176 t[i] = b
177 const c = L.src.charCodeAt(i)
178 if (c < 0x80) {
179 b++
180 i++
181 } else if (c < 0x800) {
182 b += 2
183 i++
184 } else if (c >= 0xd800 && c <= 0xdbff) {
185 t[i + 1] = b + 2
186 b += 4
187 i += 2
188 } else {
189 b += 3
190 i++
191 }
192 }
193 t[L.len] = b
194 L.byteTable = t
195 return t[charIdx]!
196}
197
198function isWordChar(c: string): boolean {
199 // Bash word chars: alphanumeric + various punctuation that doesn't start operators

Callers 2

sliceBytesFunction · 0.85
restoreLexToByteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected