Socket
Socket
Sign inDemoInstall

node-downloader-helper

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-downloader-helper - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

9

dist/index.js

@@ -75,2 +75,3 @@ 'use strict';

_this.__isResumable = false;
_this.__isRedirected = false;
_this.__statsEstimate = {

@@ -95,4 +96,6 @@ time: 0,

return new Promise(function (resolve, reject) {
_this2.emit('start');
_this2.__setState(_this2.__states.STARTED);
if (!_this2.__isRedirected) {
_this2.emit('start');
_this2.__setState(_this2.__states.STARTED);
}
_this2.__fileStream = fs.createWriteStream(_this2.__filePath, _this2.__isResumed ? { 'flags': 'a' } : {});

@@ -109,2 +112,3 @@ _this2.__request = _this2.__protocol.request(_this2.__options, function (response) {

if (response.statusCode > 300 && response.statusCode < 400 && response.headers.hasOwnProperty('location') && response.headers.location) {
_this2.__isRedirected = true;
_this2.__initProtocol(response.headers.location);

@@ -135,2 +139,3 @@ _this2.__fileStream.close();

_this2.__isResumed = false;
_this2.__isRedirected = false;
_this2.__setState(_this2.__states.DOWNLOADING);

@@ -137,0 +142,0 @@ _this2.__statsEstimate.time = new Date();

{
"name": "node-downloader-helper",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple http file downloader for node.js",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

# node-downloader-helper
[![NPM Version](https://img.shields.io/npm/v/hgouveia/node-download-helper.svg?style=flat-square "npm version")](https://www.npmjs.com/package/node-download-helper)
[![Build Status](https://img.shields.io/travis/hgouveia/node-download-helper/master.svg?style=flat-square "Build Status")](https://travis-ci.org/hgouveia/node-download-helper)
[![Windows Build Status](https://img.shields.io/appveyor/ci/hgouveia/node-download-helper/master.svg?label=windows&style=flat-square "Windows Build Status")](https://ci.appveyor.com/project/hgouveia/node-download-helper)
[![NPM Version](https://img.shields.io/npm/v/hgouveia/node-downloader-helper.svg?style=flat-square "npm version")](https://www.npmjs.com/package/node-downloader-helper)
[![Build Status](https://img.shields.io/travis/hgouveia/node-downloader-helper/master.svg?style=flat-square "Build Status")](https://travis-ci.org/hgouveia/node-downloader-helper)
[![Windows Build Status](https://img.shields.io/appveyor/ci/hgouveia/node-downloader-helper/master.svg?label=windows&style=flat-square "Windows Build Status")](https://ci.appveyor.com/project/hgouveia/node-downloader-helper)

@@ -11,2 +11,3 @@

Features:
- No thirdparty dependecies
- Supports pause/resume

@@ -16,2 +17,3 @@ - Supports http/https

- Usable on vanilla nodejs, electron, nwjs
- Progress stats

@@ -21,3 +23,3 @@ ## Install

```
$ npm install --save node-download-helper
$ npm install --save node-downloader-helper
```

@@ -30,3 +32,3 @@

```javascript
const { DownloaderHelper } = require('node-download-helper');
const { DownloaderHelper } = require('node-downloader-helper');
const dl = new DownloaderHelper('http://ipv4.download.thinkbroadband.com/1GB.zip', __dirname);

@@ -63,3 +65,3 @@

progress stats object
progress `stats` object
```javascript

@@ -86,3 +88,2 @@ {

| FAILED | FAILED |
| stateChanged | triggered when the state changes |

@@ -104,3 +105,3 @@ ## Test

## TODO
- Better testing
- Better code testing
- Support custom file name

@@ -37,2 +37,3 @@ import { EventEmitter } from 'events';

this.__isResumable = false;
this.__isRedirected = false;
this.__statsEstimate = {

@@ -54,4 +55,6 @@ time: 0,

return new Promise((resolve, reject) => {
this.emit('start');
this.__setState(this.__states.STARTED);
if (!this.__isRedirected) {
this.emit('start');
this.__setState(this.__states.STARTED);
}
this.__fileStream = fs.createWriteStream(this.__filePath,

@@ -70,2 +73,3 @@ this.__isResumed ? { 'flags': 'a' } : {});

response.headers.hasOwnProperty('location') && response.headers.location) {
this.__isRedirected = true;
this.__initProtocol(response.headers.location);

@@ -97,2 +101,3 @@ this.__fileStream.close();

this.__isResumed = false;
this.__isRedirected = false;
this.__setState(this.__states.DOWNLOADING);

@@ -99,0 +104,0 @@ this.__statsEstimate.time = new Date();

@@ -35,3 +35,5 @@ const { DownloaderHelper } = require('../dist');

expect(function () {
const dl = new DownloaderHelper(downloadURL, 'Z:/download');
const home = require('os').homedir();
const nonExistingPath = home + '/dh_' + new Date().getTime();
const dl = new DownloaderHelper(downloadURL, nonExistingPath);
}).to.throw('Destination Folder must exist');

@@ -38,0 +40,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc