codecamp

Node.js colors包

自定义控制台colors

语法高亮可帮助你管理代码的复杂性。

colors包(npm install colors)为你的控制台输出带来了类似的好处,使得你更容了解发生了什么。

它也是最常用的NPM包之一。

它向本地JavaScript字符串添加函数,以便你可以执行诸如“some string”.red之类的操作。

例子

// Loading this module modifies String for the entire process 
require("colors"); 

console.log("hello".green); // outputs green text 
console.log("world!".red); // outputs red text 
console.log("Feeling yellow".yellow); // outputs yellow text 
console.log("But you look blue".blue); // outputs yellow text 
console.log("This should cheer you up!".rainbow); // rainbow 


Node.js Moment
Node.js events事件模块
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }