BitBuilder
Defined in: packages/core/src/buffer/stream/bit-builder.ts:10
Accumulates individual bits into bytes, MSB-first within each byte — the bit-level counterpart of ByteBuilder, for any bit-packed format (ASN.1 PER/X.691, other bitfield-oriented wire protocols).
Every writeBit/writeBits call is O(1) (or O(n) in the bit count for
writeBits, never re-walking bits already written); the cost of assembling
the final byte array is paid once, in result().
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BitBuilder():
BitBuilder
Returns
Section titled “Returns”BitBuilder
Accessors
Section titled “Accessors”bitLength
Section titled “bitLength”Get Signature
Section titled “Get Signature”get bitLength():
number
Defined in: packages/core/src/buffer/stream/bit-builder.ts:16
Total bits written so far.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”align()
Section titled “align()”align():
void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:68
For aligned PER-style formats: pads with zero bits to the next byte boundary.
Returns
Section titled “Returns”void
result()
Section titled “result()”result():
Uint8Array
Defined in: packages/core/src/buffer/stream/bit-builder.ts:92
Produces the accumulated bytes, padding the last one with zero bits if needed.
Returns
Section titled “Returns”Uint8Array
writeBit()
Section titled “writeBit()”writeBit(
bit):void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:21
Writes a single bit.
Parameters
Section titled “Parameters”0 | 1
Returns
Section titled “Returns”void
writeBits()
Section titled “writeBits()”Call Signature
Section titled “Call Signature”writeBits(
value,n):void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:43
Writes the low n bits of value, MSB first.
Parameters
Section titled “Parameters”number
The bits to write. A plain number covers n up to 32 —
the range JS’s <</>>> bitwise operators support; a bigint covers
any wider n (e.g. a PER constrained integer whose range needs more than
32 bits).
number
How many low bits of value to write.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”When value is a plain number and n is greater
than 32.
Call Signature
Section titled “Call Signature”writeBits(
value,n):void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:44
Writes the low n bits of value, MSB first.
Parameters
Section titled “Parameters”bigint
The bits to write. A plain number covers n up to 32 —
the range JS’s <</>>> bitwise operators support; a bigint covers
any wider n (e.g. a PER constrained integer whose range needs more than
32 bits).
number
How many low bits of value to write.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”When value is a plain number and n is greater
than 32.
writeByte()
Section titled “writeByte()”writeByte(
value):void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:77
Writes a complete byte (8 bits).
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
writeBytes()
Section titled “writeBytes()”writeBytes(
data):void
Defined in: packages/core/src/buffer/stream/bit-builder.ts:82
Writes every byte of data, in order.
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”void