UNPKG

node-downloader-manager

Version:

node-downloader-manager is a simple yet powerful package manager-like download manager built with NodeJs. It allows you to download files sequentially or with a queue-based approach, handling retries and concurrency limits efficiently.

40 lines (39 loc) 1.03 kB
export interface Task { id: string; priority: number; action: () => Promise<boolean>; retries: number; } export type DownloadManagerOptions = { method?: "simple" | "queue" | "thread"; concurrencyLimit?: number; retries?: number; consoleLog?: boolean; downloadFolder?: string; getFileName?: (url: string) => string; onBeforeDownload?: (url: string, file: string, fileName: string) => Promise<void>; onAfterDownload?: (url: string, file: string, fileName: string) => Promise<void>; overWriteFile?: boolean; requestOptions?: RequestInit; stream?: boolean; backOff?: boolean; timeout?: number; maxWorkers?: number; }; export type EmitDataType = { message: string; url?: string; fileName?: string; file?: string; error?: unknown; progress?: string; totalSize?: number; downloaded?: number; speed?: string; }; export type WorkerTask = { id: string; fileName: string; url: string; options: DownloadManagerOptions; };