0.1.0 • Published 7 years ago
@fedlinker/progress v0.1.0
@fedlinker/progress
Progress bar for Node.js with nuxt/webpackbar style.

Install
npm i -S @fedlinker/progressUsage
const Progress = require('@fedlinker/progress')
let value = 0
let total = 100
const progress = new Progress({
total,
value,
head: 'client',
title: 'building modules (:percent)',
subtitle: ':value/:total modules (:time)',
description: 'node_modules/@fedlinker/progress/example.js'
})
progress.start()
let timer = setTimeout(update, 100)
function update () {
value += 1
progress.update(value)
if (value < total) {
timer = setTimeout(update, 100)
} else {
progress.stop('Done! Time: :time')
clearTimeout(timer)
}
}The :value, :total, :percent and :time above are placeholder tokens, they will be replaced with runtime values.
Options
stream: Writable stream, defualt isprocess.stderr. It must be a TTY.width: The width of progress bar, default is25.total: Total value, default is1.value: Value, default is0.color: Theme color. It could be a hex color or a normal color string.head: Head string.title: Title string.subtitle: Subtitle string.description: Description string.
Tokens
You can use tokens in head, title, subtitle and description. The tokens will be replaced with their runtime values.
These are tokens you can use:
:value: Thevalueoption.:total: Thetotaloption.:percent: Percentage ofvalue / total.:time: Spent time in processing.
Methods
.start(): Start progress..update(value | options): Update the progress bar..stop(string): Stop progress. The paramstringwill be displayed in ternimal eventually, it also accepts tokens.
License
MIT.
0.1.0
7 years ago