Skip to content

Instantly share code, notes, and snippets.

@ydnax
Created July 17, 2011 23:24
Show Gist options
  • Save ydnax/1088232 to your computer and use it in GitHub Desktop.
Save ydnax/1088232 to your computer and use it in GitHub Desktop.
colours the string of a number red if negative and green for positive. for bg=1 the background.
var clc = require('cli-color');
var colkeys =new Array(2);
colkeys[0] =new Array();
colkeys[1] =new Array();
colkeys[0][0]=clc.red;
colkeys[0][1]=clc.green;
colkeys[1][0]=clc.bgRed;
colkeys[1][1]=clc.bgGreen;
exports.gCol=function(str, bg){
return mat[bg?1:0][str[0]=='-'?0:1](str);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment