Pretty printing for console. NB: Only tested on Mac.
var printer = require('sc-printer');
All below printing functions take a single string argument. Include "\n" to create a new line.
printer.black()
printer.red()
printer.green()
printer.yellow()
printer.blue()
printer.magenta()
printer.cyan()
printer.orange()
printer.purple()
printer.white()
printer.redBright()
printer.greenBright()
printer.yellowBright()
printer.blueBright()
printer.magentaBright()
printer.cyanBright()
printer.orangeBright()
printer.purpleBright()
printer.gray1()
printer.gray2()
printer.gray3()
printer.gray4()
printer.gray5()
printer.gray6()
printer.gray7()
printer.gray8()
printer.gray9()
printer.gray10()
printer.gray11()
printer.gray12()
printer.gray13()
printer.gray14()
printer.gray15()
printer.gray16()
printer.gray17()
printer.gray18()
printer.gray19()
printer.gray20()
printer.gray21()
printer.gray22()
printer.gray23()
printer.bgWhite()
printer.bgBlack()
printer.bgRed()
printer.bgGreen()
printer.bgYellow()
printer.bgBlue()
printer.bgMagenta()
printer.bgCyan()
printer.bgRedBright()
printer.bgGreenBright()
printer.bgYellowBright()
printer.bgBlueBright()
printer.bgMagentaBright()
printer.bgCyanBright()
printer.blink()
printer.bold()
printer.dim()
printer.underline()
Colors and styles can be chained together, starting with the color, followed by
an optional background color, followed by optional styles. eg,
printer.red.bold()
printer.red.bgBlue.bold.underline()
All styles can be combined in any order. eg,
printer.bold.underline()
printer.red.dim.bold()
Return a string, as opposed to outputting to the console, by adding noprint()
to the end of any style chain.
printer.random()
Prints a string with a random color for each character.
The Progress
function animates printing of a progress message and provides
methods to indicate success or error.
printer.Progress(msg [,ticker][,fn])
Shows an animated progress message in console.
msg {String} Initial message to display.
ticker {String[]} [optional] Elements for animation loop. Defaults to ["", ".", "..", "..."].
fn {Function} [optional] Formatting function. Defaults to printer.white()
.
Returns: A Progress
object with additional methods defined:
reset(msg [,fn])
Resets progress message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.white()
.
Returns: The Progress
object.
success(msg [,fn])
Stops animated progress message and displays success message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.green()
.
Returns: The Progress
object.
error(msg [,fn])
Stops animated progress message and displays error message.
msg {String} Message to display.
fn {Function} [optional] Formatting function. Defaults to printer.red()
.
Returns: The Progress
object.
var printer = require('sc-printer');
var progress = new printer.Progress('Doing something');
progress.success('Something succeeded.');
progress.error('Something failed.');
progress.reset('Doing something else in blue.', printer.blue);