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

    Class MeasuringStream

    A stream useful for measuring the amount of data written.

    A measuring stream tracks the number of bytes written to it. This is useful when you need to know how large a message is without writing it to disk or a memory buffer.

    Hierarchy (View Summary)

    Index
    • get canRead(): boolean

      Whether the stream supports reading.

      A measuring stream is not readable.

      Returns boolean

    • get canWrite(): boolean

      Whether the stream supports writing.

      A measuring stream is always writable.

      Returns boolean

    • get canSeek(): boolean

      Whether the stream supports seeking.

      A measuring stream is always seekable.

      Returns boolean

    • get length(): number

      The number of bytes that have been written to the stream.

      Returns number

    • get position(): number

      The current position within the stream.

      Since seeking is possible, the position may differ from the length, although typically it is the same.

      Returns number

    • set position(value: number): void

      Set the current position within the stream.

      Parameters

      • value: number

      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.

    • Reading from a measuring stream is not supported.

      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

      Always thrown because reading is unsupported.

    • Write bytes to the measuring stream.

      Increments the position by the number of bytes written. If the updated position is greater than the current length, the length is updated to match the position.

      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.

      Parameters

      • value: number

        The desired length in bytes.

      Returns void

      value is negative or not an integer.

    • 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

    • Throw for an unsupported stream operation.

      Parameters

      • operation: string

        The unsupported operation name.

      Returns never

      Always thrown because the operation is unsupported.