Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
status-bar
Advanced tools
Readme
var path = require('path');
var http = require('http');
var statusBar = require('status-bar');
var url = 'http://nodejs.org/dist/latest/node.exe';
var bar;
http.get(url, function (res) {
bar = statusBar.create({ total: res.headers['content-length'] })
.on('render', function (stats) {
process.stdout.write(
path.basename(url) + ' ' +
this.format.storage(stats.currentSize) + ' ' +
this.format.speed(stats.speed) + ' ' +
this.format.time(stats.elapsedTime) + ' ' +
this.format.time(stats.remainingTime) + ' [' +
this.format.progressBar(stats.percentage) + '] ' +
this.format.percentage(stats.percentage));
process.stdout.cursorTo(0);
});
res.pipe(bar);
}).on('error', function (err) {
if (bar) bar.cancel();
console.error(err);
});
/*
It will print something like this:
node.exe 2.8 MiB 617.5K/s 00:06 00:07 [############············] 51%
*/
pipe()
things to it!pacman
from Arch Linux:
a-file 21.8 MiB 67.9M/s 00:03 [#####···················] 22%
var statusBar = require('status-bar');
var formatFilename = function (filename) {
//80 - 59
var filenameMaxLength = 21;
if (filename.length > filenameMaxLength) {
filename = filename.slice(0, filenameMaxLength - 3) + '...';
} else {
var remaining = filenameMaxLength - filename.length;
while (remaining--) {
filename += ' ';
}
}
return filename;
};
filename = formatFilename(filename);
var bar = statusBar.create({ total: ... })
.on('render', function (stats) {
process.stdout.write(filename + ' ' +
this.format.storage(stats.currentSize) + ' ' +
this.format.speed(stats.speed) + ' ' +
this.format.time(stats.remainingTime) + ' [' +
this.format.progressBar(stats.percentage) + '] ' +
this.format.percentage(stats.percentage));
process.stdout.cursorTo(0);
});
readableStream.pipe(bar);
git clone
:
Receiving objects: 18% (56655992/311833402), 54.0 MiB | 26.7M/s
var statusBar = require('status-bar');
var bar = statusBar.create({ total: ...})
.on('render', function (stats) {
process.stdout.write('Receiving objects: ' +
this.format.percentage(stats.percentage).trim() +
' (' + stats.currentSize + '/' + stats.totalSize + '), ' +
this.format.storage(stats.currentSize).trim() + ' | ' +
this.format.speed(stats.speed).trim());
process.stdout.cursorTo(0);
});
readableStream.pipe(bar);
module.create(options) : StatusBar
Returns a new StatusBar instance.
Options:
#
.·
.The StatusBar
object inherits from a writable stream.
Events
Methods
Properties
Arguments: none.
Emitted when the transfer finishes.
Arguments: none.
Emitted when the transfer hangs up (3 seconds without receiving data). Can be emitted multiple times.
Arguments: stats
.
Emitted when the status bar needs to be rendered. All the properties of the stats
object contain raw data so you need to format them. You can use the default formatting functions.
Stats:
undefined
.StatusBar#cancel() : undefined
When you need to cancel the rendering of the status bar because the transfer has been aborted due to an error or any other reason, call to this function to clear the internal timers.
Returns a Formatter instance.
Methods
Formatter#percentage(percentage) : String
The percentage must be a number between 0 and 1. Result string length: 4.
console.log(this.format.percentage(0.5));
/*
50%
*/
Formatter#progressBar(percentage) : String
The percentage must be a number between 0 and 1. Result string length: the length configured with the option progressBarLength
.
console.log(this.format.progressBar(0.06));
/*
#·······················
*/
Formatter#speed(bytesPerSecond[, decimals]) : String
By default it shows 1 decimal. Result string length: 8 + #decimals.
console.log(this.format.speed(30098226));
/*
30.1M/s
*/
Formatter#storage(bytes[, decimals]) : String
By default it shows 1 decimal. Result string length: 9 + #decimals.
console.log(this.format.storage(38546744));
/*
36.8 MiB
*/
Formatter#time(seconds) : String
Result string length: 5 (min:sec). If seconds
is undefined it prints --:--
.
console.log(this.format.time(63));
/*
01:03
*/
FAQs
A status bar for file transfers
The npm package status-bar receives a total of 524 weekly downloads. As such, status-bar popularity was classified as not popular.
We found that status-bar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.