66
77const {
88 ArrayIsArray,
9+ ArrayPrototypeMap,
10+ ArrayPrototypePush,
11+ ArrayPrototypeSplice,
912 BigUint64Array,
1013 Float64Array,
1114 NumberMAX_SAFE_INTEGER,
12- ObjectDefineProperties,
1315 ObjectDefineProperty,
1416 ObjectFreeze,
15- ObjectGetOwnPropertyDescriptors ,
17+ ReflectApply ,
1618 RegExpPrototypeTest,
17- Set,
18- SetPrototype,
19- SetPrototypeHas,
19+ SafeSet,
20+ StringPrototypeEndsWith,
2021 StringPrototypeReplace,
22+ StringPrototypeSlice,
23+ StringPrototypeStartsWith,
2124 Uint32Array,
2225} = primordials ;
2326
@@ -94,7 +97,7 @@ function wrapProcessMethods(binding){
9497} = binding ;
9598
9699function _rawDebug ( ...args ) {
97- binding . _rawDebug ( format . apply ( null , args ) ) ;
100+ binding . _rawDebug ( ReflectApply ( format , null , args ) ) ;
98101}
99102
100103// Create the argument array that will be passed to the native function.
@@ -256,31 +259,31 @@ function buildAllowedFlags(){
256259const allowedNodeEnvironmentFlags = [ ] ;
257260for ( const [ name , info ] of options ) {
258261if ( info . envVarSettings === kAllowedInEnvironment ) {
259- allowedNodeEnvironmentFlags . push ( name ) ;
262+ ArrayPrototypePush ( allowedNodeEnvironmentFlags , name ) ;
260263}
261264}
262265
263266for ( const [ from , expansion ] of aliases ) {
264267let isAccepted = true ;
265268for ( const to of expansion ) {
266- if ( ! to . startsWith ( '-' ) || to === '--' ) continue ;
269+ if ( ! StringPrototypeStartsWith ( to , '-' ) || to === '--' ) continue ;
267270const recursiveExpansion = aliases . get ( to ) ;
268271if ( recursiveExpansion ) {
269272if ( recursiveExpansion [ 0 ] === to )
270- recursiveExpansion . splice ( 0 , 1 ) ;
271- expansion . push ( ...recursiveExpansion ) ;
273+ ArrayPrototypeSplice ( recursiveExpansion , 0 , 1 ) ;
274+ ArrayPrototypePush ( expansion , ...recursiveExpansion ) ;
272275continue ;
273276}
274277isAccepted = options . get ( to ) . envVarSettings === kAllowedInEnvironment ;
275278if ( ! isAccepted ) break ;
276279}
277280if ( isAccepted ) {
278281let 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 ) ;
284287}
285288}
286289
@@ -289,14 +292,10 @@ function buildAllowedFlags(){
289292
290293// Save these for comparison against flags provided to
291294// 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 {
300299constructor ( ...args ) {
301300super ( ...args ) ;
302301
@@ -328,9 +327,9 @@ function buildAllowedFlags(){
328327key = StringPrototypeReplace ( key , replaceUnderscoresRegex , '-' ) ;
329328if ( RegExpPrototypeTest ( leadingDashesRegex , key ) ) {
330329key = StringPrototypeReplace ( key , trailingValuesRegex , '' ) ;
331- return SetPrototypeHas ( this , key ) ;
330+ return super . has ( key ) ;
332331}
333- return SetPrototypeHas ( nodeFlags , key ) ;
332+ return nodeFlags . has ( key ) ;
334333}
335334return false ;
336335}
0 commit comments