import { assert } from "../fixed_assert" ; export function isWhitespaceCharacter ( character ) { return character === " " || character === "\t" || character === "\n" || character === "\r" ; } export function isQuoteCharacter ( character ) { return character === "'" || character === "\"" ; } export function isDigit ( character ) { return character ? "0" <= character && character <= "9" : false ; } export function isLetter ( character ) { return character ? ( "A" <= character && character <= "Z" ) || ( "a" <= character && character <= "z" ) : false ; } export function unquote ( value ) { if ( ! value ) { return "" ; } if ( value . startsWith ( "\"" ) ) { return value . endsWith ( "\"" ) ? value . slice ( 1 , value . length - 1 ) : value . slice ( 1 ) ; } else if ( value . startsWith ( "'" ) ) { return value . endsWith ( "'" ) ? value . slice ( 1 , value . length - 1 ) : value . slice ( 1 ) ; } return value ; } export function quote ( value ) { let result ; if ( value === null ) { result = "null" ; } else if ( value === undefined ) { result = "undefined" ; } else { result = `"${ value }"` ; } return result ; } export function escape ( value ) { let result ; if ( value ) { result = "" ; for ( const c of value ) { switch ( c ) { case "\b" : result += "\\b" ; break ; case "\f" : result += "\\f" ; break ; case "\n" : result += "\\n" ; break ; case "\r" : result += "\\r" ; break ; case "\t" : result += "\\t" ; break ; case "\v" : result += "\\v" ; break ; default : result += c ; break ; } } } else { result = value ; } return result ; } export function escapeAndQuote ( value ) { return quote ( escape ( value ) ) ; } /**
 * Get the combined length of the provided values.
 */ export function getCombinedLength ( values ) { let result = 0 ; assert ( values ) ; for ( const value of values ) { result += value . length ( ) ; } return result ; } /**
 * Get the combined text of the provided values.
 */ export function getCombinedText ( values ) { let result = "" ; assert ( values ) ; for ( const value of values ) { result += value . toString ( ) ; } return result ; } export function isSingleQuoted ( s ) { return s . length >= 2 && s [ 0 ] === `'` && s [ s . length - 1 ] === `'` ; } export function removeSingleQuotes ( expression ) { if ( isSingleQuoted ( expression ) ) { return expression . slice ( 1 , expression . length - 1 ) ; } return expression ; } export function isDoubleQuoted ( s ) { return s . length >= 2 && s [ 0 ] === `"` && s [ s . length - 1 ] === `"` ; } export function removeDoubleQuotes ( expression ) { if ( isDoubleQuoted ( expression ) ) { return expression . slice ( 1 , expression . length - 1 ) ; } return expression ; }