Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
node-downloader-helper
Advanced tools
The node-downloader-helper package is a Node.js library designed to facilitate the downloading of files from the internet. It provides a simple and efficient way to handle file downloads, including support for pause, resume, and cancel operations, as well as event-driven progress tracking.
Basic File Download
This feature allows you to download a file from a given URL to a specified directory. The example demonstrates how to initiate a download and log a message when the download is completed.
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://www.example.com/file.zip', './downloads');
dl.on('end', () => console.log('Download Completed'));
dl.start();
Pause and Resume Download
This feature allows you to pause and resume a download. The example demonstrates how to start a download, pause it after 5 seconds, and resume it after 10 seconds.
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://www.example.com/file.zip', './downloads');
dl.on('end', () => console.log('Download Completed'));
dl.start();
setTimeout(() => dl.pause(), 5000); // Pause after 5 seconds
setTimeout(() => dl.resume(), 10000); // Resume after 10 seconds
Progress Tracking
This feature allows you to track the progress of a download. The example demonstrates how to log the download progress percentage to the console.
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://www.example.com/file.zip', './downloads');
dl.on('progress', (stats) => console.log(`Downloaded ${stats.progress}%`));
dl.start();
Error Handling
This feature allows you to handle errors that occur during the download process. The example demonstrates how to log an error message if the download fails.
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://www.example.com/file.zip', './downloads');
dl.on('error', (err) => console.error('Download Failed', err));
dl.start();
Axios is a promise-based HTTP client for Node.js and the browser. While it is not specifically designed for file downloads, it can be used to download files by making HTTP requests and handling the response data. Compared to node-downloader-helper, axios requires more manual handling for features like pause, resume, and progress tracking.
Request is a simplified HTTP client for Node.js. It can be used to download files by making HTTP requests. However, it does not natively support advanced download management features like pause, resume, and progress tracking, which are available in node-downloader-helper.
Node-fetch is a lightweight module that brings window.fetch to Node.js. It can be used to download files by making HTTP requests. Similar to axios and request, it does not provide built-in support for advanced download management features like pause, resume, and progress tracking.
A simple http file downloader for node.js
Features:
$ npm install --save node-downloader-helper
For a more complete example check example folder
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://ipv4.download.thinkbroadband.com/1GB.zip', __dirname);
dl.on('end', () => console.log('Download Completed'))
dl.start();
Name | Description |
---|---|
start | starts the downloading |
pause | pause the downloading |
resume | resume the downloading if supported, if not it will start from the beginning |
stop | stop the downloading and remove the file |
Name | Description |
---|---|
start | triggered when the .start method is called |
download | triggered when the download starts |
progress | triggered every 1 second while is downloading callback(stats) |
end | triggered when the downloading has finished |
error | triggered when there is any error callback(error) |
pause | triggered when the .pause method is called |
resume | triggered when the .resume method is called |
stop | triggered when the .stop method is called |
stateChanged | triggered when the state changes callback(state) |
progress stats
object
{
total:, // total size that needs to be downloaded in bytes
downloaded:, // downloaded size in bytes
progress:, // progress porcentage 0-100%
speed: // download speed in bytes
}
Name | Value |
---|---|
IDLE | IDLE |
STARTED | STARTED |
DOWNLOADING | DOWNLOADING |
PAUSED | PAUSED |
RESUMED | RESUMED |
STOPPED | STOPPED |
FINISHED | FINISHED |
FAILED | FAILED |
$ npm test
Read License for more licensing information.
Read here for more information.
FAQs
A simple http/s file downloader for node.js
The npm package node-downloader-helper receives a total of 295,931 weekly downloads. As such, node-downloader-helper popularity was classified as popular.
We found that node-downloader-helper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.