Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 590850245b2fde5d38bf01812c7b692d43fbe519 @einaros committed Dec 10, 2011
Showing with 57 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +3 −0 example.js
  3. +16 −0 package.json
  4. +31 −0 tinycolor.js
@@ -0,0 +1,7 @@
+npm-debug.log
+node_modules
+history/
+cache/
+.*.swp
+.lock-wscript
+build/
@@ -0,0 +1,3 @@
+require('./tinycolor');
+console.log('this should be red and have an underline!'.grey.underline);
+console.log('this should have a blue background!'.bgBlue);
@@ -0,0 +1,16 @@
+{
+ "author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)",
+ "name": "tinycolor",
+ "description": "a to-the-point color module for node",
+ "version": "0.0.1",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/einaros/tinycolor.git"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "main": "tinycolor"
+}
@@ -0,0 +1,31 @@
+var styles = {
+ 'bold': ['\033[1m', '\033[22m'],
+ 'italic': ['\033[3m', '\033[23m'],
+ 'underline': ['\033[4m', '\033[24m'],
+ 'inverse': ['\033[7m', '\033[27m'],
+ 'black': ['\033[30m', '\033[39m'],
+ 'red': ['\033[31m', '\033[39m'],
+ 'green': ['\033[32m', '\033[39m'],
+ 'yellow': ['\033[33m', '\033[39m'],
+ 'blue': ['\033[34m', '\033[39m'],
+ 'magenta': ['\033[35m', '\033[39m'],
+ 'cyan': ['\033[36m', '\033[39m'],
+ 'white': ['\033[37m', '\033[39m'],
+ 'default': ['\033[39m', '\033[39m'],
+ 'grey': ['\033[90m', '\033[39m'],
+ 'bgBlack': ['\033[40m', '\033[49m'],
+ 'bgRed': ['\033[41m', '\033[49m'],
+ 'bgGreen': ['\033[42m', '\033[49m'],
+ 'bgYellow': ['\033[43m', '\033[49m'],
+ 'bgBlue': ['\033[44m', '\033[49m'],
+ 'bgMagenta': ['\033[45m', '\033[49m'],
+ 'bgCyan': ['\033[46m', '\033[49m'],
+ 'bgWhite': ['\033[47m', '\033[49m'],
+ 'bgDefault': ['\033[49m', '\033[49m']
+}
+Object.keys(styles).forEach(function(style) {
+ Object.defineProperty(String.prototype, style, {
+ get: function() { return styles[style][0] + this + styles[style][1]; },
+ enumerable: false
+ });
+});

0 comments on commit 5908502

Please sign in to comment.