Skip to content

Instantly share code, notes, and snippets.

@ValeriiVasin
ValeriiVasin / color.js
Created December 11, 2012 19:25
Colorized output in nodejs
var color, i;
// Notice: octal literals are not allowed in strict mode.
function colorize(color, output) {
return ['\033[', color, 'm', output, '\033[0m'].join('');
}
for (i = 0; i < 100; i += 1) {
color = Math.random() > 0.9 ? 91 : 92; // 91 - red, 92 - green
process.stdout.write( colorize(color, '●') );