import { ClassUtil } from "./ClassUtil" ; export class StringUtil { static toCamel ( value ) { value = value . charAt ( 0 ) . toLowerCase ( ) + value . slice ( 1 ) ; return value . replace ( /[-_](.)/g , function ( match , p ) { return p . toUpperCase ( ) ; } ) ; } static toSnake ( value ) { const camel = StringUtil . toCamel ( value ) ; return camel . replace ( /[A-Z]/g , function ( match ) { return "_" + match . charAt ( 0 ) . toLowerCase ( ) ; } ) ; } static toKebab ( value ) { const camel = StringUtil . toCamel ( value ) ; return camel . replace ( /[A-Z]/g , function ( match ) { return "-" + match . charAt ( 0 ) . toLowerCase ( ) ; } ) ; } static addUnit ( value , unit = "px" ) { return ClassUtil . isString ( value ) ? String ( value ) : value + unit ; } }