mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-10-31 12:00:08 +00:00 
			
		
		
		
	
						commit
						5a2773dbec
					
				| @ -1,23 +0,0 @@ | |||||||
| Original Library |  | ||||||
|   - Copyright (c) Marak Squires |  | ||||||
| 
 |  | ||||||
| Additional Functionality |  | ||||||
|  - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) |  | ||||||
| 
 |  | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy |  | ||||||
| of this software and associated documentation files (the "Software"), to deal |  | ||||||
| in the Software without restriction, including without limitation the rights |  | ||||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |  | ||||||
| copies of the Software, and to permit persons to whom the Software is |  | ||||||
| furnished to do so, subject to the following conditions: |  | ||||||
| 
 |  | ||||||
| The above copyright notice and this permission notice shall be included in |  | ||||||
| all copies or substantial portions of the Software. |  | ||||||
| 
 |  | ||||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |  | ||||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |  | ||||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |  | ||||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |  | ||||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |  | ||||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |  | ||||||
| THE SOFTWARE. |  | ||||||
							
								
								
									
										20
									
								
								ReadMe.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								ReadMe.md
									
									
									
									
									
								
							| @ -1,8 +1,8 @@ | |||||||
| # colors.js | # colors.js [](https://travis-ci.org/Marak/colors.js) | ||||||
| 
 | 
 | ||||||
| ## get color and style in your node.js console | ## get color and style in your node.js console | ||||||
| 
 | 
 | ||||||
| <img src="https://github.com/Marak/colors.js/raw/master/screenshots/colors.png"/> |  | ||||||
| 
 | 
 | ||||||
| ## Installation | ## Installation | ||||||
| 
 | 
 | ||||||
| @ -25,8 +25,6 @@ | |||||||
| 
 | 
 | ||||||
| ### background colors | ### background colors | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|   - bgBlack |   - bgBlack | ||||||
|   - bgRed |   - bgRed | ||||||
|   - bgGreen |   - bgGreen | ||||||
| @ -162,6 +160,18 @@ console.log(colors.error("this is an error")); | |||||||
| 
 | 
 | ||||||
| // outputs yellow text | // outputs yellow text | ||||||
| console.log(colors.warn("this is a warning")); | console.log(colors.warn("this is a warning")); | ||||||
|  | 
 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.* | You can also combine them: | ||||||
|  | 
 | ||||||
