Members
-
Operations head.
-
Current length.
-
Linked forked states.
-
Operations tail
Methods
-
Writes a boolish value as a varint.
Parameters:
valueboolean Value to write
Returns:
Writer this -
Writes a sequence of bytes.
Parameters:
valueUint8Array | string Buffer or base64 encoded string to write
Returns:
Writer this -
Writes a double (64 bit float).
Parameters:
valuenumber Value to write
Returns:
Writer this -
Finishes the write operation.
Returns:
Uint8Array Finished buffer -
Finishes the write operation, writing into the provided buffer.
The caller must ensure thatbufhas enough space starting atoffset
to hold Writer#len bytes.Parameters:
bufT Target buffer
offsetnumber 0 optional Offset to start writing at
Returns:
T The provided buffer -
Writes an unsigned 32 bit value as fixed 32 bits.
Parameters:
valuenumber Value to write
Returns:
Writer this -
Writes an unsigned 64 bit value as fixed 64 bits.
Parameters:
valueLong | number | string Value to write
Throws:
TypeError If
valueis a string and no long library is present.Returns:
Writer this -
Writes a float (32 bit).
Parameters:
valuenumber Value to write
Returns:
Writer this -
Forks this writer's state by pushing it to a stack.
Calling reset or ldelim resets the writer to the previous state.Returns:
Writer this -
Writes a signed 32 bit value as a varint.
Parameters:
valuenumber Value to write
Returns:
Writer this -
Writes a signed 64 bit value as a varint.
Parameters:
valueLong | number | string Value to write
Throws:
TypeError If
valueis a string and no long library is present.Returns:
Writer this -
Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
Returns:
Writer this -
Writes raw bytes without a tag or length prefix.
Parameters:
valueUint8Array Raw bytes
Returns:
Writer this -
Resets this instance to the last state.
Returns:
Writer this -
Writes a signed 32 bit value as fixed 32 bits.
Parameters:
valuenumber Value to write
Returns:
Writer this -
Writes a signed 64 bit value as fixed 64 bits.
Parameters:
valueLong | number | string Value to write
Throws:
TypeError If
valueis a string and no long library is present.Returns:
Writer this -
Writes a 32 bit value as a varint, zig-zag encoded.
Parameters:
valuenumber Value to write
Returns:
Writer this -
Writes a signed 64 bit value as a varint, zig-zag encoded.
Parameters:
valueLong | number | string Value to write
Throws:
TypeError If
valueis a string and no long library is present.Returns:
Writer this -
Writes a string.
Parameters:
valuestring Value to write
Returns:
Writer this -
Writes an unsigned 32 bit value as a varint.
Parameters:
valuenumber Value to write
Returns:
Writer this -
Writes an unsigned 64 bit value as a varint.
Parameters:
valueLong | number | string Value to write
Throws:
TypeError If
valueis a string and no long library is present.Returns:
Writer this -
Allocates a buffer of the specified size.
Parameters:
sizenumber Buffer size
Returns:
Uint8Array Buffer -
Writer.create(){ BufferWriter | Writer }
-
Creates a new writer.
Returns:
BufferWriter | Writer A BufferWriter when Buffers are supported, otherwise a Writer