Options
All
  • Public
  • Public/Protected
  • All
Menu

Wire format writer using node buffers.

Hierarchy

Index

Constructors

  • Constructs a new buffer writer instance.

    Returns BufferWriter

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

  • Writes a sequence of bytes.

    Parameters

    Returns Writer

    this

  • Writes a double (64 bit float).

    Parameters

    • value: number

      Value to write

    Returns Writer

    this

  • finish(): Buffer
  • Finishes the write operation.

    Returns 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

  • fixed64(value: string | number | Long): Writer
  • 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

  • int64(value: string | number | Long): Writer
  • 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

  • sfixed64(value: string | number | Long): Writer
  • 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

  • sint64(value: string | number | Long): Writer
  • 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

  • uint64(value: string | number | Long): Writer
  • 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

  • alloc(size: number): Buffer
  • Allocates a buffer of the specified size.

    Parameters

    • size: number

      Buffer size

    Returns Buffer

    Buffer

Generated using TypeDoc