Socket
Socket
Sign inDemoInstall

progress

Package Overview
Dependencies
0
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

3

index.js

@@ -1,2 +0,1 @@

module.exports = require('./lib/node-progress');
module.exports = require('./lib/node-progress');

@@ -15,3 +15,3 @@ /*!

* Initialize a `ProgressBar` with the given
* `fmt` string and `options`.
* `fmt` string and `options` or `total`.
*

@@ -37,3 +37,3 @@ * Options:

* @param {String} fmt
* @param {Object} options
* @param {Object|Number} options or total
* @api public

@@ -52,5 +52,12 @@ */

options = options || {};
if ('string' != typeof fmt) throw new Error('format required');
if ('number' != typeof options.total) throw new Error('total required');
if (typeof(options) == 'number') {
var total = options;
options = {};
options.total = total;
} else {
options = options || {};
if ('string' != typeof fmt) throw new Error('format required');
if ('number' != typeof options.total) throw new Error('total required');
}
this.fmt = fmt;

@@ -112,7 +119,11 @@ this.curr = 0;

var percent = (this.curr >= this.total) ? 100 : this.curr / this.total * 100
, complete = Math.round(this.width * (this.curr / this.total))
var ratio = this.curr / this.total;
ratio = Math.min(Math.max(ratio, 0), 1);
var percent = ratio * 100
, complete = Math.round(this.width * ratio)
, incomplete
, elapsed = new Date - this.start
, eta = (percent == 100) ? 0 : elapsed * (this.total / this.curr - 1)
, eta = (percent == 100) ? 0 : elapsed * (this.total / this.curr - 1);
complete = Array(complete).join(this.chars.complete);

@@ -126,3 +137,3 @@ incomplete = Array(this.width - complete.length).join(this.chars.incomplete);

.replace(':elapsed', isNaN(elapsed) ? "0.0" : (elapsed / 1000).toFixed(1))
.replace(':eta', isNaN(eta) ? "0.0" : (eta / 1000).toFixed(1))
.replace(':eta', (isNaN(eta) || !isFinite(eta)) ? "0.0" : (eta / 1000).toFixed(1))
.replace(':percent', percent.toFixed(0) + '%');

@@ -154,7 +165,7 @@

ProgressBar.prototype.update = function(ratio) {
ProgressBar.prototype.update = function(ratio, tokens) {
var goal = Math.floor(ratio * this.total);
var delta = goal - this.curr;
this.tick(delta);
this.tick(delta, tokens);
};

@@ -161,0 +172,0 @@

{
"name": "progress"
, "version": "1.1.2"
, "version": "1.1.3"
, "description": "Flexible ascii progress bar"

@@ -5,0 +5,0 @@ , "keywords": ["cli", "progress"]

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc