import { CharCode } from "./charCode" ; internal export function convertSimple2RegExpPattern ( pattern ) { return pattern . replace ( /[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g , "\\$&" ) . replace ( /[\*]/g , ".*" ) ; } internal export function isLowerAsciiLetter ( code ) { return code >= CharCode . a && code <= CharCode . z ; } internal export function isUpperAsciiLetter ( code ) { return code >= CharCode . A && code <= CharCode . Z ; } internal function isAsciiLetter ( code ) { return isLowerAsciiLetter ( code ) || isUpperAsciiLetter ( code ) ; } internal export function equalsIgnoreCase ( a , b ) { return a . length === b . length && doEqualsIgnoreCase ( a , b ) ; } internal function doEqualsIgnoreCase ( a , b , stopAt = a . length ) { for ( let i = 0 ; i < stopAt ; i ++ ) { const codeA = a . charCodeAt ( i ) ; const codeB = b . charCodeAt ( i ) ; if ( codeA === codeB ) { continue ; } if ( isAsciiLetter ( codeA ) && isAsciiLetter ( codeB ) ) { const diff = Math . abs ( codeA - codeB ) ; if ( diff !== 0 && diff !== 32 ) { return false ; } } else { if ( String . fromCharCode ( codeA ) . toLowerCase ( ) !== String . fromCharCode ( codeB ) . toLowerCase ( ) ) { return false ; } } } return true ; } internal export function startsWithIgnoreCase ( str , candidate ) { const candidateLength = candidate . length ; if ( candidate . length > str . length ) { return false ; } return doEqualsIgnoreCase ( str , candidate , candidateLength ) ; }