unfoldBitstream
@buff-beacon-project/rand-utils v1.0.0 • Docs
@buff-beacon-project/rand-utils v1.0.0 / unfoldBitstream
Function: unfoldBitstream()
unfoldBitstream<
T>(bitstream,fn):Generator<T>
Utility to yield results from provided function using a bitstream. Stops when bitstream runs out of usable bits.
Type Parameters
• T
Parameters
• bitstream: BitStream
• fn
Returns
Generator<T>
Example
// creates an array of 8 bit numbers consuming the bitStream
Array.from(unfoldBitstream((bs, i) => bs.readBits(8)))Defined in
Last updated