Options
All
  • Public
  • Public/Protected
  • All
Menu

Wire format writer using node buffers.

Hierarchy

Index

Constructors

Properties

head: object

Operations head.

len: number

Current length.

states: null | object

Linked forked states.

tail: object

Operations tail

Methods

  • Writes a boolish value as a varint.

    Parameters

    • value: boolean

      Value to write

    Returns Writer

    this

  • bytes(value: string | Uint8Array): Writer
  • Writes a sequence of bytes.

    Parameters

    • value: string | Uint8Array

      Buffer or base64 encoded string to write

    Returns Writer

    this

  • Writes a double (64 bit float).

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Finishes the write operation.

    Returns <internal>.Buffer

    Finished buffer

  • fixed32(value: number): Writer
  • Writes an unsigned 32 bit value as fixed 32 bits.

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Writes an unsigned 64 bit value as fixed 64 bits.

    throws

    {TypeError} If value is a string and no long library is present.

    Parameters

    • value: string | number | Long

      Value to write

    Returns Writer

    this

  • Writes a float (32 bit).

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Forks this writer's state by pushing it to a stack. Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.

    Returns Writer

    this

  • Writes a signed 32 bit value as a varint.

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Writes a signed 64 bit value as a varint.

    throws

    {TypeError} If value is a string and no long library is present.

    Parameters

    • value: string | number | Long

      Value to write

    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

  • Resets this instance to the last state.

    Returns Writer

    this

  • sfixed32(value: number): Writer
  • Writes a signed 32 bit value as fixed 32 bits.

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Writes a signed 64 bit value as fixed 64 bits.

    throws

    {TypeError} If value is a string and no long library is present.

    Parameters

    • value: string | number | Long

      Value to write

    Returns Writer

    this

  • Writes a 32 bit value as a varint, zig-zag encoded.

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Writes a signed 64 bit value as a varint, zig-zag encoded.

    throws

    {TypeError} If value is a string and no long library is present.

    Parameters

    • value: string | number | Long

      Value to write

    Returns Writer

    this

  • Writes a string.

    Parameters

    • value: string

      Value to write

    Returns Writer

    this

  • Writes an unsigned 32 bit value as a varint.

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • Writes an unsigned 64 bit value as a varint.

    throws

    {TypeError} If value is a string and no long library is present.

    Parameters

    • value: string | number | Long

      Value to write

    Returns Writer

    this

  • Allocates a buffer of the specified size.

    Parameters

    • size: number

      Buffer size

    Returns <internal>.Buffer

    Buffer