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

rh-color

v1.0.5

Published

格式化console

Downloads

21

Readme

描述

  • 格式化 console

方法

log

  • 单行指定

  • description : 设置console的字体颜色和背景颜色

  • param ...keys Styles[] 样式

  • returns : function(...args) { ...args: 要打印的内容 }

color

  • 当行多次指定

  • description 指定字段颜色打印

  • param source 待打印信息[多个color结合使用时候, 不要使用呢, 隔开的写法]

  • param ...keys Styles[]

  • returns

eg:console.log(color('Reverse', 'Reverse', 'Black', 'RedBG'))

  • 若要去除每个color(...)之间的空格
  • 可用: log(color(...), color(...), ...)

使用

npm install rh-color
import { color, log } from "rh-color";

log('Grey')('Grey')
log('Black')('Black')
log('Red')('Red')
log('Green')('Green')
log('Yellow')('Yellow')
log('Blue')('Blue')
log('Magenta')('Magenta')
log('Cyan')('Cyan')
log('White')('White')
log('BlackBG')('BlackBG')
log('RedBG')('RedBG')
log('GreenBG')('GreenBG')
log('YellowBG')('YellowBG')
log('BlueBG')('BlueBG')
log('MagentaBG')('MagentaBG')
log('CyanBG')('CyanBG')
log('WhiteBG')('WhiteBG')
log('Bright')('Bright')
log('Italic')('Italic')
log('Underline')('Underline')
log('Reverse')('Reverse')
log('Hidden')('Hidden')

// 等同于

console.log(color('Grey', 'Grey'))
console.log(color('Black', 'Black'))
console.log(color('Red', 'Red'))
console.log(color('Green', 'Green'))
console.log(color('Yellow', 'Yellow'))
console.log(color('Blue', 'Blue'))
console.log(color('Magenta', 'Magenta'))
console.log(color('Cyan', 'Cyan'))
console.log(color('White', 'White'))
console.log(color('BlackBG', 'BlackBG'))
console.log(color('RedBG', 'RedBG'))
console.log(color('GreenBG', 'GreenBG'))
console.log(color('YellowBG', 'YellowBG'))
console.log(color('BlueBG', 'BlueBG'))
console.log(color('MagentaBG', 'MagentaBG'))
console.log(color('CyanBG', 'CyanBG'))
console.log(color('WhiteBG', 'WhiteBG'))
console.log(color('Bright', 'Bright'))
console.log(color('Italic', 'Italic'))
console.log(color('Underline', 'Underline'))
console.log(color('Reverse', 'Reverse'))
console.log(color('Hidden', 'Hidden'))

打印结果

浏览器使用

 <script type="module">
 //  这里next 要指定npm包的版本
  import { color, log } from 'https://cdn.jsdelivr.net/npm/rh-color@next/lib/index.esm.js'
 </script>

支持样式

  • 样式之间的冲突需要注意

| 颜色 | 代码 | 补充 | | :------- | :---------- | :----------------- | | 灰色 | Grey | | 黑色 | Black | | 红色 | Red | | 绿色 | Green | | 黄色 | Yellow | | 蓝色 | Blue | | 品红 | Magenta | | 青色 | Cyan | | 白色 | White | | 黑色背景 | BlackBG | | 红色背景 | RedBG | | 绿色背景 | GreenBG | | 换色背景 | YellowBG | | 蓝色背景 | BlueBG | | 品红背景 | MagentaBG | | 青色背景 | CyanBG | | 白色背景 | WhiteBG | | 样色重置 | Reset | | 明亮 | Bright | | 斜体 | Italic | | 下划线 | Underline | 注意中文的使用 | | 反装 | Reverse | 字体和背景颜色反转 | | 隐藏 | Hidden |