{"library":"node-downloader-helper","title":"Node Downloader Helper","description":"node-downloader-helper is a robust, zero-dependency file downloader for Node.js, supporting HTTP and HTTPS protocols. It's built for environments like vanilla Node.js, Electron, and NW.js, providing features essential for reliable file transfers. Key functionalities include pause and resume capabilities, automatic retry mechanisms for failed downloads, handling of HTTP redirects, and the option to pipe downloaded content for on-the-fly processing. Currently stable at version 2.1.11, the library demonstrates an active release cadence, with frequent patch updates addressing bugs, performance optimizations, and feature enhancements. Its primary differentiators are its complete independence from third-party packages, minimizing its attack surface and simplifying its dependency tree, along with comprehensive error management and detailed progress statistics.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install node-downloader-helper"],"cli":null},"imports":["import { DownloaderHelper } from 'node-downloader-helper';","const { DownloaderHelper } = require('node-downloader-helper');","import type { DownloadOptions } from 'node-downloader-helper';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { DownloaderHelper } from 'node-downloader-helper';\nimport path from 'path';\nimport fs from 'fs';\n\nconst downloadUrl = 'https://proof.ovh.net/files/1Gb.dat'; // Example URL for a large file\nconst destinationFolder = path.join(__dirname, 'downloads');\n\n// Ensure the destination folder exists\nif (!fs.existsSync(destinationFolder)) {\n  fs.mkdirSync(destinationFolder, { recursive: true });\n}\n\nconst dl = new DownloaderHelper(downloadUrl, destinationFolder, {\n  fileName: 'test-file.dat',\n  retry: { maxRetries: 3, delay: 1000 }, // Retry 3 times with 1-second delay\n  resumeOnIncomplete: true,\n  maxRedirects: 5\n});\n\ndl.on('start', () => console.log(`Starting download for ${downloadUrl} to ${destinationFolder}`));\ndl.on('progress', (stats) => {\n  const progress = stats.progress.toFixed(2);\n  const speed = (stats.speed / 1024 / 1024).toFixed(2); // MB/s\n  console.log(`Progress: ${progress}% - Speed: ${speed} MB/s - Downloaded: ${(stats.downloaded / 1024 / 1024).toFixed(2)} MB`);\n});\ndl.on('end', () => console.log('Download Completed successfully!'));\ndl.on('error', (err) => console.error('Download Failed:', err.message));\ndl.on('timeout', () => console.error('Download Timed out!'));\ndl.on('skip', (info) => console.log(`Download skipped: ${info.message}`));\n\ndl.start().catch(err => {\n  console.error('Failed to initiate download:', err.message);\n});","lang":"typescript","description":"This quickstart demonstrates how to initialize `DownloaderHelper`, configure basic options like retries and a custom filename, and set up event listeners for monitoring download progress, completion, and errors. It also ensures the download directory exists before starting.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}