E.g.: binStringToBin('0010101001100100') → new Uint8Array([42, 100])
Note, this method always completes. If binaryDigits is not divisible by 8,
the final byte will be parsed as if it were prepended with 0s (e.g. 1
is interpreted as 00000001). If binaryDigits is potentially malformed,
check it with isBinString before calling this method.
Decode a binary-encoded string into a Uint8Array.
E.g.:
binStringToBin('0010101001100100')
→new Uint8Array([42, 100])
Note, this method always completes. If
binaryDigits
is not divisible by 8, the final byte will be parsed as if it were prepended with0
s (e.g.1
is interpreted as00000001
). IfbinaryDigits
is potentially malformed, check it withisBinString
before calling this method.For the reverse, see binToBinString.