taglib-ts
    Preparing search index...

    A read/write IOStream backed by a browser/Node.js Blob (or File).

    Each BlobSegment is fetched from the blob on first access and its bytes are cached on the segment object. Subsequent reads of the same range are served from the cache without any async I/O. When a single readBlock call spans multiple uncached segments, all arrayBuffer() requests are issued in parallel via Promise.all.

    A piece table tracks the logical content as an ordered list of Segments. Mutations only manipulate this list; they never copy the original blob. The cached total length is kept up-to-date on every mutation so that length() is O(1).

    toBlob assembles a new Blob from blob.slice() references and in-memory buffers — no full-file copy. The new blob's MIME type is copied from the source blob.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new BlobStream wrapping the given Blob or File.

      The blob's contents are not loaded into memory at construction time. Each byte range is fetched on demand and cached for subsequent access.

      Parameters

      • blob: Blob

        The blob (or File) to stream.

      Returns BlobStream

    Methods

    • Inserts data at byte offset start, optionally replacing replace bytes of existing content. Sets the position to start + data.length.

      Parameters

      • data: ByteVector

        The bytes to insert.

      • start: number

        Byte offset at which to begin the insertion.

      • replace: number = 0

        Number of existing bytes to replace. Defaults to 0.

      Returns Promise<void>

    • Reads up to length bytes from the current position, spanning segment boundaries as needed. All uncached BlobSegments in the range are fetched in parallel via Promise.all and their results are cached on the segment for future reads.

      Parameters

      • length: number

        Maximum number of bytes to read.

      Returns Promise<ByteVector>

      Resolves with a ByteVector containing the bytes read. May be shorter than length if the logical end of stream is reached.

    • Removes length bytes beginning at byte offset start.

      Parameters

      • start: number

        Byte offset of the first byte to remove.

      • length: number

        Number of bytes to remove.

      Returns Promise<void>

    • Assembles a new Blob from the current piece table without loading the full content into memory. Each BlobSegment becomes a blob.slice() reference and each BufferSegment is passed as a raw Uint8Array. The new blob's MIME type is copied from the source blob.

      Returns Blob

      A new Blob reflecting all edits made to this stream.

    • Truncates or zero-extends the stream to exactly length bytes. If the current position exceeds the new length it is clamped.

      Parameters

      • length: number

        The desired stream length in bytes.

      Returns Promise<void>

    • Writes data at the current position, overwriting existing content and extending the stream if necessary. Advances the position by data.length.

      Parameters

      Returns Promise<void>