export function randomStr ( length ) { const chars = [ ] ; for ( let i = 0 ; i < length ; i ++ ) { chars [ i ] = Math . random ( ) . toString ( 36 ) [ 2 ] ; } return chars . join ( "" ) ; } export function arrayToggle < T > ( array , value , state ? ) { if ( typeof state === "undefined" ) { state = ! array . includes ( value ) ; } if ( state ) { return [ ... array , value ] . filter ( ( v , i , a ) => a . indexOf ( v ) === i ) ; } else { return array . filter ( ( v ) => v !== value ) ; } } export function hexToRgb ( hex ) { const value = parseInt ( hex . replace ( "#" , "" ) , 16 ) ; return { r : ( value >> 16 ) & 255 , g : ( value >> 8 ) & 255 , b : value & 255 , } ; } export function rgbToHex ( { r , g , b } ) { return "#" + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ) . toString ( 16 ) . slice ( 1 ) ; } export function registerMessage ( message ) { return message . defaultMessage ; }