6
6
7
7
const {
8
8
ArrayIsArray,
9
+ ArrayPrototypeMap,
10
+ ArrayPrototypePush,
11
+ ArrayPrototypeSplice,
9
12
BigUint64Array,
10
13
Float64Array,
11
14
NumberMAX_SAFE_INTEGER,
12
- ObjectDefineProperties,
13
15
ObjectDefineProperty,
14
16
ObjectFreeze,
15
- ObjectGetOwnPropertyDescriptors ,
17
+ ReflectApply ,
16
18
RegExpPrototypeTest,
17
- Set,
18
- SetPrototype,
19
- SetPrototypeHas,
19
+ SafeSet,
20
+ StringPrototypeEndsWith,
20
21
StringPrototypeReplace,
22
+ StringPrototypeSlice,
23
+ StringPrototypeStartsWith,
21
24
Uint32Array,
22
25
} = primordials ;
23
26
@@ -94,7 +97,7 @@ function wrapProcessMethods(binding) {
94
97
} = binding ;
95
98
96
99
function _rawDebug ( ...args ) {
97
- binding . _rawDebug ( format . apply ( null , args ) ) ;
100
+ binding . _rawDebug ( ReflectApply ( format , null , args ) ) ;
98
101
}
99
102
100
103
// Create the argument array that will be passed to the native function.
@@ -256,31 +259,31 @@ function buildAllowedFlags() {
256
259
const allowedNodeEnvironmentFlags = [ ] ;
257
260
for ( const [ name , info ] of options ) {
258
261
if ( info . envVarSettings === kAllowedInEnvironment ) {
259
- allowedNodeEnvironmentFlags . push ( name ) ;
262
+ ArrayPrototypePush ( allowedNodeEnvironmentFlags , name ) ;
260
263
}
261
264
}
262
265
263
266
for ( const [ from , expansion ] of aliases ) {
264
267
let isAccepted = true ;
265
268
for ( const to of expansion ) {
266
- if ( ! to . startsWith ( '-' ) || to === '--' ) continue ;
269
+ if ( ! StringPrototypeStartsWith ( to , '-' ) || to === '--' ) continue ;
267
270
const recursiveExpansion = aliases . get ( to ) ;
268
271
if ( recursiveExpansion ) {
269
272
if ( recursiveExpansion [ 0 ] === to )
270
- recursiveExpansion . splice ( 0 , 1 ) ;
271
- expansion . push ( ...recursiveExpansion ) ;
273
+ ArrayPrototypeSplice ( recursiveExpansion , 0 , 1 ) ;
274
+ ArrayPrototypePush ( expansion , ...recursiveExpansion ) ;
272
275
continue ;
273
276
}
274
277
isAccepted = options . get ( to ) . envVarSettings === kAllowedInEnvironment ;
275
278
if ( ! isAccepted ) break ;
276
279
}
277
280
if ( isAccepted ) {
278
281
let canonical = from ;
279
- if ( canonical . endsWith ( '=' ) )
280
- canonical = canonical . substr ( 0 , canonical . length - 1 ) ;
281
- if ( canonical . endsWith ( ' <arg>' ) )
282
- canonical = canonical . substr ( 0 , canonical . length - 4 ) ;
283
- allowedNodeEnvironmentFlags . push ( canonical ) ;
282
+ if ( StringPrototypeEndsWith ( canonical , '=' ) )
283
+ canonical = StringPrototypeSlice ( canonical , 0 , canonical . length - 1 ) ;
284
+ if ( StringPrototypeEndsWith ( canonical , ' <arg>' ) )
285
+ canonical = StringPrototypeSlice ( canonical , 0 , canonical . length - 4 ) ;
286
+ ArrayPrototypePush ( allowedNodeEnvironmentFlags , canonical ) ;
284
287
}
285
288
}
286
289
@@ -289,14 +292,10 @@ function buildAllowedFlags() {
289
292
290
293
// Save these for comparison against flags provided to
291
294
// process.allowedNodeEnvironmentFlags.has() which lack leading dashes.
292
- // Avoid interference w/ user code by flattening `Set.prototype` into
293
- // each object.
294
- const nodeFlags = ObjectDefineProperties (
295
- new Set ( allowedNodeEnvironmentFlags . map ( trimLeadingDashes ) ) ,
296
- ObjectGetOwnPropertyDescriptors ( SetPrototype )
297
- ) ;
298
-
299
- class NodeEnvironmentFlagsSet extends Set {
295
+ const nodeFlags = new SafeSet ( ArrayPrototypeMap ( allowedNodeEnvironmentFlags ,
296
+ trimLeadingDashes ) ) ;
297
+
298
+ class NodeEnvironmentFlagsSet extends SafeSet {
300
299
constructor ( ...args ) {
301
300
super ( ...args ) ;
302
301
@@ -328,9 +327,9 @@ function buildAllowedFlags() {
328
327
key = StringPrototypeReplace ( key , replaceUnderscoresRegex , '-' ) ;
329
328
if ( RegExpPrototypeTest ( leadingDashesRegex , key ) ) {
330
329
key = StringPrototypeReplace ( key , trailingValuesRegex , '' ) ;
331
- return SetPrototypeHas ( this , key ) ;
330
+ return super . has ( key ) ;
332
331
}
333
- return SetPrototypeHas ( nodeFlags , key ) ;
332
+ return nodeFlags . has ( key ) ;
334
333
}
335
334
return false ;
336
335
}
0 commit comments