0.1.1 ā€¢ Published 1 month ago

xycolors v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

xycolors šŸŒˆ

NPM version

A tiny and fast package for adding colors to your terminal output.

Based on yoctocolors

Highlights

  • Tiny
  • Fast
  • Handles nested colors
  • Tree-shakeable
  • No dependencies
  • Actively maintained

Install

npm install xycolors

Usage

import * as c from 'xycolors'

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

console.log(c.blue(`Welcome to the ${colors.magenta('xycolors')} 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

  • reset - Reset the current style.
  • bold - Make the text bold.
  • dim - Make the text have lower opacity.
  • italic - Make the text italic. (Not widely supported)
  • underline - Put a horizontal line above the text. (Not widely supported)
  • overline - Put a horizontal line below the text. (Not widely supported)
  • inverse- Invert background and foreground colors.
  • hidden - Print the text but make it invisible.
  • strikethrough - Put a horizontal line through the center of the text. (Not widely supported)

Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • redBright
  • greenBright
  • yellowBright
  • blueBright
  • magentaBright
  • cyanBright
  • whiteBright
  • blackStylize
  • blackSecondaryStylize
  • redStylize
  • redSecondaryStylize
  • greenStylize
  • greenSecondaryStylize
  • yellowStylize
  • yellowSecondaryStylize
  • blueStylize
  • blueSecondaryStylize
  • magentaStylize
  • magentaSecondaryStylize
  • pinkStylize
  • pinkSecondaryStylize
  • cyanStylize
  • cyanSecondaryStylize
  • whiteStylize
  • whiteSecondaryStylize
  • grayStylize
  • graySecondaryStylize

Background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgGray
  • bgRedBright
  • bgGreenBright
  • bgYellowBright
  • bgBlueBright
  • bgMagentaBright
  • bgCyanBright
  • bgWhiteBright

Benchmark

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

See benchmark.js.

License

MIT License Ā© 2024 xinyao27