New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

downit

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

downit - npm Package Compare versions

Comparing version 0.5.0 to 1.0.0

bin/downit

23

index.js

@@ -5,2 +5,4 @@ 'use strict'

, URL = require('url')
, http = require('http')
, https = require('https')

@@ -12,3 +14,8 @@ function download(url, dest, options) {

return new Promise((resolve, reject) => {
return new Promise((res, rej) => {
let pending = true
const resolve = (r) => (pending = false, res(r))
, reject = (e) => (pending = false, rej(e))
fs.stat(dest, (err, stat) => {

@@ -20,3 +27,3 @@ if (err && err.code !== 'ENOENT')

const req = require(parsedUrl.protocol.slice(0, -1)).request(Object.assign({
const req = (parsedUrl.protocol === 'https:' ? https : http).request(Object.assign({
method: options.method || 'GET',

@@ -28,3 +35,3 @@ headers: Object.assign({ Range: 'bytes=' + start + '-' }, options.headers)

if (res.statusCode === 416 && res.headers['content-range'] && res.headers['content-range'].slice(-2) !== '/0')
return fs.unlink(dest, () => resolve(download(url, dest, options)))
return fs.unlink(dest, () => resolve(pending && download(url, dest, options)))

@@ -35,3 +42,3 @@ if (res.statusCode >= 400)

if (res.headers.location)
return resolve(download(res.headers.location, dest, options))
return resolve(pending && download(res.headers.location, dest, options))

@@ -62,7 +69,5 @@ if (!res.headers['content-range'])

res.on('end', () => file.end())
file.on('finish', () =>
res.complete
? resolve()
: download(url, dest, options)
)
file.on('finish', () => {
resolve(!res.complete && pending && download(url, dest, options))
})
})

@@ -69,0 +74,0 @@

{
"name": "downit",
"version": "0.5.0",
"version": "1.0.0",
"description": "Resumeable downloader",
"main": "index.js",
"keywords": ["resumeable", "download", "get", "fetch", "resume", "continue", "wget"],
"keywords": [
"resumeable",
"download",
"get",
"fetch",
"resume",
"continue",
"wget"
],
"author": "Rasmus Porsager <rasmus@porsager.com>",
"repository": "porsager/downit",
"license": "WTFPL"
"license": "WTFPL",
"bin": {
"downit": "bin/downit"
}
}

@@ -20,10 +20,25 @@ # Downit - Resume downloads in node

headers: { Authorization: 'Bearer Of Good News' },
progress: (got, total) => console.log('Got', got, 'B of ', total, 'B'),
progress: (got, total) => console.log('Got ', got, 'B of ', total, 'B'),
onrequest: req => { /* The node request instance */ },
onresponse: req => { /* The node response instance */ }
onresponse: res => { /* The node response instance */ }
}).then(() => {
console.log('Downed it')
}).catch(e => {
console.error('Dropped it')
console.error('Dropped it, due to ', e)
})
```
### CLI
Downit also works on the command line.
#### Installation
```
npm i downit -g
```
#### Usage
```
downit url [dest]
```
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