//#region src/index.d.ts /** * Simple wrapper around a `ReadableStream` that contains the total length of * the streamed binary data. */ declare class ByteStream { /** * Underlying `ReadableStream` instance. */ readonly stream: ReadableStream; /** * Total length of the stream in bytes. */ readonly length: number; constructor(stream: ReadableStream, opts: { length: number; }); } /** * Utility function to convert a `Uint8Array` to an `ArrayBuffer`. * * Required by various standards. * * @param array `Uint8Array` to convert. * * @returns An `ArrayBuffer` that contains the `Uint8Array` data. */ declare const uint8ArrayToArrayBuffer: (array: Uint8Array) => ArrayBuffer; /** * Convert a `Uint8Array` to a `ByteStream`. * * @param binary `Uint8Array` to convert. * * @returns A `ByteStream` that emits the `Uint8Array` chunks. */ declare const binaryToByteStream: (binary: Uint8Array) => ByteStream; /** * Convert a `ByteStream` to a `Uint8Array`. * * @param stream `ByteStream` to convert. * * @returns A `Uint8Array` that contains the streamed binary data. */ declare const byteStreamToBinary: (stream: ByteStream) => Promise; /** * Options for the `trackProgress` function. */ interface TrackProgressOptions { /** * Callback to invoke when progress is made. * * @param progress Object containing the total number of bytes processed, the * total length of the stream, the percentage of the stream that has been * processed, and the estimated time remaining in milliseconds. */ progress?: (progress: { processed: number; total: number; percent: number; duration: number; eta: number | null; }) => void; /** * Callback to invoke when the stream is done. * * @param done Object containing the total number of bytes processed and the * duration it took to process them in milliseconds. */ done?: (done: { total: number; duration: number; }) => void; /** * Callback to invoke when the stream is cancelled. */ cancelled?: () => void; } /** * Wrap a `ByteStream` in a progress stream that emits progress events at the * specified interval. * * @param src `ByteStream` to wrap. * @param opts Options for the progress stream. * * @returns A `ByteStream` that emits progress events at the specified interval. */ declare const trackProgress: (stream: ByteStream, opts?: TrackProgressOptions | null | undefined) => ByteStream; /** * Split a single `ByteStream` into two `ByteStream`s which can be consumed * from separately. * * @param stream `ByteStream` to split. * * @returns A tuple of two `ByteStream` instances. */ declare const splitStream: (stream: ByteStream) => [ByteStream, ByteStream]; export { ByteStream, binaryToByteStream, byteStreamToBinary, splitStream, trackProgress, uint8ArrayToArrayBuffer };