Socket
Socket
Sign inDemoInstall

download

Package Overview
Dependencies
104
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

54

index.js

@@ -18,3 +18,7 @@ 'use strict';

function Download(opts) {
this._url = [];
if (!(this instanceof Download)) {
return new Download();
}
this._get = [];
this.ware = new Ware();

@@ -41,3 +45,3 @@ this.opts = opts || {};

if (!arguments.length) {
return this._url;
return this._get;
}

@@ -50,8 +54,8 @@

opts = opts || {};
opts = assign({}, this.opts, opts);
if (file.url && file.name) {
this._url.push({ url: file.url, name: file.name, dest: dest, opts: opts });
this._get.push({ url: file.url, name: file.name, dest: dest, opts: opts });
} else {
this._url.push({ url: file, dest: dest, opts: opts });
this._get.push({ url: file, dest: dest, opts: opts });
}

@@ -106,6 +110,5 @@

var name = obj.name || path.basename(obj.url);
var opts = assign({}, self.opts, obj.opts);
var ret = [];
request.get(obj.url, opts)
request.get(obj.url, obj.opts)
.on('error', done)

@@ -124,23 +127,14 @@

self._run(res);
})
res.on('end', function () {
files.push({ url: obj.url, contents: Buffer.concat(ret) });
.on('end', function () {
files.push({ url: obj.url, contents: Buffer.concat(ret) });
if (!obj.dest) {
done();
return;
}
if (!obj.dest) {
done();
return;
}
if (opts.extract) {
return self._extract(Buffer.concat(ret), obj.dest, opts, function (err) {
if (err) {
done(err);
return;
}
done();
});
}
self._write(Buffer.concat(ret), path.join(obj.dest, name), opts, function (err) {
if (obj.opts.extract) {
return self._extract(Buffer.concat(ret), obj.dest, obj.opts, function (err) {
if (err) {

@@ -153,2 +147,11 @@ done(err);

});
}
self._write(Buffer.concat(ret), path.join(obj.dest, name), obj.opts, function (err) {
if (err) {
done(err);
return;
}
done();
});

@@ -170,3 +173,2 @@ });

* @param {Object} res
* @param {Function} cb
* @api public

@@ -173,0 +175,0 @@ */

{
"name": "download",
"version": "1.0.2",
"version": "1.0.3",
"description": "Download and extract files effortlessly",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "mocha --reporter list"
"test": "node test/test.js"
},

@@ -38,6 +38,5 @@ "files": [

"devDependencies": {
"mocha": "^1.21.4",
"nock": "^0.44.3",
"rimraf": "^2.2.5"
"ava": "0.0.4",
"nock": "^0.45.0"
}
}

@@ -32,3 +32,3 @@ # download [![Build Status](https://travis-ci.org/kevva/download.svg?branch=master)](https://travis-ci.org/kevva/download)

console.log(files);
=> [{ url: http://example.com/foo.zip, contents: <Buffer 50 4b 03 ...>, ... }]
//=> [{ url: http://example.com/foo.zip, contents: <Buffer 50 4b 03 ...> }, { ... }]
});

@@ -35,0 +35,0 @@ ```

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc