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

    Class BoundStream

    A bounded stream confined to reading and writing data in a limited subset of an underlying stream.

    Wraps an arbitrary stream, limiting I/O operations to a subset of the source stream. If endBoundary is -1, then the end of the stream is unbound.

    Hierarchy (View Summary)

    Index
    • Create a bounded stream.

      If endBoundary is less than 0, then the end of the stream is unbounded.

      Parameters

      • baseStream: Stream

        The underlying stream.

      • startBoundary: number

        The offset in the base stream that marks the start of this substream.

      • endBoundary: number

        The offset in the base stream that marks the end of this substream.

      • leaveOpen: boolean

        Whether to leave baseStream open after this stream is disposed.

      Returns BoundStream

      baseStream is not a stream.

      startBoundary is less than zero or endBoundary is before startBoundary.

    baseStream: Stream

    The underlying stream.

    All I/O is performed on the base stream.

    startBoundary: number

    The byte offset into baseStream that marks the beginning of the substream.

    endBoundary: number

    The byte offset into baseStream that marks the end of the substream, or -1 if unbound.

    • get canRead(): boolean

      Whether the stream supports reading.

      The bounded stream only supports reading if the underlying stream supports it.

      Returns boolean

    • get canWrite(): boolean

      Whether the stream supports writing.

      The bounded stream only supports writing if the underlying stream supports it.

      Returns boolean

    • get canSeek(): boolean

      Whether the stream supports seeking.

      The bounded stream only supports seeking if the underlying stream supports it.

      Returns boolean

    • get length(): number

      The length of the bounded stream, in bytes.

      If endBoundary is non-negative, the length is endBoundary - startBoundary. If the end is unbound, the length is based on the underlying stream length.

      Returns number

    • get position(): number

      The current position within the bounded stream, relative to startBoundary.

      Returns number

    • set position(value: number): void

      Set the current position within the bounded stream.

      Parameters

      • value: number

      Returns void

    • Read bytes from the bounded 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 bounded 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 bounded 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 bounded stream.

    • Set the length of the bounded 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

    • 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.