Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

colorful

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colorful - npm Package Compare versions

Comparing version 1.2.3 to 1.3.0

7

index.js

@@ -1,6 +0,1 @@

var color = require('./lib/color');
exports = module.exports = color;
var logging = require('./lib/logging');
exports.logging = logging;
exports.Logging = logging.Logging;
exports.scheme = require('./lib/scheme');
module.exports = require('./lib/color');

42

lib/color.js

@@ -5,3 +5,3 @@ /*

*
* Thanks to: https://github.com/lepture/terminal
* http://en.wikipedia.org/wiki/ANSI_escape_code
*

@@ -12,2 +12,3 @@ */

var os = require('os');
var util = require('util');
var codes = {};

@@ -48,17 +49,11 @@

}
return code[0] + text + code[1];
return esc(code) + text + esc('39;49;00');
}
var styles = {
bold: [1, 22],
italic: [3, 23],
underline: [4, 24],
blink: [5, 25],
inverse: [7, 27],
strike: [9, 29]
};
for (var name in styles) {
var code = styles[name];
codes[name] = [esc(code[0]), esc(code[1])];
var styles = [
'bold', 'faint', 'italic', 'underline', 'blink', 'overline',
'inverse', 'conceal', 'strike'
];
for (var i = 0; i < styles.length; i++) {
codes[styles[i]] = i + 1;
}

@@ -70,10 +65,9 @@

];
for (var i = 0; i < colors.length; i++) {
codes[colors[i]] = [esc(i + 30), esc(39)];
codes[colors[i] + '_bg'] = [esc(i + 40), esc(49)];
codes[colors[i]] = i + 30;
codes[colors[i] + '_bg'] = i + 40;
}
codes.gray = codes.grey = [esc(90), esc(39)];
codes.gray_bg = codes.grey_bg = [esc(40), esc(49)];
codes.gray = codes.grey = '30;1';
codes.gray_bg = codes.grey_bg = '40;1';

@@ -84,5 +78,15 @@ function Color(obj) {

}
util.inherits(Color, String);
Color.prototype.valueOf = function() {
return this.color;
};
Color.prototype.toString = function() {
return this.color;
};
Object.defineProperty(Color.prototype, 'length', {
get: function() {
return this.string.length;
}
});
exports.Color = Color;

@@ -89,0 +93,0 @@ exports.color = {};

{
"name": "colorful",
"version": "1.2.3",
"description": "colorful if a terminal tool for color, logging and command",
"version": "1.3.0",
"description": "colorful if a terminal tool for colors",
"keywords": [
"color",
"logging",
"console",
"terminal",
"command"
"terminal"
],

@@ -12,0 +10,0 @@ "author": {

@@ -62,72 +62,38 @@ # Colorful

------
# Colors
# Logging
- bold
- faint
- italic
- underline
- blink
- overline
- inverse
- conceal
- strike
- black
- black_bg
- red
- red_bg
- green
- green_bg
- yellow
- yellow_bg
- blue
- blue_bg
- magenta
- magenta_bg
- cyan
- cyan_bg
- white
- white_bg
- grey
- gray
- grey_bg
- gray_bg
Colorful and nested logging in terminal.
# Changelog
[![nico](http://lab.lepture.com/nico/nico-look.png)](http://lab.lepture.com/nico/)
- `1.3.0`
## Favorite
Default is my favorite, we should do nothing:
```javascript
var logging = require('colorful').logging;
// start a nested logging
logging.start('Start Application')
logging.info('send an info message')
// start another nested logging
logging.start('Start subprocess')
logging.warn('send a warn message')
logging.end('End subprocess')
logging.error('send an error message')
logging.debug('send a debug message')
logging.end('End Application')
```
## Config
I want to show debug message:
```javascript
logging.config('debug')
// or
logging.config({level: 'debug'})
logging.config({verbose: true})
```
## Scheme
Define your logging scheme:
```javascript
var scheme = {
debug: {
start: '# ',
color: 'gray',
end: ' #'
},
info: {
start: 'v ',
color: 'green'
},
warn: {
start: '! ',
color: 'yellow'
},
error: {
start: 'x ',
color: 'red'
},
start: {
start: '> '
},
end: {
start: '< '
}
}
logging.scheme = scheme;
```
- removed logging

@@ -11,4 +11,4 @@ var color = require('../lib/color');

it('should be red hello', function() {
paint('hello').red.color.should.equal('\x1b[31mhello\x1b[39m');
paint('hello').red.style.should.equal('\x1b[31mhello\x1b[39m');
paint('hello').red.color.should.equal('\x1b[31mhello\x1b[39;49;00m');
paint('hello').red.style.should.equal('\x1b[31mhello\x1b[39;49;00m');
});

@@ -21,5 +21,4 @@ it('should be colorful string', function() {

it('should be underline red hello', function() {
'hello'.to.underline.red.color.should.equal('\x1b[31m\x1b[4mhello\x1b[24m\x1b[39m');
'hello'.to.underline.red.string.should.equal('hello');
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc