44
44
/* global process, getLinkedBinding, getInternalBinding, primordials */
45
45
46
46
const {
47
+ ArrayPrototypeMap,
48
+ ArrayPrototypePush,
47
49
Error,
48
- Map,
49
50
ObjectCreate,
50
51
ObjectDefineProperty,
51
52
ObjectKeys,
52
53
ObjectPrototypeHasOwnProperty,
53
54
ReflectGet,
55
+ SafeMap,
54
56
SafeSet,
55
57
String,
58
+ StringPrototypeStartsWith,
56
59
TypeError,
57
60
} = primordials ;
58
61
@@ -135,7 +138,7 @@ let internalBinding;
135
138
let mod = bindingObj [ module ] ;
136
139
if ( typeof mod !== 'object' ) {
137
140
mod = bindingObj [ module ] = getInternalBinding ( module ) ;
138
- moduleLoadList . push ( `Internal Binding ${ module } ` ) ;
141
+ ArrayPrototypePush ( moduleLoadList , `Internal Binding ${ module } ` ) ;
139
142
}
140
143
return mod ;
141
144
} ;
@@ -163,12 +166,14 @@ class NativeModule {
163
166
* A map from the module IDs to the module instances.
164
167
* @type {Map<string, NativeModule> }
165
168
*/
166
- static map = new Map ( moduleIds . map ( ( id ) => [ id , new NativeModule ( id ) ] ) ) ;
169
+ static map = new SafeMap (
170
+ ArrayPrototypeMap ( moduleIds , ( id ) => [ id , new NativeModule ( id ) ] )
171
+ ) ;
167
172
168
173
constructor ( id ) {
169
174
this . filename = `${ id } .js` ;
170
175
this . id = id ;
171
- this . canBeRequiredByUsers = ! id . startsWith ( 'internal/' ) ;
176
+ this . canBeRequiredByUsers = ! StringPrototypeStartsWith ( id , 'internal/' ) ;
172
177
173
178
// The CJS exports object of the module.
174
179
this . exports = { } ;
@@ -221,7 +226,7 @@ class NativeModule {
221
226
if ( ! this . exportKeys ) {
222
227
// When using --expose-internals, we do not want to reflect the named
223
228
// exports from core modules as this can trigger unnecessary getters.
224
- const internal = this . id . startsWith ( 'internal/' ) ;
229
+ const internal = StringPrototypeStartsWith ( this . id , 'internal/' ) ;
225
230
this . exportKeys = internal ? [ ] : ObjectKeys ( this . exports ) ;
226
231
}
227
232
this . getESMFacade ( ) ;
@@ -271,7 +276,7 @@ class NativeModule {
271
276
this . loading = true ;
272
277
273
278
try {
274
- const requireFn = this . id . startsWith ( 'internal/deps/' ) ?
279
+ const requireFn = StringPrototypeStartsWith ( this . id , 'internal/deps/' ) ?
275
280
requireWithFallbackInDeps : nativeModuleRequire ;
276
281
277
282
const fn = compileFunction ( id ) ;
@@ -282,7 +287,7 @@ class NativeModule {
282
287
this . loading = false ;
283
288
}
284
289
285
- moduleLoadList . push ( `NativeModule ${ id } ` ) ;
290
+ ArrayPrototypePush ( moduleLoadList , `NativeModule ${ id } ` ) ;
286
291
return this . exports ;
287
292
}
288
293
}
0 commit comments