国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Node.js npm colors

2019-11-08 20:12:05
字體:
供稿:網(wǎng)友

譯自 https://www.npmjs.com/package/colors

colors

get colors in your node.js console

在你的 node.js 控制臺中獲取顏色

get color and style in your node.js console(在你的 node.js 控制臺中獲取顏色和風(fēng)格)

這里寫圖片描述

安裝

npm install colors

colors and styles(顏色和風(fēng)格)

text colors(文本顏色)

black(黑色)red(紅色)green(綠色)yellow(黃色)blue(藍(lán)色)magenta(品紅/洋紅/紫紅)cyan(青色)white(白色)gray(灰色)grey(灰色)

background colors(背景顏色)

bgBlack(黑色)bgRed(紅色)bgGreen(綠色)bgYellow(黃色)bgBlue(藍(lán)色)bgMagenta(品紅/洋紅/紫紅)bgCyan(青色)bgWhite(白色)

styles(風(fēng)格)

reset(重置)bold(加粗)dim(暗淡)【無效】italic(斜體)【無效】underline(下劃線)【無效】inverse(反色)【無效】hidden(隱藏)【無效】strikethrough(刪除線)【無效】

extras(額外項(xiàng))

rainbow(彩虹 - 紅,黃,綠,藍(lán),紫紅,)zebra(有斑紋的)【無效】america(美國國旗顏色 - 紅,白,藍(lán))trap(圈套 - 亂碼)random(隨機(jī)顏色)

【無效】指的是在 Win10 下的測試結(jié)果

Usage(使用)

By popular demand, colors now ships with two types of usages!

應(yīng)大眾的要求,colors現(xiàn)在提供了兩種使用方式!

The super nifty way

超級漂亮的方式

var colors = require('colors');console.log('hello'.green); // outputs green text console.log('i like cake and pies'.underline.red) // outputs red underlined text console.log('inverse the color'.inverse); // inverses the color console.log('OMG Rainbows!'.rainbow); // rainbow console.log('Run the trap'.trap); // Drops the bass(降低音)

在 Win10 下測試發(fā)現(xiàn):underline、inverse、trap 均無效。

這里寫圖片描述

or a slightly less nifty way which doesn’t extend String.PRototype

或者一個沒有繼承 String.prototype 的稍微不那么漂亮的方式

var colors = require('colors/safe');console.log(colors.green('hello')); // outputs green text console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text console.log(colors.inverse('inverse the color')); // inverses the color console.log(colors.rainbow('OMG Rainbows!')); // rainbow console.log(colors.trap('Run the trap')); // Drops the bass

I prefer the first way. Some people seem to be afraid of extending String.prototype and prefer the second way.

我更喜歡第一種方式。相當(dāng)多的人看起來害怕繼承 String.prototype 并且更喜歡第二種方式。

If you are writing good code you will never have an issue with the first approach. If you really don’t want to touch String.prototype, the second usage will not touch String native object.

如果你的編碼能力較好,那么對第一種方式將不會有任何問題。如果你實(shí)在不想接觸 String.prototype,第二種使用方式將不會接觸到字符串的對象。

Disabling Colors(禁用 colors)

To disable colors you can pass the following arguments in the command line to your application:

你可以在命令行中通過傳遞如下的參數(shù)到你的應(yīng)用程序來禁用 colors:

node myapp.js -no-color

Console.log string substitution(控制臺打印替換后的字符串)

var name = 'Marak';console.log(colors.green('Hello %s'), name);// outputs -> 'Hello Marak'

Custom themes(自定義主題)

Using standard API(使用標(biāo)準(zhǔn)的 API)

var colors = require('colors');colors.setTheme({ silly: 'rainbow', input: 'grey', verbose: 'cyan', prompt: 'grey', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', debug: 'blue', error: 'red'});// outputs red text console.log("this is an error".error);// outputs yellow text console.log("this is a warning".warn);

Using string safe API(使用字符串安全的 API)

var colors = require('colors/safe');// set single property var error = colors.red;error('this is red');// set theme colors.setTheme({ silly: 'rainbow', input: 'grey', verbose: 'cyan', prompt: 'grey', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', debug: 'blue', error: 'red'});// outputs red text console.log(colors.error("this is an error"));// outputs yellow text console.log(colors.warn("this is a warning"));

You can also combine them:

你也可以將他們合并:

var colors = require('colors');colors.setTheme({ custom: ['red', 'underline']});console.log('test'.custom);

Protip: There is a secret undocumented style in colors. If you find the style you can summon him.

提示:colors 中有一個秘密的無明文規(guī)定的風(fēng)格。如果你發(fā)現(xiàn)了這種風(fēng)格,你就可以召喚它。

Protip 是新一代的 jQuery 提示插件。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 沙湾县| 武宣县| 南陵县| 仁寿县| 梨树县| 大埔区| 清水县| 堆龙德庆县| 金坛市| 师宗县| 壤塘县| 江口县| 姜堰市| 新绛县| 乌兰察布市| 张家口市| 东宁县| 汝南县| 阿尔山市| 丘北县| 武平县| 晋宁县| 昌江| 垫江县| 荃湾区| 沙湾县| 紫阳县| 依安县| 新营市| 同心县| 夹江县| 三门县| 盘山县| 洪湖市| 大兴区| 兴化市| 玉山县| 沾益县| 抚宁县| 永清县| 宝鸡市|