npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xycolors

v0.1.2

Published

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

Downloads

54,352

Readme

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

TrueColor

You can use the hex or rgb format.

Foreground function: hex() rgb() Background function: bgHex() bgRgb()

import { bgHex, bgRgb, hex, rgb } from 'xycolors'

// foreground color
hex('#E0115F')('Ruby')
hex('#96C')('Amethyst')
rgb(224, 17, 95)('Ruby')

// background color
bgHex('#E0115F')('Ruby')
bgHex('#96C')('Amethyst')
bgRgb(224, 17, 95)('Ruby')

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