param str export const escapeCharacter = ( str ) => { return str . replace ( /\r?\n/g , '<br>' ) . replace ( /\|/g , '\\|' ) ; } ; param str export const toKebabCase = ( str ) : string => { return str . replace ( /[A-Z]/g , ( match , offset ) => { return `${ offset > 0 ? '-' : '' }${ match . toLocaleLowerCase ( ) }` ; } ) ; } ; const opt = Object . prototype . toString ; export function isBoolean ( obj ) { return opt . call ( obj ) === '[object Boolean]' ; } param { str } string returns { string } export function unquote ( str ) { return str && str . replace ( /^['"]|['"]$/g , '' ) ; } param { str } string returns { string } export function trimStr ( str ) { return str && str . replace ( /^(\s|\||\r?\n)*|(\s|\||\r?\n)*$/g , '' ) ; } param { str } string returns { string } export function cleanStr ( str ) { return str && str . replace ( /\r?\n/g , '' ) ; } export const getTemplate = ( src , lang ) => { const matches = Array . from ( src . matchAll ( /##\s+(zh-CN|en-US)\n+(.+?)\n+---(?:\n|$)/gs ) ) ; for ( const item of matches ) { if ( new RegExp ( lang ) . test ( item [ 1 ] ) ) { src = src . replace ( item [ 0 ] , `${ item [ 2 ] }\n` ) ; } else { src = src . replace ( item [ 0 ] , '' ) ; } } return src ; } ;