Add bright/light colors, closes #128

This commit is contained in:
DABH 2019-09-22 16:36:30 -07:00
parent b4d964b514
commit 56de9f0983
9 changed files with 70 additions and 5 deletions

View File

@ -29,6 +29,16 @@ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases.
- gray - gray
- grey - grey
### bright text colors
- brightRed
- brightGreen
- brightYellow
- brightBlue
- brightMagenta
- brightCyan
- brightWhite
### background colors ### background colors
- bgBlack - bgBlack
@ -39,6 +49,18 @@ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases.
- bgMagenta - bgMagenta
- bgCyan - bgCyan
- bgWhite - bgWhite
- bgGray
- bgGrey
### bright background colors
- bgBrightRed
- bgBrightGreen
- bgBrightYellow
- bgBrightBlue
- bgBrightMagenta
- bgBrightCyan
- bgBrightWhite
### styles ### styles

View File

@ -29,6 +29,7 @@ console.log('Background color attack!'.black.bgWhite);
console.log('Use random styles on everything!'.random); console.log('Use random styles on everything!'.random);
console.log('America, Heck Yeah!'.america); console.log('America, Heck Yeah!'.america);
console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
console.log('Setting themes is useful'); console.log('Setting themes is useful');

View File

@ -28,6 +28,8 @@ console.log(colors.black.bgWhite('Background color attack!'));
console.log(colors.random('Use random styles on everything!')); console.log(colors.random('Use random styles on everything!'));
console.log(colors.america('America, Heck Yeah!')); console.log(colors.america('America, Heck Yeah!'));
console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));
console.log('Setting themes is useful'); console.log('Setting themes is useful');
// //

View File

@ -1,6 +1,7 @@
module['exports'] = function(colors) { module['exports'] = function(colors) {
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
'blue', 'white', 'cyan', 'magenta']; 'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta'];
return function(letter, i, exploded) { return function(letter, i, exploded) {
return letter === ' ' ? letter : return letter === ' ' ? letter :
colors[ colors[

View File

@ -48,6 +48,14 @@ var codes = {
gray: [90, 39], gray: [90, 39],
grey: [90, 39], grey: [90, 39],
brightRed: [91, 39],
brightGreen: [92, 39],
brightYellow: [93, 39],
brightBlue: [94, 39],
brightMagenta: [95, 39],
brightCyan: [96, 39],
brightWhite: [97, 39],
bgBlack: [40, 49], bgBlack: [40, 49],
bgRed: [41, 49], bgRed: [41, 49],
bgGreen: [42, 49], bgGreen: [42, 49],
@ -56,6 +64,16 @@ var codes = {
bgMagenta: [45, 49], bgMagenta: [45, 49],
bgCyan: [46, 49], bgCyan: [46, 49],
bgWhite: [47, 49], bgWhite: [47, 49],
bgGray: [100, 49],
bgGrey: [100, 49],
bgBrightRed: [101, 49],
bgBrightGreen: [102, 49],
bgBrightYellow: [103, 49],
bgBrightBlue: [104, 49],
bgBrightMagenta: [105, 49],
bgBrightCyan: [106, 49],
bgBrightWhite: [107, 49],
// legacy styles for colors pre v1.0.0 // legacy styles for colors pre v1.0.0
blackBG: [40, 49], blackBG: [40, 49],

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "colors", "name": "colors",
"version": "1.3.4", "version": "1.4.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -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.3.4", "version": "1.4.0",
"author": "Marak Squires", "author": "Marak Squires",
"contributors": [ "contributors": [
{ {

View File

@ -16,7 +16,10 @@ function aE(s, color, code) {
} }
var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta',
'red', 'yellow']; 'red', 'yellow', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan',
'brightMagenta'];
// eslint-disable-next-line // eslint-disable-next-line
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', var stylesAll = stylesColors.concat(['bold', 'italic', 'underline',
'inverse', 'rainbow']); 'inverse', 'rainbow']);
@ -46,6 +49,14 @@ aE(s, 'magenta', 35);
aE(s, 'red', 31); aE(s, 'red', 31);
aE(s, 'yellow', 33); aE(s, 'yellow', 33);
aE(s, 'brightWhite', 97);
aE(s, 'brightBlue', 94);
aE(s, 'brightCyan', 96);
aE(s, 'brightGreen', 92);
aE(s, 'brightMagenta', 95);
aE(s, 'brightRed', 91);
aE(s, 'brightYellow', 93);
assert.equal(s, 'string'); assert.equal(s, 'string');
var testStringWithNewLines = s + '\n' + s; var testStringWithNewLines = s + '\n' + s;

View File

@ -13,7 +13,9 @@ function aE(s, color, code) {
} }
var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta',
'red', 'yellow']; 'red', 'yellow', 'brightYellow', 'brightRed',
'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan',
'brightMagenta'];
// eslint-disable-next-line // eslint-disable-next-line
var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse',
'rainbow']); 'rainbow']);
@ -37,6 +39,14 @@ aE(s, 'magenta', 35);
aE(s, 'red', 31); aE(s, 'red', 31);
aE(s, 'yellow', 33); aE(s, 'yellow', 33);
aE(s, 'brightWhite', 97);
aE(s, 'brightBlue', 94);
aE(s, 'brightCyan', 96);
aE(s, 'brightGreen', 92);
aE(s, 'brightMagenta', 95);
aE(s, 'brightRed', 91);
aE(s, 'brightYellow', 93);
assert.equal(s, 'string'); assert.equal(s, 'string');
var testStringWithNewLines = s + '\n' + s; var testStringWithNewLines = s + '\n' + s;