Socket
Socket
Sign inDemoInstall

@js-bits/log-in-color

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @js-bits/log-in-color

Colorful console logging


Version published
Maintainers
1
Created

Readme

Source

Colorful console logging

Add colors to your console output

Installation

Install with npm:

npm install @js-bits/log-in-color

Install with yarn:

yarn add @js-bits/log-in-color

Import where you need it:

import { green /* black, red, yellow, blue, magenta, cyan, white */, css } from '@js-bits/log-in-color';

or require for CommonJS:

const { green /* black, red, yellow, blue, magenta, cyan, white */, css } = require('@js-bits/log-in-color');

How to use

console.log(green('this message is green')); // this message is green

or

console.log(green`Now: ${new Date()}`); // Now: Sun Jun 27 2021 11:38:15 GMT-0400 (Eastern Daylight Time)

or

console.log(`RGB: ${red`red`}; ${green`green`}; ${blue`blue`}.`); // RGB: red; green; blue.

The approach above works in Chrome, Edge and Node.js. All browsers should support a little different format:

console.log(...css(`RGB: ${red`red`}; ${green`green`}; ${blue`blue`}.`)); // RGB: red; green; blue.

Use provided css() function with a spread operator to convert colored string into a list of CSS styles.

Keywords

FAQs

Last updated on 09 Jun 2023

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