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

@deox/clc

v0.5.0

Published

Console log colors helper for simple lightweight useage, no external dependencies.

Downloads

79

Readme

console-log-colors

console-log-colors

NPM version node version npm download GitHub issues GitHub forks GitHub stars

Console log colors helper for simple lightweight useage. No external dependencies. It supports use in Node.js and Browser(Since Chrome 69) environments.

Please use chalk for complex requirements.

INSTALL

npm install console-log-colors

USAGE/API

Examples:

const { color, log, red, green, cyan, cyanBright } = require('console-log-colors');
// or use import
import { color, log, red, green, cyan, cyanBright } from 'console-log-colors';

// ansi colors
console.log(green('This is a green string!'));
console.log(color.green('This is a green string!'));
console.log(color('This is a green string!', 'green'));

// chained styles
console.log(cyan.bgRed.bold.underline('Hello world!'));

// log
log('This is a green string!', 'green');
log.green('This is a green string!', 'This is a green string!');

// helpers
console.log('isSupported:', clc.isSupported());
clc.disable();
console.log('isSupported(after disabled):', clc.isSupported());
clc.enable();
console.log('isSupported(after enabled):', clc.isSupported());

const greenstr = clc.green('This is a green string!');
const striped = clc.strip(greenstr);
console.log(greenstr, ' ==> [striped]', striped);

Chained colors

import { cyan } from 'console-log-colors';

console.log(cyan.bgRed.bold.underline('Hello world!'));
console.log(bold.cyan.bgRed.underline('Hello world!'));

Nested

import { red, white, gray } from 'console-log-colors'; // import { red, white, gray } from '@deox/clc';

console.log(
  red(`a red ${white('white')} red ${red('red')} red ${gray('gray')} red ${red('red')} red ${red('red')}`)
);

ANSI256

Support ansi256 colors. For example:

import { c250 } from 'console-log-colors'; // import { c250 } from '@deox/clc';

console.log(c250.bg129(' ANSI256: color 250 and background 129 '));

API

color[color type](string)

import { color } from 'console-log-colors'; // import { color } from '@deox/clc';

console.log(color.red('red'), color.green('green'), color.cyanBright('cyanBright'));

log[color type](str)

import { log } from 'console-log-colors'; // import { log } from '@deox/clc';

log.red('red text');
log.green('green text');
log.cyanBright('cyanBright text', 'cyanBright text2');

ALL Color Types => color.list

Object.keys(color.list).forEach(function (colorType) {
    log[colorType](colorType);
});

Styles

modifier:

  • reset
  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough

color:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • grey

Bright color:

  • redBright
  • greenBright
  • yellowBright
  • blueBright
  • magentaBright
  • cyanBright
  • whiteBright

bgColor:

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite

bgColor - legacy styles for colors pre version:

  • blackBG
  • redBG
  • greenBG
  • yellowBG
  • blueBG
  • magentaBG
  • cyanBG
  • whiteBG

Bright bgColor:

  • bgBlackBright
  • bgRedBright
  • bgGreenBright
  • bgYellowBright
  • bgBlueBright
  • bgMagentaBright
  • bgCyanBright
  • bgWhiteBright

ANSI256:

  • c<0~255>
  • bg<0~255>

Benchmarks

npm run benchmark

Output reference:

# All Colors
+ console-log-colors x 1,713,611 ops/sec ±1.35% (88 runs sampled))
  ansi-colors        x 361,503 ops/sec ±1.15% (89 runs sampled))
  cli-color          x 61,993 ops/sec ±1.53% (91 runs sampled)
  picocolors         x 1,458,754 ops/sec ±1.14% (90 runs sampled)
  colorette          x 441,998 ops/sec ±1.19% (92 runs sampled)
  chalk              x 922,968 ops/sec ±1.30% (91 runs sampled)d)
  kleur              x 1,162,681 ops/sec ±1.46% (87 runs sampled)
  yoctocolors        x 345,921 ops/sec ±1.07% (91 runs sampled)
  kolorist           x 345,567 ops/sec ±0.69% (93 runs sampled)

# Chained colors
+ console-log-colors x 105,119 ops/sec ±2.13% (92 runs sampled))
  ansi-colors        x 36,412 ops/sec ±1.31% (91 runs sampled)
  cli-color          x 28,733 ops/sec ±1.10% (90 runs sampled)
  chalk              x 479,833 ops/sec ±0.82% (93 runs sampled)
  kleur              x 74,308 ops/sec ±2.06% (75 runs sampled))

# Nested colors
+ console-log-colors x 193,483 ops/sec ±1.20% (88 runs sampled)
  ansi-colors        x 97,122 ops/sec ±1.21% (89 runs sampled))
  cli-color          x 25,077 ops/sec ±0.97% (93 runs sampled)
  picocolors         x 191,207 ops/sec ±1.22% (86 runs sampled)
  colorette          x 179,415 ops/sec ±1.37% (88 runs sampled)
  chalk              x 136,924 ops/sec ±1.04% (90 runs sampled)
  kleur              x 166,470 ops/sec ±1.23% (87 runs sampled)
  kolorist           x 150,592 ops/sec ±1.33% (90 runs sampled)

References

License

console-log-colors is released under the MIT license.

该插件由志文工作室开发和维护。