- Display progress in a fancy way
- Easily customizable (width, fill/empty symbols, percents)
- Clear the bar on complete
const sh = require('kool-shell')
const bar = sh.progressBar({
// stop rendering and remove the bar when filled
onComplete(bar) {
bar.pause()
console.log('Done!')
}
})
// display the bar
bar.resume()
// update progress (0: empty / 1: filled)
bar.set(0)
setTimeout(() => bar.set(0.4), 1000)
setTimeout(() => bar.set(0.8), 2000)
setTimeout(() => bar.set(1), 3000)
Return a new progressBar instance
showPercents
(Boolean, default true): show or hide progress percentageclearOnPause
(Boolean, default true): The bar will be cleared oncepause()
is calledwidth
(Number, default 20) : Set the width of the bar, in charsemptySymbol
(String, default░
): Symbol used for the empty bar portionfillSymbol
(String, default▓
): Symbol used for the filled bar portiononComplete
(Function): Function called when the bar is entirely filled
progressBar.set(progress)
- Set the progress, from 0 (empty) to 1 (filled)
- You can set a value without calling
resume()
. The bar will update its progress without being displayed in the terminal.
progressBar.resume()
- Start rendering the bar
- Do not write in process.stdout when the bar is rendering, it will cause visual glitches.
progressBar.pause()
- Stop rendering the bar
- if
clearOnPause
option is set to true, the bar will be removed from the terminal