{"id":25030438,"url":"https://github.com/nextyfine-dev/bun-download-manager","last_synced_at":"2026-02-15T01:30:42.955Z","repository":{"id":273748481,"uuid":"919075115","full_name":"nextyfine-dev/bun-download-manager","owner":"nextyfine-dev","description":"bun-download-manager is a simple yet powerful package manager-like download manager built with Bun.js. It allows you to download files sequentially or with a queue-based approach, handling retries and concurrency limits efficiently. ","archived":false,"fork":false,"pushed_at":"2025-01-22T19:23:15.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T21:25:15.966Z","etag":null,"topics":["bun","bun-download-manager","bun-downloader-manager"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/bun-downloader-manager","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nextyfine-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-19T16:40:12.000Z","updated_at":"2025-01-22T19:23:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"18a89cdb-7ee8-4e55-b8c5-a35705550c91","html_url":"https://github.com/nextyfine-dev/bun-download-manager","commit_stats":null,"previous_names":["nextyfine-dev/bun-download-manager"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nextyfine-dev/bun-download-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fbun-download-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fbun-download-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fbun-download-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fbun-download-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nextyfine-dev","download_url":"https://codeload.github.com/nextyfine-dev/bun-download-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nextyfine-dev%2Fbun-download-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29463941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"ssl_error","status_checked_at":"2026-02-15T01:01:23.809Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","bun-download-manager","bun-downloader-manager"],"created_at":"2025-02-05T22:00:11.515Z","updated_at":"2026-02-15T01:30:42.950Z","avatar_url":"https://github.com/nextyfine-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠️ bun-downloader-manager\n\n`bun-downloader-manager` is a simple yet powerful package manager-like download manager built with **Bun.js**. It allows you to download files sequentially or with a queue-based approach, handling retries, concurrency limits, and custom tasks efficiently. Designed for seamless integration into Node.js and TypeScript projects, this tool is perfect for managing downloads with ease and flexibility.\n\n---\n\n## 📚 Table of Contents\n\n- [�️ bun-downloader-manager](#️-bun-downloader-manager)\n  - [📚 Table of Contents](#-table-of-contents)\n  - [🔧 Features](#-features)\n  - [🚀 Installation](#-installation)\n    - [Using npm](#using-npm)\n    - [Using yarn](#using-yarn)\n    - [Using bun](#using-bun)\n  - [🔍 Usage](#-usage)\n    - [Queue Download Example](#queue-download-example)\n    - [Queue Download Example 2](#queue-download-example-2)\n    - [Simple Download Example](#simple-download-example)\n    - [Custom Task Example Using `otherTaskFunction`](#custom-task-example-using-othertaskfunction)\n  - [🛠️ API Documentation](#️-api-documentation)\n    - [DownloadManager Class](#downloadmanager-class)\n      - [Constructor Options](#constructor-options)\n      - [Methods](#methods)\n    - [Queue Class](#queue-class)\n      - [Constructor Options](#constructor-options-1)\n      - [Methods](#methods-1)\n  - [⚖️ License](#️-license)\n\n---\n\n## 🔧 Features\n\n- **Queue-based downloads**: Handles multiple download tasks with retry mechanisms and concurrency limits.\n- **Simple sequential downloads**: Downloads files one by one.\n- **Retry support**: Automatically retries failed downloads up to a specified limit.\n- **Custom file naming**: Allows you to define custom logic for naming downloaded files.\n- **Logging**: Optional logging to monitor download progress.\n- **Custom tasks**: Supports additional processing for each file with `otherTaskFunction`.\n- **File overwrite control**: Enables or disables overwriting files with the same name.\n\n---\n\n## 🚀 Installation\n\nTo install `bun-downloader-manager`, you can use **npm**, **yarn**, or **bun**:\n\n### Using npm\n\n```bash\nnpm install bun-downloader-manager\n```\n\n### Using yarn\n\n```bash\nyarn add bun-downloader-manager\n```\n\n### Using bun\n\n```bash\nbun add bun-downloader-manager\n```\n\n---\n\n## 🔍 Usage\n\nHere are some examples of how to use `bun-downloader-manager` in your project:\n\n### Queue Download Example\n\nDownload multiple files with concurrency control and automatic task management:\n\n```ts\nimport DownloadManager from \"bun-downloader-manager\";\n\nconst urls = [\n  \"https://example.com/file1.jpeg\",\n  \"https://example.com/file2.jpeg\",\n  \"https://example.com/file3.jpeg\",\n];\n\nconst downloadManager = new DownloadManager({\n  consoleLog: true, // Enable logging\n  method: \"queue\", // Use queue-based download\n});\n\nawait downloadManager.download(urls);\n```\n\n### Queue Download Example 2\n\nManually enqueue download tasks for greater flexibility:\n\n```ts\nimport DownloadManager from \"bun-downloader-manager\";\n\nconst urls = [\n  \"https://example.com/file1.jpeg\",\n  \"https://example.com/file2.jpeg\",\n  \"https://example.com/file3.jpeg\",\n];\n\n// Optional custom file name logic\nconst getFileName = (url: string) =\u003e `${Date.now()}-${url.split(\"/\").pop()}`;\n\nconst downloadManager = new DownloadManager({\n  consoleLog: true, // Enable logging\n});\n\nfor (const url of urls) {\n  downloadManager.enqueueDownloadTask(url, getFileName(url)); // Custom file name is optional\n}\n```\n\n### Simple Download Example\n\nDownload files one by one in sequence:\n\n```ts\nimport DownloadManager from \"bun-downloader-manager\";\n\nconst urls = [\n  \"https://example.com/file1.jpeg\",\n  \"https://example.com/file2.jpeg\",\n];\n\nconst downloadManager = new DownloadManager({\n  consoleLog: true,\n  method: \"simple\", // Use simple sequential download\n});\n\nawait downloadManager.download(urls);\n```\n\n### Custom Task Example Using `otherTaskFunction`\n\nDefine a custom task function for additional processing during downloads:\n\n```ts\nimport DownloadManager from \"bun-downloader-manager\";\n\nconst urls = [\n  \"https://example.com/file1.jpeg\",\n  \"https://example.com/file2.jpeg\",\n];\n\nconst customTaskFunction = async (url: string, fileName: string) =\u003e {\n  console.log(`Processing ${fileName}`);\n  // Custom logic (e.g., saving metadata or sending notifications)\n};\n\nconst downloadManager = new DownloadManager({\n  method: \"queue\",\n  consoleLog: true,\n  otherTaskFunction: customTaskFunction, // Custom task\n  overWriteFile: true, // Overwrite existing files\n});\n\nawait downloadManager.download(urls);\n```\n\n---\n\n## 🛠️ API Documentation\n\n### DownloadManager Class\n\nThe `DownloadManager` class is the main interface for handling file downloads.\n\n#### Constructor Options\n\n| Option              | Type                                               | Default         | Description                                                                                  |\n| ------------------- | -------------------------------------------------- | --------------- | -------------------------------------------------------------------------------------------- |\n| `method`            | `\"simple\"` \\| `\"queue\"`                            | `\"queue\"`       | Choose between **simple** (sequential downloads) or **queue** (task-based downloads).        |\n| `concurrencyLimit`  | `number`                                           | `5`             | Maximum number of concurrent downloads (for \"queue\" method).                                 |\n| `retries`           | `number`                                           | `3`             | Maximum number of retries allowed for failed downloads.                                      |\n| `consoleLog`        | `boolean`                                          | `false`         | Enable or disable console logging.                                                           |\n| `downloadFolder`    | `string`                                           | `\"./downloads\"` | Directory to save downloaded files.                                                          |\n| `getFileName`       | `(url: string) =\u003e string`                          | `undefined`     | Custom function to generate file names from URLs. If not provided, the URL filename is used. |\n| `otherTaskFunction` | `(url: string, fileName: string) =\u003e Promise\u003cvoid\u003e` | `undefined`     | Custom task function for additional processing (e.g., post-download actions).                |\n| `overWriteFile`     | `boolean`                                          | `false`         | If `true`, files with the same name will be overwritten. If `false`, duplicates are skipped. |\n\n#### Methods\n\n- **`download(urls: string | string[])`**: Downloads one or more files based on the configured `method`.\n- **`enqueueDownloadTask(url: string, fileName?: string, priority?: number)`**: Adds a download task to the queue manually.\n\n### Queue Class\n\nManages tasks in the queue with concurrency control.\n\n#### Constructor Options\n\n| Option             | Type      | Default | Description                          |\n| ------------------ | --------- | ------- | ------------------------------------ |\n| `concurrencyLimit` | `number`  | `5`     | Maximum number of concurrent tasks.  |\n| `maxRetries`       | `number`  | `3`     | Maximum retries for failed tasks.    |\n| `consoleLog`       | `boolean` | `false` | Enable logging for queue operations. |\n\n#### Methods\n\n- **`enqueue(task: Task)`**: Adds a new task to the queue.\n- **`runNext()`**: Processes the next task in the queue.\n\n---\n\n## ⚖️ License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fbun-download-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnextyfine-dev%2Fbun-download-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnextyfine-dev%2Fbun-download-manager/lists"}