Creates a new ChunkedByteVectorStream.
Zero or more Uint8Array chunks that form the initial
content. Empty chunks are silently discarded.
Returns a Blob whose parts are the individual chunks, avoiding a full buffer copy in browser environments.
Optionalmime: stringOptional MIME type for the Blob.
Returns a copy of the internal chunk array. Each element is a copy of the corresponding chunk.
Resets the stream position to the beginning.
Returns a copy of all chunks concatenated as a ByteVector.
Inserts data at byte offset start, optionally replacing replace
bytes of existing content. Builds a new chunk array from slices of
existing chunks to avoid unnecessary data copies.
The bytes to insert.
Byte offset at which to begin the insertion.
Number of existing bytes to overwrite. Defaults to 0.
Returns true — ChunkedByteVectorStream is always open.
Returns the total number of bytes across all chunks.
Returns an empty string — in-memory streams have no meaningful name.
Reads up to length bytes starting from the current position, spanning
chunk boundaries as needed, and advances the position.
Maximum number of bytes to read.
Resolves with a ByteVector containing the bytes read.
Returns false — ChunkedByteVectorStream is always writable.
Removes length bytes beginning at byte offset start. Builds a new
chunk array from slices of the existing chunks on either side of the
removed region.
Byte offset of the first byte to remove.
Number of bytes to remove.
Moves the read/write position.
Number of bytes to move.
Reference point. Defaults to Position.Beginning.
Returns the current read/write position in bytes.
Truncates or zero-extends the stream to exactly length bytes. If the
current position exceeds the new length, it is clamped.
The desired stream length in bytes.
Writes data at the current position, overwriting existing content byte
by byte across chunk boundaries and appending a new chunk if the write
extends past the end. Advances the position by data.length.
The bytes to write.
StaticfromCreates a ChunkedByteVectorStream from an existing array of chunks.
This factory avoids the overhead of the spread-argument constructor when the chunk array is already available. Empty chunks are silently discarded.
The initial chunk array.
An in-memory IOStream backed by an array of
Uint8Arraychunks.Unlike ByteVectorStream, data is never stored as one contiguous buffer. This is efficient when working with large media files where only specific regions need to be modified — existing chunks can be sliced and reused without copying the whole buffer.
Additionally, the chunk array can be passed directly to a Blob constructor, enabling zero-copy export for browser environments.
All I/O methods are async to satisfy the IOStream contract; the underlying operations are synchronous in-memory computations.