JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 262152
  • Score
    100M100P100Q173559F
  • License MIT

A simple http file downloader for node.js

Package Exports

  • node-downloader-helper

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-downloader-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-downloader-helper

NPM Version Build Status Windows Build Status

A simple http file downloader for node.js

Features:

  • No thirdparty dependecies
  • Supports pause/resume
  • Supports http/https
  • Supports http redirects
  • Usable on vanilla nodejs, electron, nwjs
  • Progress stats

Install

$ npm install --save node-downloader-helper

Usage

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();

Methods

| 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 |

Events

| 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
}

States

| Name | Value | |-------------- |---------------------------------- | | IDLE | IDLE | | STARTED | STARTED | | DOWNLOADING | DOWNLOADING | | PAUSED | PAUSED | | RESUMED | RESUMED | | STOPPED | STOPPED | | FINISHED | FINISHED | | FAILED | FAILED |

Test

$ npm test

License

Read License for more licensing information.

Contributing

Read here for more information.

TODO

  • Better code testing