Package Exports
- console-styles
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (console-styles) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
About
console-styles is a module used for applying ANSI codes to strings, this allows for customized output/logging to the console/process.stdout. This module is very similar to chalk but it has no dependencies and there is much less code as it takes advantage of ES6 features, specifically the Proxy constructor. All styles and colours can be chained and then wrapped around a specific string or logged directly to the terminal/prompt. Thanks to 1Computer for the idea and the basic structure of using proxy objects for something like this.
Comes with some TypeScript definitions.
Install
--save
is not necessary if you don't have a package.json
.
npm install --save console-styles
Example
const styler = require("console-styles");
// log underlined red text to the console
styler.red.underline.log("hola amigos");
// log black text with cyan background to the console
styler.black.bgCyan.log("wow");
// More freedom, allows for multiple styles in one line
console.log(styler.black.bgCyan("this is great Kappa", "hello"));
console.log(styler.red("nested", styler.blue("colours")));
Styles
All styles can be chained.
const styler = require("console-styles");
styler.reset.log("Removes styles");
styler.bright.log("Makes text bold/bright");
styler.bold.log("Makes text bold/bright");
styler.dim.log("Darkens text");
styler.underline.log("Underline text");
styler.reverse.log("Inverse style");
styler.inverse.log("Inverse style");
styler.black.log("Black coloured text");
styler.red.log("Red coloured text");
styler.green.log("Green coloured text");
styler.yellow.log("Yellow coloured text");
styler.blue.log("Blue coloured text");
styler.magenta.log("Magenta coloured text");
styler.cyan.log("Cyan coloured text");
styler.white.log("White coloured text");
styler.bgBlack.log("Black background text", "multiple", "params");
styler.bgRed.log("Red background text");
styler.bgGreen.log("Green background text");
styler.bgYellow.log("Yellow background text");
styler.bgBlue.log("Blue background text");
styler.bgMagenta.log("Magenta background text");
styler.bgCyan.log("Cyan background text");
styler.bgWhite.log("White background text");
There are also a bunch of convenience methods for logging purposes that also combine with the available styles
const styler = require("console-styles");
styler.trim.log(" remove whitespace ");
styler.upper.log("upper case text");
styler.lower.log("LOWER CASE TEXT");