import * as stream from 'stream'; import { ProgressCallback } from './streams.cjs'; import 'readable-stream'; /** * @typedef {object} DownloadResponse * @property {import('stream').Readable} body Node ReadableStream of the response body * @property {string | null} mimeType Content mime-type (from http content-type header) * @property {number | null} contentLength Content length in bytes (from http content-length header) */ /** * A wrapper for fetch that limits the number of concurrent downloads. */ declare class FetchQueue { /** @param {number} concurrency */ constructor(concurrency: number); get activeCount(): number; /** * Fetch a URL, limiting the number of concurrent downloads. Resolves with a * `DownloadResponse`, which is a parsed from the Fetch `Response` objects, * with `body` as a Node readable stream, and the MIME type and content length * of the response. * * NB: The response body stream must be consumed to the end, otherwise the * queue will never be emptied. * * @param {string} url * @param {{ onprogress?: import('./streams.js').ProgressCallback }} opts * @returns {Promise} */ fetch(url: string, { onprogress }?: { onprogress?: ProgressCallback; }): Promise; #private; } type DownloadResponse = { /** * Node ReadableStream of the response body */ body: stream.Readable; /** * Content mime-type (from http content-type header) */ mimeType: string | null; /** * Content length in bytes (from http content-length header) */ contentLength: number | null; }; export { type DownloadResponse, FetchQueue };