Socket
Socket
Sign inDemoInstall

console-styles

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    console-styles

a styled console logger with no dependencies


Version published
Weekly downloads
31
increased by14.81%
Maintainers
1
Install size
5.61 kB
Created
Weekly downloads
 

Readme

Source

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.

Comes with some TypeScript definitions.

Install

--save is not necessary if you don't have a package.json.

npm install --save console-styles

Example

// require the module
const styler = require("console-styles");

// log red text to the console
console.log(styler.red("hola amigos"));

// log black text with cyan background to the console
console.log(styler.black.bgCyan("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");

console.log(styler.reset("Removes styles"));
console.log(styler.bright("Makes text bold/bright"));
console.log(styler.bold("Makes text bold/bright"));
console.log(styler.dim("Darkens text"));
console.log(styler.underline("Underline text"));
console.log(styler.reverse("Inverse style"));
console.log(styler.inverse("Inverse style"));
console.log(styler.black("Black coloured text"));
console.log(styler.grey("Grey coloured text"));
console.log(styler.gray("Grey coloured text"));
console.log(styler.red("Red coloured text"));
console.log(styler.green("Green coloured text"));
console.log(styler.yellow("Yellow coloured text"));
console.log(styler.blue("Blue coloured text"));
console.log(styler.magenta("Magenta coloured text"));
console.log(styler.cyan("Cyan coloured text"));
console.log(styler.white("White coloured text"));
console.log(styler.bgBlack("Black background text", "multiple", "params"));
console.log(styler.bgRed("Red background text"));
console.log(styler.bgGreen("Green background text"));
console.log(styler.bgYellow("Yellow background text"));
console.log(styler.bgBlue("Blue background text"));
console.log(styler.bgMagenta("Magenta background text"));
console.log(styler.bgCyan("Cyan background text"));
console.log(styler.bgWhite("White background text"));

Keywords

FAQs

Last updated on 03 Sep 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc