type ImageOptions = { /** * The directory to save the image to. * * If not provided, the current working directory will be used. */ directory?: string; /** * The name of the image file. * * If not provided, the default value will be the **original name** if it exists in the URL. * * Otherwise, it will be **'image'**. * * If a name with same extension already exists, ` (1)`, ` (2)`, etc. will be added to the end of the name. */ name?: string; /** * The extension of the image. * * If not provided, the extension of the URL will be used. * * If the URL doesn't have an extension, `jpg` will be used. */ extension?: string; }; type DownloadOptions = { /** * The headers to send with the request. */ headers?: Record; /** * Set the maximum number of times to retry the request if it fails. * * @default 2 */ maxRetry?: number; /** * Set timeout for each request in milliseconds. */ timeout?: number; /** * The signal which can be used to abort requests. */ signal?: AbortSignal; /** * Set to `false` to disable certificate verification. * * This is useful when the server does not send intermediate certificates or uses self-signed certificates. * * @default true */ rejectUnauthorized?: boolean; /** * The certificate authority to trust. * * This is useful when the server does not send intermediate certificates. */ ca?: string | Buffer; }; type Image = { /** * The URL of the image. */ url: URL; /** * The name of the image file, without the extension. */ name: string; /** * The extension of the image without the dot. Example: `jpg`. */ extension: string; /** * The path of the directory where the image is saved. */ directory: string; /** * The original name of the image file, without the extension. */ originalName?: string; /** * The original extension of the image file, without the dot. Example: `jpg`. */ originalExtension?: string; /** * The absolute path of the image, including the directory, name, and extension. */ path: string; }; type Options = (ImageOptions & DownloadOptions) & { /** * Do something when an image is successfully downloaded. * * @param image The downloaded image. */ onSuccess?: (image: Image) => void; /** * Do something when an image fails to download. * * @param error The error that caused the download to fail. * @param url The URL of the image that failed to download. */ onError?: (error: Error, url: string) => void; /** * The number of requests to make at the same time. * * @default 5 */ step?: number; /** * The interval between each batch of requests in milliseconds. * * @default 100 */ interval?: number; /** * The signal which can be used to abort requests. */ signal?: AbortSignal; }; declare function imgdl(url: string | (string | ({ url: string; } & ImageOptions))[], options?: Options): Promise; export { type DownloadOptions, type Image, type ImageOptions, type Options, imgdl as default };