1.0.5 • Published 2 years ago

rh-color v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

描述

  • 格式化 console

方法

log

  • 单行指定

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

  • param ...keys Styles[] 样式
  • returns : function(...args) { ...args: 要打印的内容 }

color

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'))

打印结果

npm.io

浏览器使用

 <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
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago