mimekit-ts - v1.0.0
    Preparing search index...

    Class MemoryBlockStream

    An efficient memory stream implementation that sacrifices direct access to the internal byte buffer in order to improve performance.

    Instead of resizing one internal byte array, the stream chains blocks of non-contiguous memory. This avoids copying old data into newly allocated arrays.

    Hierarchy (View Summary)

    Index
    • get canRead(): boolean

      Whether the stream supports reading.

      The memory block stream is always readable.

      Returns boolean

    • get canWrite(): boolean

      Whether the stream supports writing.

      The memory block stream is always writable.

      Returns boolean

    • get canSeek(): boolean

      Whether the stream supports seeking.

      The memory block stream is always seekable.

      Returns boolean

    • get position(): number

      The current position within the stream.

      Returns number

    • set position(value: number): void

      Set the current position within the stream.

      Parameters

      • value: number

      Returns void

    • Copy the stream data into a newly allocated, contiguous byte array.

      Returns Uint8Array

      The copied array.

    • Read bytes from the stream.

      Parameters

      • buffer: Uint8Array

        The buffer to read data into.

      • offset: number

        The offset into the buffer to start reading data.

      • count: number

        The number of bytes to read.

      Returns number

      The total number of bytes read into the buffer, or zero if the end of the stream has been reached.

    • Write bytes to the stream.

      Parameters

      • buffer: Uint8Array

        The buffer to write.

      • offset: number

        The offset of the first byte to write.

      • count: number

        The number of bytes to write.

      Returns void

    • Set the position within the stream.

      Parameters

      • offset: number

        The offset relative to origin.

      • origin: SeekOrigin

        The reference point used to obtain the new position.

      Returns number

      The new position within the stream.

    • Set the length of the stream.

      If the length is reduced, blocks no longer needed are released and truncated bytes are cleared.

      Parameters

      • value: number

        The desired length in bytes.

      Returns void

      value is outside the valid range.

    • Copy data from this stream to another stream.

      Parameters

      • destination: Stream

        The stream that will receive the copied data.

      • bufferSize: number = 4096

        The temporary buffer size to use while copying.

      Returns void

    • Validate buffer, offset, and count arguments for stream read/write operations.

      Parameters

      • buffer: Uint8Array

        The buffer supplied by the caller.

      • offset: number

        The starting offset in the buffer.

      • count: number

        The number of bytes to read or write.

      Returns void

      offset or count does not specify a valid range in buffer.

    • Throw for an unsupported stream operation.

      Parameters

      • operation: string

        The unsupported operation name.

      Returns never

      Always thrown because the operation is unsupported.