66 ArrayPrototypeShift,
77 ArrayPrototypeSlice,
88 ArrayPrototypePush,
9- ObjectDefineProperty,
109 ObjectEntries,
1110 ObjectPrototypeHasOwnProperty : ObjectHasOwn ,
1211 StringPrototypeCharAt,
@@ -117,19 +116,9 @@ function checkOptionUsage(longOption, optionValue, options,
117116 */
118117function storeOption ( longOption , optionValue , options , values ) {
119118 if ( longOption === '__proto__' ) {
120- return ;
119+ return ; // No. Just no.
121120 }
122121
123- // Can be removed when value has a null prototype
124- const safeAssignProperty = ( obj , prop , value ) => {
125- ObjectDefineProperty ( obj , prop , {
126- value,
127- writable : true ,
128- enumerable : true ,
129- configurable : true
130- } ) ;
131- } ;
132-
133122 // We store based on the option value rather than option type,
134123 // preserving the users intent for author to deal with.
135124 const newValue = optionValue ?? true ;
@@ -138,13 +127,14 @@ function storeOption(longOption, optionValue, options, values) {
138127 // values[longOption] starts out not present,
139128 // first value is added as new array [newValue],
140129 // subsequent values are pushed to existing array.
141- if ( ObjectHasOwn ( values , longOption ) ) {
130+ // (note: values has null prototype, so simpler usage)
131+ if ( values [ longOption ] ) {
142132 ArrayPrototypePush ( values [ longOption ] , newValue ) ;
143133 } else {
144- safeAssignProperty ( values , longOption , [ newValue ] ) ;
134+ values [ longOption ] = [ newValue ] ;
145135 }
146136 } else {
147- safeAssignProperty ( values , longOption , newValue ) ;
137+ values [ longOption ] = newValue ;
148138 }
149139}
150140
@@ -184,7 +174,7 @@ const parseArgs = (config = { __proto__: null }) => {
184174 ) ;
185175
186176 const result = {
187- values : { } ,
177+ values : { __proto__ : null } ,
188178 positionals : [ ]
189179 } ;
190180
0 commit comments