(a: string, b: string, aStart: number = 0, aEnd: number = a.length, bStart: number = 0, bEnd: number = b.length)
| 296 | } |
| 297 | |
| 298 | export 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 | |
| 318 | export function compareIgnoreCase(a: string, b: string): number { |
| 319 | return compareSubstringIgnoreCase(a, b, 0, a.length, 0, b.length); |
no outgoing calls
no test coverage detected