
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Kolorist is an npm package that provides utilities for styling terminal strings with colors and other text attributes. It is designed to be lightweight and easy to use, making it a great choice for adding visual enhancements to command-line applications.
Basic Color Styling
Kolorist allows you to style text with basic colors. The example demonstrates how to use red, green, and blue colors to style terminal output.
const { red, green, blue } = require('kolorist');
console.log(red('This is red text'));
console.log(green('This is green text'));
console.log(blue('This is blue text'));
Background Colors
Kolorist also supports background colors. The example shows how to apply red, green, and blue background colors to text.
const { bgRed, bgGreen, bgBlue } = require('kolorist');
console.log(bgRed('This text has a red background'));
console.log(bgGreen('This text has a green background'));
console.log(bgBlue('This text has a blue background'));
Text Attributes
In addition to colors, Kolorist can apply text attributes like bold, underline, and italic. The example demonstrates how to use these attributes.
const { bold, underline, italic } = require('kolorist');
console.log(bold('This text is bold'));
console.log(underline('This text is underlined'));
console.log(italic('This text is italicized'));
Chalk is a popular npm package for styling terminal strings. It offers a wide range of colors and text attributes, similar to Kolorist. Chalk is known for its extensive documentation and community support.
Colors is another npm package for adding color and style to terminal output. It provides a simple API for applying colors and text attributes. Compared to Kolorist, Colors has been around longer and has a larger user base.
CLI-Color is a package that provides a comprehensive set of tools for styling terminal output. It supports nested styles and complex formatting. CLI-Color is more feature-rich compared to Kolorist, but it may be overkill for simpler use cases.
Tiny library to put colors into stdin/stdout :tada:
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'
MIT
, see the license file.
1.8.0
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.
FAQs
A tiny utility to colorize stdin/stdout
The npm package kolorist receives a total of 2,142,142 weekly downloads. As such, kolorist popularity was classified as popular.
We found that kolorist demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.