sc-printer v1.1.28
README
Pretty printing for console. NB: Only tested on Mac.
Usage
var printer = require('sc-printer');
Functions
All below printing functions take a single string argument. Include "\n" to create a new line.
Foreground Colors
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()
Background Colors
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()
Styles
printer.blink()printer.bold()printer.dim()printer.underline()
Combining Colors and Styles
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()
Returning Strings
Return a string, as opposed to outputting to the console, by adding noprint() to the end of any style chain.
Random Character Colors
printer.random()
Prints a string with a random color for each character.
Process Progress
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.
Example
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);
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago