description param h param s param v returns { String } const encodeColorData = ( h , s , v ) : string => { let hue = h % 360 ; hue = hue > 0 ? hue : h ; hue = hue < 0 ? 360 + hue : hue ; return [ hue , s , v ] . reduce ( ( curr , next ) => { let hex = next . toString ( 16 ) ; if ( hex . length < 4 ) { hex = '0' . repeat ( 4 - hex . length ) + hex ; } else { hex = hex . slice ( 0 , 4 ) ; } return curr + hex ; } , '' ) ; } ; description param hsvStr returns { Array } const decodeColorData = ( byte ) : number [ ] => { if ( ! byte || byte . length !== 12 ) { return [ 0 , 1000 , 1000 ] ; } const b = byte . match ( /[a-z\d]{4}/gi ) || [ ] ; return b . reduce ( ( curr , hex ) => { curr . push ( parseInt ( hex , 16 ) ) ; return curr ; } , [ ] ) ; } ; export default { encodeColorData , decodeColorData , } ;