Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 2.28 KB

README.md

File metadata and controls

82 lines (56 loc) · 2.28 KB

Promise.bar

Promise.bar on NPM Build Status

Usage

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)

Alias as Promise.bar

Make PromiseBar even cuter.

Promise.bar = function() {
  return PromiseBar.all(arguments);
};

Stacked Progress Bars

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;.

Color the Progress Bar

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.

Always Below console.log Content

Progress bars will always appear under other stdout content.

All Options

Promise.bar supports much more customization than the options listed here. Please check out the full API documentation for other configurable options.