|  | ```javascript | ||||||
|  | colors.setTheme({ | ||||||
|  |   link: ['underline', 'blue'] | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | // outputs underlined blue text | ||||||
|  | console.log(colors.info('Listening on ') + colors.link('http://0.0.0.0:' + port)); | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.* | ||||||
|  | |||||||
| @ -48,6 +48,10 @@ colors.stripColors = colors.strip = function(str){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var stylize = colors.stylize = function stylize (str, style) { | var stylize = colors.stylize = function stylize (str, style) { | ||||||
|  |   if (!colors.enabled) { | ||||||
|  |     return str+''; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   return ansiStyles[style].open + str + ansiStyles[style].close; |   return ansiStyles[style].open + str + ansiStyles[style].close; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -115,6 +119,13 @@ function applyTheme (theme) { | |||||||
|   for (var style in theme) { |   for (var style in theme) { | ||||||
|     (function(style){ |     (function(style){ | ||||||
|       colors[style] = function(str){ |       colors[style] = function(str){ | ||||||
|  |         if (typeof theme[style] === 'object'){ | ||||||
|  |           var out = str; | ||||||
|  |           for (var i in theme[style]){ | ||||||
|  |             out = colors[theme[style][i]](out); | ||||||
|  |           } | ||||||
|  |           return out; | ||||||
|  |         } | ||||||
|         return colors[theme[style]](str); |         return colors[theme[style]](str); | ||||||
|       }; |       }; | ||||||
|     })(style) |     })(style) | ||||||
|  | |||||||
| @ -58,10 +58,10 @@ module['exports'] = function zalgo(text, options) { | |||||||
|   function heComes(text, options) { |   function heComes(text, options) { | ||||||
|     var result = '', counts, l; |     var result = '', counts, l; | ||||||
|     options = options || {}; |     options = options || {}; | ||||||
|     options["up"] = options["up"] || true; |     options["up"] =   typeof options["up"]   !== 'undefined' ? options["up"]   : true; | ||||||
|     options["mid"] = options["mid"] || true; |     options["mid"] =  typeof options["mid"]  !== 'undefined' ? options["mid"]  : true; | ||||||
|     options["down"] = options["down"] || true; |     options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true; | ||||||
|     options["size"] = options["size"] || "maxi"; |     options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi"; | ||||||
|     text = text.split(''); |     text = text.split(''); | ||||||
|     for (l in text) { |     for (l in text) { | ||||||
|       if (is_char(l)) { |       if (is_char(l)) { | ||||||
| @ -72,12 +72,12 @@ module['exports'] = function zalgo(text, options) { | |||||||
|       switch (options.size) { |       switch (options.size) { | ||||||
|       case 'mini': |       case 'mini': | ||||||
|         counts.up = randomNumber(8); |         counts.up = randomNumber(8); | ||||||
|         counts.min = randomNumber(2); |         counts.mid = randomNumber(2); | ||||||
|         counts.down = randomNumber(8); |         counts.down = randomNumber(8); | ||||||
|         break; |         break; | ||||||
|       case 'maxi': |       case 'maxi': | ||||||
|         counts.up = randomNumber(16) + 3; |         counts.up = randomNumber(16) + 3; | ||||||
|         counts.min = randomNumber(4) + 1; |         counts.mid = randomNumber(4) + 1; | ||||||
|         counts.down = randomNumber(64) + 3; |         counts.down = randomNumber(64) + 3; | ||||||
|         break; |         break; | ||||||
|       default: |       default: | ||||||
| @ -100,5 +100,5 @@ module['exports'] = function zalgo(text, options) { | |||||||
|     return result; |     return result; | ||||||
|   } |   } | ||||||
|   // don't summon him
 |   // don't summon him
 | ||||||
|   return heComes(text); |   return heComes(text, options); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| var colors = require('./colors'), | var colors = require('./colors'); | ||||||
|     styles = require('./styles'); |  | ||||||
| 
 | 
 | ||||||
| module['exports'] = function () { | module['exports'] = function () { | ||||||
| 
 | 
 | ||||||
| @ -18,10 +17,6 @@ module['exports'] = function () { | |||||||
|       } |       } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   var stylize = function stylize (str, style) { |  | ||||||
|     return styles[style].open + str + styles[style].close; |  | ||||||
|   } |  | ||||||
| 
 |  | ||||||
|   addProperty('strip', function () { |   addProperty('strip', function () { | ||||||
|     return colors.strip(this); |     return colors.strip(this); | ||||||
|   }); |   }); | ||||||
| @ -60,7 +55,7 @@ module['exports'] = function () { | |||||||
|   var x = Object.keys(colors.styles); |   var x = Object.keys(colors.styles); | ||||||
|   x.forEach(function (style) { |   x.forEach(function (style) { | ||||||
|     addProperty(style, function () { |     addProperty(style, function () { | ||||||
|       return stylize(this, style); |       return colors.stylize(this, style); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,4 +9,4 @@ module['exports'] = colors; | |||||||
| //   colors.red("foo")
 | //   colors.red("foo")
 | ||||||
| //
 | //
 | ||||||
| //
 | //
 | ||||||
| var extendStringPrototype = require('./extendStringPrototype')(); | require('./extendStringPrototype')(); | ||||||
							
								
								
									
										11
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								package.json
									
									
									
									
									
								
							| @ -1,7 +1,7 @@ | |||||||
| { | { | ||||||
|     "name": "colors", |     "name": "colors", | ||||||
|     "description": "get colors in your node.js console", |     "description": "get colors in your node.js console", | ||||||
|     "version": "1.0.3", |     "version": "1.1.0", | ||||||
|     "author": "Marak Squires", |     "author": "Marak Squires", | ||||||
|     "homepage": "https://github.com/Marak/colors.js", |     "homepage": "https://github.com/Marak/colors.js", | ||||||
|     "bugs": "https://github.com/Marak/colors.js/issues", |     "bugs": "https://github.com/Marak/colors.js/issues", | ||||||
| @ -17,5 +17,12 @@ | |||||||
|     "engines": { |     "engines": { | ||||||
|         "node": ">=0.1.90" |         "node": ">=0.1.90" | ||||||
|     }, |     }, | ||||||
|     "main": "./lib/index" |     "main": "lib", | ||||||
|  |     "files": [ | ||||||
|  |         "examples", | ||||||
|  |         "lib", | ||||||
|  |         "LICENSE", | ||||||
|  |         "safe.js", | ||||||
|  |         "themes" | ||||||
|  |     ] | ||||||
| } | } | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 22 KiB | 
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user