new BufferWriter()
Constructs a new buffer writer instance.
Extends
Members
-
head { Object }
-
Operations head.
-
len { number }
-
Current length.
-
states { Object | null }
-
Linked forked states.
-
tail { Object }
-
Operations tail
Methods
-
BufferWriter.alloc(size){ Buffer }
-
Allocates a buffer of the specified size.
Name Type Description size
number Buffer size
Returns:
Type Description Buffer Buffer -
Writes a boolish value as a varint.
Name Type Description value
boolean Value to write
Returns:
Type Description Writer this
-
Writes a sequence of bytes.
Name Type Description value
Uint8Array | string Buffer or base64 encoded string to write
Returns:
Type Description Writer this
-
Writes a double (64 bit float).
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
finish(){ Buffer }
-
Finishes the write operation.
Returns:
Type Description Buffer Finished buffer -
Writes an unsigned 32 bit value as fixed 32 bits.
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
Writes an unsigned 64 bit value as fixed 64 bits.
Name Type Description value
Long | number | string Value to write
Throws:
Type Description TypeError If
value
is a string and no long library is present.Returns:
Type Description Writer this
-
Writes a float (32 bit).
Name Type Description value
number Value to write
Returns:
Type Description 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:
Type Description Writer this
-
Writes a signed 32 bit value as a varint.
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
Writes a signed 64 bit value as a varint.
Name Type Description value
Long | number | string Value to write
Throws:
Type Description TypeError If
value
is a string and no long library is present.Returns:
Type Description Writer this
-
Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
Returns:
Type Description Writer this
-
Resets this instance to the last state.
Returns:
Type Description Writer this
-
Writes a signed 32 bit value as fixed 32 bits.
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
Writes a signed 64 bit value as fixed 64 bits.
Name Type Description value
Long | number | string Value to write
Throws:
Type Description TypeError If
value
is a string and no long library is present.Returns:
Type Description Writer this
-
Writes a 32 bit value as a varint, zig-zag encoded.
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
Writes a signed 64 bit value as a varint, zig-zag encoded.
Name Type Description value
Long | number | string Value to write
Throws:
Type Description TypeError If
value
is a string and no long library is present.Returns:
Type Description Writer this
-
Writes a string.
Name Type Description value
string Value to write
Returns:
Type Description Writer this
-
Writes an unsigned 32 bit value as a varint.
Name Type Description value
number Value to write
Returns:
Type Description Writer this
-
Writes an unsigned 64 bit value as a varint.
Name Type Description value
Long | number | string Value to write
Throws:
Type Description TypeError If
value
is a string and no long library is present.Returns:
Type Description Writer this