dataview-stream - v1.4.0
    Preparing search index...

    Class DataViewReader

    Treat a Uint8Array as a stream to read typed data from, sequentially. Note that this is not an actual ReadableStream in either the nodejs sense or the web sense.

    Index

    Constructors

    Properties

    defaultOptions: RequiredRederOptions = ...

    Accessors

    • get offset(): number

      Current offset.

      Returns number

      Current.

    • get original(): Uint8Array

      Original bytes.

      Returns Uint8Array

      Original.

    Methods

    • When outputting with console.log('%O', this) or at the node REPL, see the current chunk structure.

      Parameters

      • depth: number

        Current depth.

      • options: InspectOptions

        Options for writing, generated by util.inpect.

      • inspect: Inspect

        Local copy of util.inspect, so there is no node dependency.

      Returns string

      Formatted string.

    • Get a chunk of the buffer as 8-bit ASCII text. This is only useful for ancient protocols such as DNS. If the top bit is set, you get equivalent Unicode characters, which should be Latin-1.

      Advances the current read position by length bytes.

      Parameters

      • length: number

        Number of bytes.

      Returns string

      String.

    • Get a chunk of the original buffer.

      Advances the current read position by length bytes.

      Parameters

      • length: number

        How many bytes?

      Returns Uint8Array

      A subarray of the original buffer, without copying.

    • If the current buffer has not been completely read, throws an error.

      Returns void

      When extra data.

    • Get a half-precision floating point number. On older JS runtimes, uses a local implementation of f16.

      Advances the current read position by 2 bytes.

      Returns number

      Number.

    • Get a single-precision floating point number.

      Advances the current read position by 4 bytes.

      Returns number

      Number.

    • Get a double-precision floating point number.

      Advances the current read position by 8 bytes.

      Returns number

      Number.

    • Get a two-byte signed integer. Advances the current read position by 2 bytes.

      Returns number

      Number.

    • Get a four-byte signed integer. Advances the current read position by 4 bytes.

      Returns number

      Number.

    • Get a eight-byte signed integer. Advances the current read position by 8 bytes.

      Returns bigint

      Bigint.

    • Get a signed byte. Advances the current read position by 1 byte.

      Returns number

      Number.

    • Reset to the beginning of the input. Ignores the initial offset, so if you want to restart at the same place, call seek(initialOffset).

      Returns void

    • Go to a particular offset in the buffer.

      Parameters

      • offset: number = 0

        The new offset.

      Returns void

    • Convenience function to repeat reading a given number of times.

      Type Parameters

      Parameters

      • num: number

        Number of times to call fn.

      • fn: (n: number) => T

        Function that reads.

      Returns T[]

      Array of results.

    • Get a two-byte unsigned integer. Advances the current read position by 2 bytes.

      Returns number

      Number.

    • Get a four-byte unsigned integer. Advances the current read position by 4 bytes.

      Returns number

      Number.

    • Get an eight-byte unsigned integer. Advances the current read position by 8 bytes.

      Returns bigint

      Bigint, since 264 > 253.

    • Get an unsigned byte. Advances the current read position by 1 byte.

      Returns number

      Number.

    • Read a number of bytes as a UTF-8 encoded string. Use the ignoreUTF8errors option to avoid throwing exceptions on invalid UTF-8 and get replacement characters instead. However, by default, Postel was wrong.

      Advances the current read position by length bytes.

      Parameters

      • length: number

        Number of bytes.

      Returns string

      Unicode string.