
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
clui-progressbar
Advanced tools
Simple terminal progress bar, backed by clui-live
npm install --save clui-progressbar
You can call the .setState()
method when updating more than just the progress, or simple set the handly .percentage
property on the object.
import { LiveProgressBar } from 'clui-live';
const progressbar = new LiveProgressBar( { title: 'Long running task...' } );
for ( let i = 0; i < 100; i++ ) {
progressbar.percentage = i;
await sleepRandom();
}
for ( let i = 0; i < 100; i++ ) {
progressbar.setState( {
percentage: i,
rightLabel: 'Some other stat (like speed)'
} );
await sleepRandom();
}
// The progressbar is a live area, so we can use any of the habitual methods on it, like closing
progressbar.close();
The component LiveProgressBar
extends the LiveComponent
, which in turn extends the LiveArea
class.
interface ProgressBarState {
// Shown on the line above the progress bar
title ?: string;
// A value between 0 and 100. Values outside of this range are clamped.
percentage : number;
// Shown on the left side of the progressbar
leftLabel ?: string;
// Shown on the right side of the progressbar
rightLabel ?: string;
}
Creates a LiveProgressBar. Optionaly accepts an initial state.
Is an alias to .state.progress
when getting, and to .setState( { progress: value } )
when setting.
Holds the current state of the component. Should not be updated manually, as doing so won't not refresh the terminal
Allows to define a max width for the progress bar (including any labels it might have). By default it's value is infinity, which means the progress bar tries to fit the entire terminal's width.
Hooks this component to the global LiveContainer
. Useful when there may be lines written to the terminal while the progress bar is showing, which would traditionally cause the output to become a mess (since the cursor would now be in a different position).
Calling this method monkey patches some methods (like console.log
) to account for this type of sittuations.
Can be called to clear the output of the progress bar from the screen. There is no need to manually call this method
when updating the progress bar. However it can come in handy if we don't want the progress bar to remain visible after it has finished (must be called before .close()
).
Should be called when the progress bar is finished and won't be used any more, to release resources
FAQs
Simple terminal progress bar, backed by clui-live
We found that clui-progressbar 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
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.