precisebar
v2.0.2
Published
An extremely precise progress bar
Downloads
147
Maintainers
Readme
precisebar is a low-level precise text-based progress bar for use in command-line applications.
Where most text-based progress bars use ascii characters, precisebar takes advantage of widespread unicode support to render sub-character lengths.
Why use precisebar?
- precisebar allows for smaller progress bars
- precisebar allows for highly precise progress information
- precisebar only has one dependency, chalk
Installation
yarn install precisebar
Usage
Basic usage:
const bar = require("precisebar");
const progress = 0.3; // Any number 0-1
const charWidth = 15; // Any integer value
console.log(bar.getProgress(progress, charWidth));
Advanced usage:
const bar = require("precisebar");
const progress = 0.3;
const charWidth = 15;
const beginningColor = "cyan";
const endColor = "bgGrey";
console.log(bar.getProgress(progress, charWidth, beginningColor, endColor));
Valid beginning colors:
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- blackBright (alias: gray, grey)
- redBright
- greenBright
- yellowBright
- blueBright
- magentaBright
- cyanBright
- whiteBright
- Any RGB array (ex: [255, 105, 180])
Valid end colors:
- bgBlack
- bgRed
- bgGreen
- bgYellow
- bgBlue
- bgMagenta
- bgCyan
- bgWhite
- bgBlackBright (alias: bgGray, bgGrey)
- bgRedBright
- bgGreenBright
- bgYellowBright
- bgBlueBright
- bgMagentaBright
- bgCyanBright
- bgWhiteBright
- Any RGB array (ex: [248, 248, 255])
License
Blue Oak License v1.0.0 - A modern alternative to the MIT License.