arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/colors/ReadMe.md
www/node_modules/colors/ReadMe.mdRaw
  1# colors.js
  2
  3## get color and style in your node.js console
  4
  5<img src="https://github.com/Marak/colors.js/raw/master/screenshots/colors.png"/>
  6
  7## Installation
  8
  9    npm install colors
 10
 11## colors and styles!
 12
 13### text colors
 14
 15  - black
 16  - red
 17  - green
 18  - yellow
 19  - blue
 20  - magenta
 21  - cyan
 22  - white
 23  - gray
 24  - grey
 25
 26### background colors
 27
 28
 29
 30  - bgBlack
 31  - bgRed
 32  - bgGreen
 33  - bgYellow
 34  - bgBlue
 35  - bgMagenta
 36  - bgCyan
 37  - bgWhite
 38
 39### styles
 40
 41  - reset
 42  - bold
 43  - dim
 44  - italic
 45  - underline
 46  - inverse
 47  - hidden
 48  - strikethrough
 49
 50### extras
 51
 52  - rainbow
 53  - zebra
 54  - america
 55  - trap
 56  - random
 57
 58
 59## Usage
 60
 61By popular demand, `colors` now ships with two types of usages!
 62
 63The super nifty way
 64
 65```js
 66var colors = require('colors');
 67
 68console.log('hello'.green); // outputs green text
 69console.log('i like cake and pies'.underline.red) // outputs red underlined text
 70console.log('inverse the color'.inverse); // inverses the color
 71console.log('OMG Rainbows!'.rainbow); // rainbow
 72console.log('Run the trap'.trap); // Drops the bass
 73
 74```
 75
 76or a slightly less nifty way which doesn't extend `String.prototype`
 77
 78```js
 79var colors = require('colors/safe');
 80
 81console.log(colors.green('hello')); // outputs green text
 82console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
 83console.log(colors.inverse('inverse the color')); // inverses the color
 84console.log(colors.rainbow('OMG Rainbows!')); // rainbow
 85console.log(colors.trap('Run the trap')); // Drops the bass
 86
 87```
 88
 89I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way. 
 90
 91If 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.
 92
 93## Disabling Colors
 94
 95To disable colors you can pass the following arguments in the command line to your application:
 96
 97```bash
 98node myapp.js --no-color
 99```
100
101## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
102
103```js
104var name = 'Marak';
105console.log(colors.green('Hello %s'), name);
106// outputs -> 'Hello Marak'
107```
108
109## Custom themes
110
111### Using standard API
112
113```js
114
115var colors = require('colors');
116
117colors.setTheme({
118  silly: 'rainbow',
119  input: 'grey',
120  verbose: 'cyan',
121  prompt: 'grey',
122  info: 'green',
123  data: 'grey',
124  help: 'cyan',
125  warn: 'yellow',
126  debug: 'blue',
127  error: 'red'
128});
129
130// outputs red text
131console.log("this is an error".error);
132
133// outputs yellow text
134console.log("this is a warning".warn);
135```
136
137### Using string safe API
138
139```js
140var colors = require('colors/safe');
141
142// set single property
143var error = colors.red;
144error('this is red');
145
146// set theme
147colors.setTheme({
148  silly: 'rainbow',
149  input: 'grey',
150  verbose: 'cyan',
151  prompt: 'grey',
152  info: 'green',
153  data: 'grey',
154  help: 'cyan',
155  warn: 'yellow',
156  debug: 'blue',
157  error: 'red'
158});
159
160// outputs red text
161console.log(colors.error("this is an error"));
162
163// outputs yellow text
164console.log(colors.warn("this is a warning"));
165```
166
167*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*