Doing a bunch of tasks asynchronously with promises, and want a status indicator?
let compiles = [
compile("a.coffee"),
compile("b.coffee")
];
Promise.all(compiles).then(() => {
console.log("Compile Done!");
});
Simply replace Promise.all
with PromiseBar.all
, and watch a progress bar fill as compilations finish!
let PromiseBar = require("promise.bar");
PromiseBar.enable();
PromiseBar.all(compiles, {label: "Minify"}).then(() -> {
console.log("Compile Done!");
});
(Install PromiseBar via npm install --save promise.bar
)
Make PromiseBar even cuter.
Promise.bar = function() {
return PromiseBar.all(arguments);
};
Want to stack progress bars?
child = PromiseBar.all([], {label: "Child"});
parent = PromiseBar.all([child], {label: "Parent"});
The child will automatically be indented under the parent. Disable this for a progress bar by passing flat: false
to
PromiseBar#all
, or disable it for all progress bars with PromiseBar.conf.flat = false;
.
Add colors to your progress bars with libraries like Chalk.
let chalk = require("chalk");
PromiseBar.all([], {label: chalk.blue("Progress"), barFormat: chalk.dim.blue});
The label will be colored blue, and the progress bar will be light blue. You can provide any function to barFormat
to transform the output.
Progress bars will always appear under other stdout
content.
Promise.bar supports much more customization than the options listed here. Please check out the full API documentation for other configurable options.