11'use strict' ;
2- const colorConvert = require ( 'color-convert' ) ;
32
4- const wrapAnsi16 = ( fn , offset ) => function ( ) {
5- const code = fn . apply ( colorConvert , arguments ) ;
6- return `\u001B[${ code + offset } m` ;
7- } ;
8-
9- const wrapAnsi256 = ( fn , offset ) => function ( ) {
10- const code = fn . apply ( colorConvert , arguments ) ;
11- return `\u001B[${ 38 + offset } ;5;${ code } m` ;
12- } ;
13-
14- const wrapAnsi16m = ( fn , offset ) => function ( ) {
15- const rgb = fn . apply ( colorConvert , arguments ) ;
16- return `\u001B[${ 38 + offset } ;2;${ rgb [ 0 ] } ;${ rgb [ 1 ] } ;${ rgb [ 2 ] } m` ;
17- } ;
18-
19- function assembleStyles ( ) {
20- const styles = {
21- modifier : {
3+ function assembleStyles ( ) {
4+ var styles = {
5+ modifiers : {
226 reset : [ 0 , 0 ] ,
23- // 21 isn't widely supported and 22 does the same thing
24- bold : [ 1 , 22 ] ,
7+ bold : [ 1 , 22 ] , // 21 isn't widely supported and 22 does the same thing
258 dim : [ 2 , 22 ] ,
269 italic : [ 3 , 23 ] ,
2710 underline : [ 4 , 24 ] ,
2811 inverse : [ 7 , 27 ] ,
2912 hidden : [ 8 , 28 ] ,
3013 strikethrough : [ 9 , 29 ]
3114 } ,
32- color : {
15+ colors : {
3316 black : [ 30 , 39 ] ,
3417 red : [ 31 , 39 ] ,
3518 green : [ 32 , 39 ] ,
@@ -38,54 +21,33 @@ function assembleStyles() {
3821 magenta : [ 35 , 39 ] ,
3922 cyan : [ 36 , 39 ] ,
4023 white : [ 37 , 39 ] ,
41- gray : [ 90 , 39 ] ,
42-
43- // Bright color
44- redBright : [ 91 , 39 ] ,
45- greenBright : [ 92 , 39 ] ,
46- yellowBright : [ 93 , 39 ] ,
47- blueBright : [ 94 , 39 ] ,
48- magentaBright : [ 95 , 39 ] ,
49- cyanBright : [ 96 , 39 ] ,
50- whiteBright : [ 97 , 39 ]
24+ gray : [ 90 , 39 ]
5125 } ,
52- bgColor : {
26+ bgColors : {
5327 bgBlack : [ 40 , 49 ] ,
5428 bgRed : [ 41 , 49 ] ,
5529 bgGreen : [ 42 , 49 ] ,
5630 bgYellow : [ 43 , 49 ] ,
5731 bgBlue : [ 44 , 49 ] ,
5832 bgMagenta : [ 45 , 49 ] ,
5933 bgCyan : [ 46 , 49 ] ,
60- bgWhite : [ 47 , 49 ] ,
61-
62- // Bright color
63- bgBlackBright : [ 100 , 49 ] ,
64- bgRedBright : [ 101 , 49 ] ,
65- bgGreenBright : [ 102 , 49 ] ,
66- bgYellowBright : [ 103 , 49 ] ,
67- bgBlueBright : [ 104 , 49 ] ,
68- bgMagentaBright : [ 105 , 49 ] ,
69- bgCyanBright : [ 106 , 49 ] ,
70- bgWhiteBright : [ 107 , 49 ]
34+ bgWhite : [ 47 , 49 ]
7135 }
7236 } ;
7337
74- // Fix humans
75- styles . color . grey = styles . color . gray ;
38+ // fix humans
39+ styles . colors . grey = styles . colors . gray ;
7640
77- Object . keys ( styles ) . forEach ( groupName => {
78- const group = styles [ groupName ] ;
41+ Object . keys ( styles ) . forEach ( function ( groupName ) {
42+ var group = styles [ groupName ] ;
7943
80- Object . keys ( group ) . forEach ( styleName => {
81- const style = group [ styleName ] ;
44+ Object . keys ( group ) . forEach ( function ( styleName ) {
45+ var style = group [ styleName ] ;
8246
83- styles [ styleName ] = {
84- open : `\u001B[ ${ style [ 0 ] } m` ,
85- close : `\u001B[ ${ style [ 1 ] } m`
47+ styles [ styleName ] = group [ styleName ] = {
48+ open : '\u001b[' + style [ 0 ] + 'm' ,
49+ close : '\u001b[' + style [ 1 ] + 'm'
8650 } ;
87-
88- group [ styleName ] = styles [ styleName ] ;
8951 } ) ;
9052
9153 Object . defineProperty ( styles , groupName , {
@@ -94,51 +56,11 @@ function assembleStyles() {
9456 } ) ;
9557 } ) ;
9658
97- const rgb2rgb = ( r , g , b ) => [ r , g , b ] ;
98-
99- styles . color . close = '\u001B[39m' ;
100- styles . bgColor . close = '\u001B[49m' ;
101-
102- styles . color . ansi = { } ;
103- styles . color . ansi256 = { } ;
104- styles . color . ansi16m = {
105- rgb : wrapAnsi16m ( rgb2rgb , 0 )
106- } ;
107-
108- styles . bgColor . ansi = { } ;
109- styles . bgColor . ansi256 = { } ;
110- styles . bgColor . ansi16m = {
111- rgb : wrapAnsi16m ( rgb2rgb , 10 )
112- } ;
113-
114- for ( const key of Object . keys ( colorConvert ) ) {
115- if ( typeof colorConvert [ key ] !== 'object' ) {
116- continue ;
117- }
118-
119- const suite = colorConvert [ key ] ;
120-
121- if ( 'ansi16' in suite ) {
122- styles . color . ansi [ key ] = wrapAnsi16 ( suite . ansi16 , 0 ) ;
123- styles . bgColor . ansi [ key ] = wrapAnsi16 ( suite . ansi16 , 10 ) ;
124- }
125-
126- if ( 'ansi256' in suite ) {
127- styles . color . ansi256 [ key ] = wrapAnsi256 ( suite . ansi256 , 0 ) ;
128- styles . bgColor . ansi256 [ key ] = wrapAnsi256 ( suite . ansi256 , 10 ) ;
129- }
130-
131- if ( 'rgb' in suite ) {
132- styles . color . ansi16m [ key ] = wrapAnsi16m ( suite . rgb , 0 ) ;
133- styles . bgColor . ansi16m [ key ] = wrapAnsi16m ( suite . rgb , 10 ) ;
134- }
135- }
136-
13759 return styles ;
13860}
13961
140- //Object.defineProperty(module, 'exports', {
141- // enumerable: true,
142- // get: assembleStyles
143- //});
14462module . exports = assembleStyles ( ) ;
63+ /* Object.defineProperty(module, 'exports', {
64+ enumerable: true,
65+ get: assembleStyles
66+ }); */
0 commit comments