Comparing version 0.0.4 to 0.0.5
0.0.5 / 2012-08-07 | ||
================== | ||
* add ability to tick by zero chunks - tick(0) | ||
* fix ETA. Closes #4 [lwille] | ||
0.0.4 / 2011-11-14 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -1,2 +0,1 @@ | ||
/*! | ||
@@ -18,3 +17,3 @@ * node-progress | ||
exports.version = '0.0.4'; | ||
exports.version = '0.0.5'; | ||
@@ -71,3 +70,4 @@ /** | ||
ProgressBar.prototype.tick = function(len, tokens){ | ||
len = len || 1; | ||
if (len !== 0) | ||
len = len || 1; | ||
@@ -91,3 +91,3 @@ // swap tokens | ||
, elapsed = new Date - this.start | ||
, eta = elapsed * (1 - (this.curr / this.total)); | ||
, eta = elapsed * (this.total / this.curr - 1) | ||
@@ -94,0 +94,0 @@ complete = Array(complete).join(this.chars.complete); |
{ | ||
"name": "progress" | ||
, "version": "0.0.4" | ||
, "version": "0.0.5" | ||
, "description": "Flexible ascii progress bar" | ||
@@ -5,0 +5,0 @@ , "keywords": ["cli", "progress"] |
@@ -1,2 +0,1 @@ | ||
# node-progress | ||
@@ -6,2 +5,6 @@ | ||
## Installation | ||
npm install progress | ||
## Usage | ||
@@ -13,13 +16,15 @@ | ||
var ProgressBar = require('progress'); | ||
var bar = new ProgressBar(':bar', { total: 10 }); | ||
var timer = setInterval(function(){ | ||
bar.tick(); | ||
if (bar.complete) { | ||
console.log('\ncomplete\n'); | ||
clearInterval(timer); | ||
} | ||
}, 100); | ||
```javascript | ||
var ProgressBar = require('progress'); | ||
var bar = new ProgressBar(':bar', { total: 10 }); | ||
var timer = setInterval(function(){ | ||
bar.tick(); | ||
if (bar.complete) { | ||
console.log('\ncomplete\n'); | ||
clearInterval(timer); | ||
} | ||
}, 100); | ||
``` | ||
## Options: | ||
@@ -47,38 +52,42 @@ | ||
var ProgressBar = require('../') | ||
, https = require('https'); | ||
```javascript | ||
var ProgressBar = require('../') | ||
, https = require('https'); | ||
var req = https.request({ | ||
host: 'download.github.com' | ||
, port: 443 | ||
, path: '/visionmedia-node-jscoverage-0d4608a.zip' | ||
}); | ||
var req = https.request({ | ||
host: 'download.github.com' | ||
, port: 443 | ||
, path: '/visionmedia-node-jscoverage-0d4608a.zip' | ||
}); | ||
req.on('response', function(res){ | ||
var len = parseInt(res.headers['content-length'], 10); | ||
req.on('response', function(res){ | ||
var len = parseInt(res.headers['content-length'], 10); | ||
console.log(); | ||
var bar = new ProgressBar(' downloading [:bar] :percent :etas', { | ||
complete: '=' | ||
, incomplete: ' ' | ||
, width: 20 | ||
, total: len | ||
}); | ||
console.log(); | ||
var bar = new ProgressBar(' downloading [:bar] :percent :etas', { | ||
complete: '=' | ||
, incomplete: ' ' | ||
, width: 20 | ||
, total: len | ||
}); | ||
res.on('data', function(chunk){ | ||
bar.tick(chunk.length); | ||
}); | ||
res.on('data', function(chunk){ | ||
bar.tick(chunk.length); | ||
}); | ||
res.on('end', function(){ | ||
console.log('\n'); | ||
}); | ||
}); | ||
res.on('end', function(){ | ||
console.log('\n'); | ||
}); | ||
}); | ||
req.end(); | ||
req.end(); | ||
``` | ||
The code above will generate a progress bar that looks like this: | ||
downloading [===== ] 29% 3.7s | ||
``` | ||
downloading [===== ] 29% 3.7s | ||
``` | ||
## License | ||
@@ -88,3 +97,3 @@ | ||
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca> | ||
Copyright (c) 2011 TJ Holowaychuk `<tj@vision-media.ca>` | ||
@@ -91,0 +100,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
113
0
6574
7
93
1