Gathering detailed insights and metrics for @s524797336/node-downloader-helper
Gathering detailed insights and metrics for @s524797336/node-downloader-helper
Gathering detailed insights and metrics for @s524797336/node-downloader-helper
Gathering detailed insights and metrics for @s524797336/node-downloader-helper
A simple http file downloader for node.js
npm install @s524797336/node-downloader-helper
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
1,561
Last Day
2
Last Week
6
Last Month
31
Last Year
300
MIT License
258 Stars
100 Commits
54 Forks
6 Watchers
3 Branches
19 Contributors
Updated on Jun 16, 2025
Latest Version
1.0.5
Package Id
@s524797336/node-downloader-helper@1.0.5
Unpacked Size
27.61 kB
Size
8.99 kB
File Count
6
NPM Version
6.14.5
Node Version
14.2.0
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
100%
6
Compared to previous week
Last Month
181.8%
31
Compared to previous month
Last Year
47.8%
300
Compared to previous year
A simple http file downloader for node.js
Features:
$ npm install --save node-downloader-helper
For a more complete example check example folder
1const { DownloaderHelper } = require('node-downloader-helper'); 2const dl = new DownloaderHelper('http://www.ovh.net/files/1Gio.dat', __dirname); 3 4dl.on('end', () => console.log('Download Completed')) 5dl.start();
This can be used as standalone CLI downloader
Install npm i -g node-downloader-helper
Usage: ndh [folder] [url]
1$ ndh ./folder http://url
Download Helper constructor also allow a 3rd parameter to set some options constructor(url, destinationFolder, options)
,
these are the default values
1{ 2 method: 'GET', // Request Method Verb 3 headers: {}, // Custom HTTP Header ex: Authorization, User-Agent 4 fileName: string|cb(fileName, filePath)|{name, ext}, // Custom filename when saved 5 retry: false, // { maxRetries: number, delay: number in ms } or false to disable (default) 6 forceResume: false, // If the server does not return the "accept-ranges" header, can be force if it does support it 7 removeOnStop: true, // remove the file when is stopped (default:true) 8 removeOnFail: true, // remove the file when fail (default:true) 9 override: boolean|{skip, skipSmaller}, // Behavior when local file already exists 10 httpRequestOptions: {}, // Override the http request options 11 httpsRequestOptions: {}, // Override the https request options, ex: to add SSL Certs 12}
for fileName
you can provide 3 types of parameter
(fileName) => 'PREFIX_' + fileName;
name
attribute and an optional ext
attribute, the ext
attribute can be an string without dot(.
) or a boolean where true
use the name
as full file name (same as just giving an string to the fileName
parameter) or false (default) will only replace the name and keep the original extension, for example if the original name is myfile.zip
and the option is {name: 'somename'}
the output will be somename.zip
for override
you can provide 2 types of parameter
true
to override existing local file, false
to append '(number)' to new file nameskip
(boolean): whether to skip download if file exists, and skipSmaller
(boolean): whether to skip download if file exists but is smaller. Both default to false
, for the equivalent of override: true
.for httpRequestOptions
the available options are detailed in here https://nodejs.org/api/http.html#http_http_request_options_callback
for httpsRequestOptions
the available options are detailed in here https://nodejs.org/api/https.html#https_https_request_options_callback
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 |
pipe | readable.pipe(stream.Readable, options) : stream.Readable |
unpipe | (stream) if not stream is not specified, then all pipes are detached. |
updateOptions | (options) updates the options, can be use on pause/resume events |
getStats | returns stats from the current download, these are the same stats sent via progress event |
getDownloadPath | gets the full path where the file will be downloaded (available after the start phase) |
isResumable | return tru/false if the download can be resumable (available after the start phase) |
Name | Description |
---|---|
start | Emitted when the .start method is called |
skip | Emitted when the download is skipped because the file already exists |
download | Emitted when the download starts callback(downloadInfo) |
progress | Emitted every 1 second while is downloading callback(stats) |
retry | Emitted when the download fails and retry is enabled callback(attempt, retryOpts) |
end | Emitted when the downloading has finished callback(downloadInfo) |
error | Emitted when there is any error callback(error) |
timeout | Emitted when the underlying socket times out from inactivity. |
pause | Emitted when the .pause method is called |
resume | Emitted when the .resume method is called callback(isResume) |
stop | Emitted when the .stop method is called |
renamed | Emitted when '(number)' is appended to the end of file, this requires override:false opt, callback(filePaths) |
stateChanged | Emitted when the state changes callback(state) |
event skip skipInfo
object
1{ 2 totalSize:, // total file size got from the server 3 fileName:, // original file name 4 filePath:, // original path name 5 downloadedSize:, // the downloaded amount 6}
event download downloadInfo
object
1{ 2 totalSize:, // total file size got from the server 3 fileName:, // assigned name 4 filePath:, // download path 5 isResumed:, // if the download is a resume, 6 downloadedSize:, // the downloaded amount (only if is resumed otherwise always 0) 7}
event progress stats
object
1{ 2 name:, // file name 3 total:, // total size that needs to be downloaded in bytes 4 downloaded:, // downloaded size in bytes 5 progress:, // progress porcentage 0-100% 6 speed: // download speed in bytes 7}
event end downloadInfo
object
1{ 2 fileName:, 3 filePath:, 4 totalSize:, // total file size got from the server 5 incomplete:, // true/false if the download endend but still incomplete 6 onDiskSize, // total size of file on the disk 7 downloadedSize:, // the total size downloaded 8}
event renamed filePaths
object
1{ 2 path:, // modified path name 3 fileName:, // modified file name 4 prevPath:, // original path name 5 prevFileName:, // original file name 6}
event error error
object
1{ 2 message:, // Error message 3 status:, // Http status response if available 4 body:, // Http body response if available 5}
Name | Value |
---|---|
IDLE | 'IDLE' |
SKIPPED | 'SKIPPED' |
STARTED | 'STARTED' |
DOWNLOADING | 'DOWNLOADING' |
PAUSED | 'PAUSED' |
RESUMED | 'RESUMED' |
STOPPED | 'STOPPED' |
FINISHED | 'FINISHED' |
FAILED | 'FAILED' |
RETRY | 'RETRY' |
$ npm test
Read License for more licensing information.
Read here for more information.
No vulnerabilities found.