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

progbar

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

progbar - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

.jshintrc

75

lib/progbar.js

@@ -8,3 +8,8 @@ /*

var mod_tty = require('tty');
var mod_stream = require('stream');
if (!mod_stream.Transform) {
mod_stream = require('readable-stream');
}
var mod_assert = require('assert-plus');

@@ -245,4 +250,4 @@ var mod_sprintf = require('sprintf');

'options.maxdrawfreq > 0');
self.pb_drawperiod = Math.floor((1 / options.maxdrawfreq)
* 1000);
self.pb_drawperiod = Math.floor((1 / options.maxdrawfreq) *
1000);
} else {

@@ -253,4 +258,6 @@ self.pb_drawperiod = 500; /* 2 Hz */

self.pb_lastdrawwidth = 0;
self.pb_startat = +Date.now();
self.pb_startat = Date.now();
self.pb_readings = 0;
self.pb_stream = null;
}

@@ -335,2 +342,56 @@

ProgressBar.prototype.stream = function
stream(stream_opts)
{
var self = this;
if (self.pb_stream === null) {
if (!stream_opts) {
/*
* If the user does not pass in stream options,
* create a basic options field without any buffering.
*/
stream_opts = {
highWaterMark: 0
};
}
/*
* Detect if the user requested an Object Mode stream or not.
*/
var was_object_mode = false;
if (stream_opts.objectMode) {
was_object_mode = true;
}
self.pb_stream = new mod_stream.Transform(stream_opts);
self.pb_stream._transform = function (data, _, done) {
this.push(data);
if (was_object_mode) {
/*
* Each _transform() call represents one
* object in the stream.
*/
self.advance(1);
} else {
/*
* Each _transform() call should receive
* either a Buffer or a String, both of
* which ought to have a numeric length
* property.
*/
mod_assert.number(data.length, 'data.length');
self.advance(data.length);
}
done();
};
self.pb_stream._flush = function (done) {
self.end();
done();
};
}
return (self.pb_stream);
};
ProgressBar.prototype.end = function

@@ -381,3 +442,3 @@ end()

self.advance(0);
}
};

@@ -403,3 +464,3 @@ ProgressBar.prototype.advance = function

var now = +Date.now();
var now = Date.now();
if (now - self.pb_lastdrawtime > self.pb_drawperiod)

@@ -426,3 +487,3 @@ self.draw();

var etastr = '';
var now = +Date.now();
var now = Date.now();
if ((self.pb_nosize || self.pb_size > 0) && self.pb_readings > 5 &&

@@ -477,3 +538,3 @@ (now - self.pb_startat) > WARMUP_DELAY) {

self.pb_lastdrawwidth = filestr.length + bar.length + infostr.length;
self.pb_lastdrawtime = +Date.now();
self.pb_lastdrawtime = Date.now();
};

@@ -480,0 +541,0 @@

5

package.json
{
"name": "progbar",
"author": "Joshua M. Clulow <jmc@joyent.com>",
"version": "0.1.0",
"version": "1.0.0",
"description": "terminal progress bar",

@@ -15,3 +15,4 @@ "main": "./lib/progbar.js",

"assert-plus": "~0.1.5",
"sprintf": "~0.1.3"
"sprintf": "~0.1.3",
"readable-stream": "~1.0.27-1"
},

@@ -18,0 +19,0 @@

@@ -35,2 +35,10 @@ # node-progbar

});
/*
* You may also use the stream() method to get a passthrough stream
* that you may pipe your data through. The bar will advance with
* the passage of bytes through the stream, and end() will be called
* at the end of the stream.
*/
input_stream.pipe(bar.stream()).pipe(output_stream);
```
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