@@ -7,7 +7,12 @@ const template = require('./templates.js');
77const isSimpleWindowsTerm = process . platform === 'win32' && ! ( process . env . TERM || '' ) . toLowerCase ( ) . startsWith ( 'xterm' ) ;
88
99// `supportsColor.level` → `ansiStyles.color[name]` mapping
10- const levelMapping = [ 'ansi' , 'ansi' , 'ansi256' , 'ansi16m' ] ;
10+ const levelMapping = [
11+ 'ansi' ,
12+ 'ansi' ,
13+ 'ansi256' ,
14+ 'ansi16m'
15+ ] ;
1116
1217// `color-convert` models to exclude from the Chalk API due to conflicts and such
1318const skipModels = new Set ( [ 'gray' ] ) ;
@@ -35,14 +40,15 @@ function chalkFactory(options) {
3540 const chalk = { } ;
3641 applyOptions ( chalk , options ) ;
3742
38- chalk . template = ( ...args ) => chalkTag ( chalk . template , ...args ) ;
43+ chalk . template = ( ...arguments_ ) => chalkTag ( chalk . template , ...arguments_ ) ;
3944
4045 Object . setPrototypeOf ( chalk , Chalk . prototype ) ;
4146 Object . setPrototypeOf ( chalk . template , chalk ) ;
4247
4348 chalk . template . constructor = ( ) => {
4449 throw new Error ( '`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.' ) ;
4550 } ;
51+
4652 chalk . template . Instance = ChalkClass ;
4753
4854 return chalk . template ;
@@ -57,13 +63,12 @@ if (isSimpleWindowsTerm) {
5763 ansiStyles . blue . open = '\u001B[94m' ;
5864}
5965
60- for ( const key of Object . keys ( ansiStyles ) ) {
61- ansiStyles [ key ] . closeRe = new RegExp ( escapeStringRegexp ( ansiStyles [ key ] . close ) , 'g' ) ;
66+ for ( const [ styleName , style ] of Object . entries ( ansiStyles ) ) {
67+ style . closeRe = new RegExp ( escapeStringRegexp ( style . close ) , 'g' ) ;
6268
63- styles [ key ] = {
69+ styles [ styleName ] = {
6470 get ( ) {
65- const codes = ansiStyles [ key ] ;
66- return build . call ( this , [ ...( this . _styles || [ ] ) , codes ] , this . _empty , key ) ;
71+ return build . call ( this , [ ...( this . _styles || [ ] ) , style ] , this . _empty , styleName ) ;
6772 }
6873 } ;
6974}
@@ -106,8 +111,8 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
106111 styles [ bgModel ] = {
107112 get ( ) {
108113 const { level} = this ;
109- return function ( ...args ) {
110- const open = ansiStyles . bgColor [ levelMapping [ level ] ] [ model ] ( ...args ) ;
114+ return function ( ...arguments_ ) {
115+ const open = ansiStyles . bgColor [ levelMapping [ level ] ] [ model ] ( ...arguments_ ) ;
111116 const codes = {
112117 open,
113118 close : ansiStyles . bgColor . close ,
@@ -122,7 +127,7 @@ for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
122127const proto = Object . defineProperties ( ( ) => { } , styles ) ;
123128
124129function build ( _styles , _empty , key ) {
125- const builder = ( ...args ) => applyStyle . call ( builder , ...args ) ;
130+ const builder = ( ...arguments_ ) => applyStyle . call ( builder , ...arguments_ ) ;
126131 builder . _styles = _styles ;
127132 builder . _empty = _empty ;
128133
@@ -158,8 +163,8 @@ function build(_styles, _empty, key) {
158163 return builder ;
159164}
160165
161- function applyStyle ( ...args ) {
162- let string = args . join ( ' ' ) ;
166+ function applyStyle ( ...arguments_ ) {
167+ let string = arguments_ . join ( ' ' ) ;
163168
164169 if ( ! this . enabled || this . level <= 0 || ! string ) {
165170 return this . _empty ? '' : string ;
@@ -200,12 +205,12 @@ function chalkTag(chalk, ...strings) {
200205 return strings . join ( ' ' ) ;
201206 }
202207
203- const args = strings . slice ( 1 ) ;
208+ const arguments_ = strings . slice ( 1 ) ;
204209 const parts = [ firstString . raw [ 0 ] ] ;
205210
206211 for ( let i = 1 ; i < firstString . length ; i ++ ) {
207212 parts . push (
208- String ( args [ i - 1 ] ) . replace ( / [ { } \\ ] / g, '\\$&' ) ,
213+ String ( arguments_ [ i - 1 ] ) . replace ( / [ { } \\ ] / g, '\\$&' ) ,
209214 String ( firstString . raw [ i ] )
210215 ) ;
211216 }
0 commit comments