export class StringUtil { public static replaceAll ( s , val , newVal ) { while ( s . indexOf ( val ) !== - 1 ) { s = s . replace ( val , newVal ) ; } return s ; } public static prettyPrint ( bufferString ) { let s = StringUtil . replaceAll ( bufferString , "\r\n" , "\\n" ) ; s = StringUtil . replaceAll ( s , "\n" , "\\n" ) ; return s ; } public static prettyPrintJSON ( jsonString ) { try { return JSON . stringify ( JSON . parse ( jsonString ) , null , 2 ) ; } catch ( e ) { return jsonString ; } } param s param padString param length returns { string } public static rpad ( s , padString , length ) { let str = s ; while ( str . length < length ) str = str + padString ; if ( str . length > length ) { str = str . substr ( 0 , length ) ; } return str ; } public static isIn ( input , values ) { let match = false ; for ( let s of values ) { if ( input === s ) { match = true ; break ; } } return match ; } }