export const camelCase = ( ( ) => { const DEFAULT_REGEX = /[-_]+(.)?/g ; function toUpper ( match , group1 ) { return group1 ? group1 . toUpperCase ( ) : '' ; } return ( str , delimiters ? ) => { return str . replace ( delimiters ? new RegExp ( '[' + delimiters + ']+(.)?' , 'g' ) : DEFAULT_REGEX , toUpper ) ; } ; } ) ( ) ; export const safePush = ( obj , key , value ) => { if ( ! obj [ key ] ) { obj [ key ] = [ ] ; } cleanUndefined ( value ) ; obj [ key ] . push ( value ) ; } ; export const oneObjectMoreArray = ( obj , key , value ) => { if ( ! obj [ key ] ) { obj [ key ] = value ; return ; } if ( obj [ key ] && obj [ key ] . constructor . name === 'Object' ) { obj [ key ] = [ obj [ key ] ] ; } let indexOfSameObject = - 1 ; if ( value && value . viewId ) { obj [ key ] . forEach ( ( o , i ) => { if ( o && o . viewId && o . viewId === value . viewId ) { indexOfSameObject = i ; } } ) ; } else if ( value && value . componentId ) { obj [ key ] . forEach ( ( o , i ) => { if ( o && o . componentId && o . componentId === value . componentId ) { indexOfSameObject = i ; } } ) ; } if ( indexOfSameObject === - 1 ) { obj [ key ] . push ( value ) ; } else { obj [ key ] [ indexOfSameObject ] = { ... obj [ key ] [ indexOfSameObject ] , ... value , } ; } } ; export const cleanUndefined = ( value ) => { const newValue = { ... value } ; for ( const key in newValue ) { if ( newValue [ key ] === undefined ) { delete newValue [ key ] ; } } return newValue ; } ; export const isAllUndefined = ( value ) => { return Object . keys ( value ) . every ( ( key ) => value [ key ] === undefined ) ; } ; export const camelize = ( str ) => { return str . replace ( /(?:^\w|[A-Z]|\b\w)/g , ( letter , index ) => { return index === 0 ? letter . toLowerCase ( ) : letter . toUpperCase ( ) ; } ) . replace ( /\s+/g , '' ) ; } ; /**
 * special props for vue
 */ export const normalizeProps = ( props , include = [ ] , exclude = [ ] ) => { const newProps = { ... props } ; if ( newProps . vStyle ) { newProps . style = newProps . vStyle ; delete newProps . vStyle ; } if ( exclude . length ) { exclude . forEach ( ( propsKey ) => { delete newProps [ propsKey ] ; } ) ; } if ( include . length ) { Object . keys ( newProps ) . forEach ( ( propsKey ) => { if ( include . indexOf ( propsKey ) === - 1 ) { delete newProps [ propsKey ] ; } } ) ; } return newProps ; } ; export const generateRandomNum = ( ) => { return ( Math . floor ( new Date ( ) . getTime ( ) + Math . random ( ) * 10000 ) ) . toString ( ) ; } ;