Home

Awesome

<sup>yoctocolors šŸŒˆ</sup>

The smallest and fastest command-line coloring package on the internet

Check out Chalk if you want something more mature and comprehensive.

Highlights

Install

ESM:

npm install yoctocolors

Or CommonJS:

npm install yoctocolors-cjs

Usage

import colors from 'yoctocolors';

console.log(colors.red('Yo!'));

console.log(colors.blue(`Welcome to the ${colors.green('yoctocolors')} package!`));

You can also import colors as named imports:

import {red, blue, green} from 'yoctocolors';

console.log(red('Yo!'));

console.log(blue(`Welcome to the ${green('yoctocolors')} package!`));

This package supports basic color detection. Colors can be forcefully enabled by setting the FORCE_COLOR environment variable to 1 and can be forcefully disabled by setting NO_COLOR or NODE_DISABLE_COLORS to any value. More info.

Styles

Modifiers

Colors

Background colors

Prior art

Yes

Benchmark

$ ./benchmark.js
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ (index) ā”‚ library        ā”‚ ops/sec     ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ 0       ā”‚ 'yoctocolors'  ā”‚ '8,000,000' ā”‚
ā”‚ 1       ā”‚ 'colorette'    ā”‚ '8,000,000' ā”‚
ā”‚ 2       ā”‚ 'picocolors'   ā”‚ '8,000,000' ā”‚
ā”‚ 3       ā”‚ 'nanocolors'   ā”‚ '5,988,024' ā”‚
ā”‚ 4       ā”‚ 'chalk'        ā”‚ '4,807,692' ā”‚
ā”‚ 5       ā”‚ 'kleur/colors' ā”‚ '4,807,692' ā”‚
ā”‚ 6       ā”‚ 'kleur'        ā”‚ '4,784,689' ā”‚
ā”‚ 7       ā”‚ 'ansi-colors'  ā”‚ '2,178,649' ā”‚
ā”‚ 8       ā”‚ 'cli-color'    ā”‚ '585,138'   ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

See benchmark.js.

FAQ

What is yocto?

It was the smallest official unit prefix in the metric system until 2022. Much smaller than nano.

Related