MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / tailSrcLenFor

Function tailSrcLenFor

src/pkg/utils/regex_to_glob.ts:206–223  ·  view source on GitHub ↗
(s: string, need: string)

Source from the content-addressed store, hash-verified

204 return got.startsWith(need) ? idx : 0;
205 }
206 function tailSrcLenFor(s: string, need: string): number {
207 if (!need) return 0;
208 let idx = s.length - 1,
209 got = "";
210 while (idx >= 0 && got.length < need.length) {
211 const ch = s[idx];
212 if (isEscaped(s, idx)) {
213 got = escapeGlobLiteral(ch) + got;
214 idx -= 2;
215 } else if (REGEX_SPECIAL.has(ch)) {
216 break;
217 } else {
218 got = escapeGlobLiteral(ch) + got;
219 idx -= 1;
220 }
221 }
222 return got.endsWith(need) ? s.length - 1 - idx : 0;
223 }
224
225 // ----- Character class ----- 字符类解析 -----
226 function parseCharClass(): Unit | null {

Callers 1

parseGroupFunction · 0.85

Calls 3

isEscapedFunction · 0.85
escapeGlobLiteralFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected