@@ -26,7 +26,7 @@ const util = require('util');
26
26
const kCounts = Symbol ( 'counts' ) ;
27
27
28
28
// Track amount of indentation required via `console.group()`.
29
- const groupIndent = Symbol ( 'groupIndent' ) ;
29
+ const kGroupIndent = Symbol ( 'groupIndent' ) ;
30
30
31
31
function Console ( stdout , stderr , ignoreErrors = true ) {
32
32
if ( ! ( this instanceof Console ) ) {
@@ -60,15 +60,14 @@ function Console(stdout, stderr, ignoreErrors = true) {
60
60
Object . defineProperty ( this , '_stderrErrorHandler' , prop ) ;
61
61
62
62
this [ kCounts ] = new Map ( ) ;
63
+ this [ kGroupIndent ] = '' ;
63
64
64
65
// bind the prototype functions to this Console instance
65
66
var keys = Object . keys ( Console . prototype ) ;
66
67
for ( var v = 0 ; v < keys . length ; v ++ ) {
67
68
var k = keys [ v ] ;
68
69
this [ k ] = this [ k ] . bind ( this ) ;
69
70
}
70
-
71
- this [ groupIndent ] = '' ;
72
71
}
73
72
74
73
// Make a function that can serve as the callback passed to `stream.write()`.
@@ -116,7 +115,7 @@ function write(ignoreErrors, stream, string, errorhandler) {
116
115
Console . prototype . log = function log ( ...args ) {
117
116
write ( this . _ignoreErrors ,
118
117
this . _stdout ,
119
- `${ this [ groupIndent ] } ${ util . format . apply ( null , args ) } \n` ,
118
+ `${ this [ kGroupIndent ] } ${ util . format . apply ( null , args ) } \n` ,
120
119
this . _stdoutErrorHandler ) ;
121
120
} ;
122
121
@@ -127,7 +126,7 @@ Console.prototype.info = Console.prototype.log;
127
126
Console . prototype . warn = function warn ( ...args ) {
128
127
write ( this . _ignoreErrors ,
129
128
this . _stderr ,
130
- `${ this [ groupIndent ] } ${ util . format . apply ( null , args ) } \n` ,
129
+ `${ this [ kGroupIndent ] } ${ util . format . apply ( null , args ) } \n` ,
131
130
this . _stderrErrorHandler ) ;
132
131
} ;
133
132
@@ -139,7 +138,7 @@ Console.prototype.dir = function dir(object, options) {
139
138
options = Object . assign ( { customInspect : false } , options ) ;
140
139
write ( this . _ignoreErrors ,
141
140
this . _stdout ,
142
- `${ this [ groupIndent ] } ${ util . inspect ( object , options ) } \n` ,
141
+ `${ this [ kGroupIndent ] } ${ util . inspect ( object , options ) } \n` ,
143
142
this . _stdoutErrorHandler ) ;
144
143
} ;
145
144
@@ -223,13 +222,14 @@ Console.prototype.group = function group(...data) {
223
222
if ( data . length > 0 ) {
224
223
this . log ( ...data ) ;
225
224
}
226
- this [ groupIndent ] += ' ' ;
225
+ this [ kGroupIndent ] += ' ' ;
227
226
} ;
228
227
229
228
Console . prototype . groupCollapsed = Console . prototype . group ;
230
229
231
230
Console . prototype . groupEnd = function groupEnd ( ) {
232
- this [ groupIndent ] = this [ groupIndent ] . slice ( 0 , this [ groupIndent ] . length - 2 ) ;
231
+ this [ kGroupIndent ] =
232
+ this [ kGroupIndent ] . slice ( 0 , this [ kGroupIndent ] . length - 2 ) ;
233
233
} ;
234
234
235
235
module . exports = new Console ( process . stdout , process . stderr ) ;
0 commit comments