MCPcopy Create free account
hub / github.com/Wscats/vscode-explore / compareSubstring

Function compareSubstring

contributes/src/vs/base/common/strings.ts:298–316  ·  view source on GitHub ↗
(a: string, b: string, aStart: number = 0, aEnd: number = a.length, bStart: number = 0, bEnd: number = b.length)

Source from the content-addressed store, hash-verified

296}
297
298export function compareSubstring(a: string, b: string, aStart: number = 0, aEnd: number = a.length, bStart: number = 0, bEnd: number = b.length): number {
299 for (; aStart < aEnd && bStart < bEnd; aStart++, bStart++) {
300 let codeA = a.charCodeAt(aStart);
301 let codeB = b.charCodeAt(bStart);
302 if (codeA < codeB) {
303 return -1;
304 } else if (codeA > codeB) {
305 return 1;
306 }
307 }
308 const aLen = aEnd - aStart;
309 const bLen = bEnd - bStart;
310 if (aLen < bLen) {
311 return -1;
312 } else if (aLen > bLen) {
313 return 1;
314 }
315 return 0;
316}
317
318export function compareIgnoreCase(a: string, b: string): number {
319 return compareSubstringIgnoreCase(a, b, 0, a.length, 0, b.length);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected