import * as stream from 'stream'; import * as readable_stream from 'readable-stream'; import { Transform, TransformOptions } from 'readable-stream'; /** @import { TransformOptions } from 'readable-stream' */ /** * Create a writable stream from an async function. Default concurrecy is 16 - * this is the number of parallel functions that will be pending before * backpressure is applied on the stream. * * @template {(...args: any[]) => Promise} T * @param {T} fn * @returns {import('readable-stream').Writable} */ declare function writeStreamFromAsync Promise>(fn: T, { concurrency }?: { concurrency?: number | undefined; }): readable_stream.Writable; /** * From https://github.com/nodejs/node/blob/430c0269/lib/internal/webstreams/adapters.js#L509 * * @param {ReadableStream} readableStream * @param {{ * highWaterMark? : number, * encoding? : string, * objectMode? : boolean, * signal? : AbortSignal, * }} [options] * @returns {import('stream').Readable} */ declare function fromWebReadableStream(readableStream: ReadableStream, options?: { highWaterMark?: number; encoding?: string; objectMode?: boolean; signal?: AbortSignal; }): stream.Readable; /** * @param {unknown} obj * @returns {obj is ReadableStream} */ declare function isWebReadableStream(obj: unknown): obj is ReadableStream; /** @typedef {(opts: { totalBytes: number, chunkBytes: number }) => void} ProgressCallback */ /** @typedef {TransformOptions & { onprogress?: ProgressCallback }} ProgressStreamOptions */ /** * Passthrough stream that counts the bytes passing through it. Pass an optional * `onprogress` callback that will be called with the accumulated total byte * count and the chunk byte count after each chunk. * @extends {Transform} */ declare class ProgressStream extends Transform { /** * @param {ProgressStreamOptions} [opts] */ constructor({ onprogress, ...opts }?: ProgressStreamOptions); /** Total bytes that have passed through this stream */ get byteLength(): number; /** * @override * @param {Buffer | Uint8Array} chunk * @param {Parameters[1]} encoding * @param {Parameters[2]} callback */ override _transform(chunk: Buffer | Uint8Array, encoding: Parameters[1], callback: Parameters[2]): void; #private; } type ProgressCallback = (opts: { totalBytes: number; chunkBytes: number; }) => void; type ProgressStreamOptions = TransformOptions & { onprogress?: ProgressCallback; }; export { type ProgressCallback, ProgressStream, type ProgressStreamOptions, fromWebReadableStream, isWebReadableStream, writeStreamFromAsync };