mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-11-04 05:50:10 +00:00 
			
		
		
		
	resolves #72
This commit is contained in:
		
							parent
							
								
									e9e6557cc0
								
							
						
					
					
						commit
						c11d23d96a
					
				
							
								
								
									
										12
									
								
								ReadMe.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ReadMe.md
									
									
									
									
									
								
							@ -162,6 +162,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"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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.*
 | 
					*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
 | 
				
			||||||
@ -115,6 +115,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)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user