Socket
Socket
Sign inDemoInstall

kolorist

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kolorist

A tiny utility to colorize stdin/stdout


Version published
Weekly downloads
1.2M
increased by1.33%
Maintainers
1
Install size
49.8 kB
Created
Weekly downloads
 

Changelog

Source

1.8.0

Minor Changes

  • 737ef18: Add support for 24bit TrueColor detection.

    This is supported in nearly every modern terminals these days. The exception to that is the built in Terminal app on macOS and CI systems. TrueColor values are automatically converted to Ansi 256 when TrueColor isn't supported, but Ansi 256 is. The only case where I found that in practice was with Terminal.app on macOS which only supports Ansi 256.

Readme

Source

kolorist

Tiny library to put colors into stdin/stdout :tada:

Screenshot of terminal colors

Usage

npm install --save-dev kolorist
import { red, cyan } from 'kolorist';

console.log(red(`Error: something failed in ${cyan('my-file.js')}.`));

You can also disable or enable colors globally via the following environment variables:

  • disable:

    • NODE_DISABLE_COLORS
    • NO_COLOR
    • TERM=dumb
    • FORCE_COLOR=0
  • enable:

    • FORCE_COLOR=1
    • FORCE_COLOR=2
    • FORCE_COLOR=3

On top of that you can disable colors right from node:

import { options, red } from 'kolorist';

options.enabled = false;
console.log(red('foo'));
// Logs a string without colors

You can also strip colors from a string:

import { red, stripColors } from 'kolorist';

console.log(stripColors(red('foo')));
// Logs 'foo'

License

MIT, see the license file.

FAQs

Last updated on 22 Apr 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