param data param inBits param outBits param pad return export function convertWords ( data , inBits , outBits , pad ) { let value = 0 ; let bits = 0 ; const maxV = ( 1 << outBits ) - 1 ; const result = [ ] ; for ( let i = 0 ; i < data . length ; ++ i ) { value = ( value << inBits ) | data [ i ] ; bits += inBits ; while ( bits >= outBits ) { bits -= outBits ; result . push ( ( value >> bits ) & maxV ) ; } } if ( pad && bits > 0 ) { result . push ( ( value << ( outBits - bits ) ) & maxV ) ; } return result ; } param num returns export function sizeofNum ( num ) { return Math . ceil ( Math . log2 ( num ) / 5 ) ; } param bits returns export function sizeofBits ( bits ) { return Math . ceil ( bits / 5 ) ; } param bytes returns export function sizeofBytes ( bytes ) { return sizeofBits ( bytes * 8 ) ; }