A command line progress bar for NodeJS.
import { makeProgressBar } from 'yaprog';
const bar = makeProgressBar(`uploading [:bar] :current/:total :custom`, 100);
// set
bar.update(10, { custom: 'replacement text' });
// interrupt the bar and log some text
bar.interrupt(`Some log message here!`);
interface ProgressBarOptions {
completeChar?: string; // defaults to '█'
incompleteChar?: string; // defaults to '░'
renderThrottle?: number; // defaults to 16ms (60fps)
start?: number; // defaults to Date.now()
stream?: NodeJS.WriteStream; // defaults to process.stderr
total?: number; // defaults to 0
width?: number; // defaults to 40
}
interface ProgressBar {
progress: number;
total: number;
tokens: ProgressBarTokens;
clear(): void;
log(message: string, tokens?: ProgressBarTokens): void;
render(force?: boolean, tokens?: ProgressBarTokens): void;
update(current: number, total?: number, tokens?: ProgressBarTokens): void;
update(current: number, tokens: ProgressBarTokens): void;
}
interface ProgressBarTokens {
[key: string]: any;
}
This is based on progress, but simplifies the interface and fixes some bugs.