Writes all kind of data values to a specified sink.

Written data is buffered so you have to call the flush method when you are done writing all data to ensure that all data is written to the sink.

All methods of the writer are asynchronous but can safely be used synchronously when you have no reason to wait for it. Usually you only want to wait for the flush method at the end of a write operation.

Constructors

Methods

  • Writes all buffered data to the sink. If an incomplete byte is buffered then it is padded with zeroes so the writer points to the beginning of a new byte after flushing.

    Returns Promise<void>

  • Returns number

    The buffer size of the writer.

  • Returns the default encoding of the writer.

    Returns string

    the default encoding used when no encoding is specified as parameter to the various string write methods.

  • Returns the default endianness of the writer.

    Returns Endianness

    the default endianness used when no endianness is specified as parameter to the various write methods.

  • Returns the number of written bytes. This value reflects the number of bytes the writer was told to write so far, not the actual number of written bytes (which may not be finished because writing happens asynchronously). When a write operation fails then this counter is invalid and may not be in sync with the output sink any longer.

    Returns number

    the number of written bytes.

  • Writes an signed 64 bit value.

    Parameters

    • value: bigint

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of signed 64 bit values.

    Parameters

    • values: BigInt64Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an unsigned 64 bit value.

    Parameters

    • value: bigint

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of unsigned 64 bit values.

    Parameters

    • values: BigUint64Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes a single bit.

    Parameters

    • value: number

      The bit to write.

    Returns void

  • Writes a signed 16 bit value.

    Parameters

    • value: number

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of signed 16 bit values.

    Parameters

    • values: Int16Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes a signed 32 bit value.

    Parameters

    • value: number

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of signed 32 bit values.

    Parameters

    • values: Int32Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes a signed 8 bit value.

    Parameters

    • value: number

      The value to write.

    Returns void

  • Writes an array of signed 8 bit values.

    Parameters

    • values: Int8Array

      The values to write.

    Returns void

  • Writes a string.

    Parameters

    • text: string

      The text to write.

    • encoding: string = ...

      The encoding. Defaults to encoding the writer was configured with.

    Returns void

  • Writes an unsigned 16 bit value.

    Parameters

    • value: number

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of unsigned 16 bit values.

    Parameters

    • values: Uint16Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an unsigned 32 bit value.

    Parameters

    • value: number

      The value to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an array of unsigned 32 bit values.

    Parameters

    • values: Uint32Array

      The values to write.

    • endianness: Endianness = ...

      Optional endianness. Defaults to endianness the writer was configured with.

    Returns void

  • Writes an unsigned 8 bit value.

    Parameters

    • value: number

      The value to write.

    Returns void

  • Writes an array of unsigned 8 bit values.

    Parameters

    • values: Uint8Array | Uint8ClampedArray

      The values to write.

    Returns void