export function stringToHex ( str ) { let buf = new TextEncoder ( ) . encode ( str ) ; return [ ... buf ] . map ( b => b . toString ( 16 ) . padStart ( 2 , "0" ) ) . join ( "" ) ; } export function numToHex ( n , digits ? ) { let hex = n . toString ( 16 ) . toUpperCase ( ) ; if ( digits ) { return ( "0" . repeat ( digits ) + hex ) . slice ( - digits ) ; } return ( hex . length % 2 == 0 ) ? hex : "0" + hex ; } export function valueIn < type > ( setof , value ) { return setof . indexOf ( value ) >= 0 ; }