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

    Class DataViewWriter

    Write bytes to a growing buffer. Intended for relatively-small final buffer sizes; everything is held in memory.

    Index

    Constructors

    Properties

    defaultOptions: RequiredWriterOptions = ...

    Accessors

    • get length(): number

      Current number of bytes in the writer.

      Returns number

      Length in bytes.

    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.

    • Convert a string to ASCII bytes.

      Parameters

      • s: string

        Latin-1 string.

      Returns this

      This, for chaining.

      Character not in 0-256.

    • Clear all of the existing data.

      Returns this

      This, for chaining.

    • Write a two-byte float.

      Parameters

      • n: number

        Number that fits in a short float without losing precision.

      Returns this

      This, for chaining.

      If number would lose precision on write.

    • Write a four-byte float.

      Parameters

      • n: number

        Number that fits in a float.

      Returns this

      This, for chaining.

      Would lose precision.

    • Write an eight-byte integer.

      Parameters

      • n: number

        Double.

      Returns this

      This, for chaining.

    • Write a signed two-byte integer.

      Parameters

      • n: number

        Signed short int.

      Returns this

      This, for chaining.

    • Write a signed four-byte integer.

      Parameters

      • n: number

        Signed int.

      Returns this

      This, for chaining.

    • Write an eight-byte signed integer.

      Parameters

      • n: number | bigint

        Signed long long.

      Returns this

      This, for chaining.

    • Write a signed byte.

      Parameters

      • n: number

        Signed byte.

      Returns this

      This, for chaining.

    • Read the current contents of the writer as a single buffer, but does not clear the current contents. This has a side effect, which is to coalesce multiple chunks into a single chunk, making subsequent read() and peek() operations a little faster. Note: there is no need to call peek() before read() for performance, read() does the same coalescing, then throws away the result.

      Returns Uint8Array

      Current contents of the writer.

    • Destructively read all bytes from the writer as a single buffer. Could take some time if there are lots of chunks.

      Returns Uint8Array

      Bytes.

    • Write a two-byte unsigned integer.

      Parameters

      • n: number

        Unsigned short int.

      Returns this

      This, for chaining.

    • Write a four-byte unsigned integer.

      Parameters

      • n: number

        Unsigned int.

      Returns this

      This, for chaining.

    • Write an eight-byte unsigned integer.

      Parameters

      • n: number | bigint

        Unsigned long long.

      Returns this

      This, for chaining.

    • Write a single unsigned byte.

      Parameters

      • n: number

        Byte.

      Returns this

      This, for chaining.

    • Encode the string as UTF8.

      Parameters

      • s: string

        String. If there are unpaired surrogates, they will be switched to the replacement character.

      Returns this

      This, for chaining.

    • Write an arbitrarily-large amount of data to the writer. If this buffer is larger than chunkSize, it is appended directly -- see the copyBuffers option for what should happen in this case. If the buffer is less than the chunkSize + 8 bytes, the buffer is always copied, since it might be worth writing some more data into that same chunk later.

      Parameters

      • buf: Uint8Array

        Bytes to write.

      • copy: boolean = ...

        Override the copyBuffers option if specified.

      Returns this

      This, for chaining.