stream-progressbar
Advanced tools
Comparing version 0.0.1 to 1.0.0
24
index.js
@@ -5,15 +5,25 @@ var PassThrough = require('stream').PassThrough; | ||
module.exports = function(tokens, options) { | ||
var pt = new PassThrough(); | ||
options = options || {}; | ||
var pt = new PassThrough(); | ||
var total = options.total; | ||
pt.on('pipe', function(stream) { | ||
stream.on('response', function(res) { | ||
var total = parseInt(res.headers['content-length'], 10); | ||
options.total = total; | ||
var bar = new ProgressBar(tokens, options); | ||
var bar = new ProgressBar(tokens, options); | ||
if(total) { | ||
pt.on('data', function(chunk) { | ||
bar.tick(chunk.length); | ||
}); | ||
}); | ||
} else { | ||
stream.on('response', function(res) { | ||
var total = parseInt(res.headers['content-length'], 10); | ||
options.total = total; | ||
var bar = new ProgressBar(tokens, options); | ||
pt.on('data', function(chunk) { | ||
bar.tick(chunk.length); | ||
}); | ||
}); | ||
} | ||
}); | ||
@@ -20,0 +30,0 @@ |
{ | ||
"name": "stream-progressbar", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "Simple progress bar for node stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# stream-progressbar | ||
Simple progress bar for node stream | ||
Simple progress bar for node stream with [progress](https://www.npmjs.com/package/progress) | ||
``` sh | ||
@@ -8,9 +8,11 @@ npm install stream-progressbar | ||
``` javascript | ||
var fs = require('fs'); | ||
var request = require('request'); | ||
var progress = require('stream-progressbar'); | ||
var request = require('request'); | ||
request('http://cachefly.cachefly.net/10mb.test').pipe(progress(':bar')); | ||
request('http://cachefly.cachefly.net/10mb.test') | ||
.pipe(progress(':bar')) | ||
.pipe(fs.createWriteStream('10mb.test')); | ||
``` | ||
**Notice:** This module only supports request stream now. | ||
#### License | ||
MIT |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3937
7
38
1
18
2