File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33const {
4- FunctionPrototypeBind,
54 ObjectCreate,
65 ObjectDefineProperty,
76 RegExp,
8- RegExpPrototypeTest ,
7+ RegExpPrototypeExec ,
98 SafeArrayIterator,
109 StringPrototypeToLowerCase,
1110 StringPrototypeToUpperCase,
1211} = primordials ;
1312
1413const { inspect, format, formatWithOptions } = require ( 'internal/util/inspect' ) ;
1514
16- // `debugs` is deliberately initialized to undefined so any call to
17- // debuglog() before initializeDebugEnv() is called will throw.
15+ // `debugImpls` and `testEnabled` are deliberately not initialized so any call
16+ // to ` debuglog()` before ` initializeDebugEnv()` is called will throw.
1817let debugImpls ;
19-
20- let debugEnvRegex = / ^ $ / ;
2118let testEnabled ;
2219
20+
2321// `debugEnv` is initial value of process.env.NODE_DEBUG
2422function initializeDebugEnv ( debugEnv ) {
2523debugImpls = ObjectCreate ( null ) ;
2624if ( debugEnv ) {
25+ // This is run before any user code, it's OK not to use primordials.
2726debugEnv = debugEnv . replace ( / [ | \\ { } ( ) [ \] ^ $ + ? . ] / g, '\\$&' )
28- . replace ( / \* / g, '.*' )
29- . replace ( / , / g, '$|^' )
30- . toUpperCase ( ) ;
31- debugEnvRegex = new RegExp ( `^${ debugEnv } $` , 'i' ) ;
27+ . replaceAll ( '*' , '.*' )
28+ . replaceAll ( ',' , '$|^' ) ;
29+ const debugEnvRegex = new RegExp ( `^${ debugEnv } $` , 'i' ) ;
30+ testEnabled = ( str ) => RegExpPrototypeExec ( debugEnvRegex , str ) !== null ;
31+ } else {
32+ testEnabled = ( ) => false ;
3233}
33- testEnabled = FunctionPrototypeBind ( RegExpPrototypeTest , null , debugEnvRegex ) ;
3434}
3535
3636// Emits warning when user sets
You can’t perform that action at this time.
0 commit comments