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

Function byteAt

src/utils/bash/bashParser.ts:166–194  ·  view source on GitHub ↗
(L: Lexer, charIdx: number)

Source from the content-addressed store, hash-verified

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