It's probably best to handle it in C (the less people writing in JS have to be aware of the better). Perhaps you could do something like data & ((1<<databits)-1) and then it'd be vaguely compatible with any number of bits.
data & ((1<<databits)-1)
© Espruino, powered by microcosm.
Report a problem