4444/* global process, getLinkedBinding, getInternalBinding, primordials */
4545
4646const {
47+ ArrayPrototypeMap,
48+ ArrayPrototypePush,
4749 Error,
48- Map,
4950 ObjectCreate,
5051 ObjectDefineProperty,
5152 ObjectKeys,
5253 ObjectPrototypeHasOwnProperty,
5354 ReflectGet,
55+ SafeMap,
5456 SafeSet,
5557 String,
58+ StringPrototypeStartsWith,
5659 TypeError,
5760} = primordials ;
5861
@@ -135,7 +138,7 @@ let internalBinding;
135138 let mod = bindingObj [ module ] ;
136139 if ( typeof mod !== 'object' ) {
137140 mod = bindingObj [ module ] = getInternalBinding ( module ) ;
138- moduleLoadList . push ( `Internal Binding ${ module } ` ) ;
141+ ArrayPrototypePush ( moduleLoadList , `Internal Binding ${ module } ` ) ;
139142 }
140143 return mod ;
141144 } ;
@@ -163,12 +166,14 @@ class NativeModule {
163166 * A map from the module IDs to the module instances.
164167 * @type {Map<string, NativeModule> }
165168 */
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+ ) ;
167172
168173 constructor ( id ) {
169174 this . filename = `${ id } .js` ;
170175 this . id = id ;
171- this . canBeRequiredByUsers = ! id . startsWith ( 'internal/' ) ;
176+ this . canBeRequiredByUsers = ! StringPrototypeStartsWith ( id , 'internal/' ) ;
172177
173178 // The CJS exports object of the module.
174179 this . exports = { } ;
@@ -221,7 +226,7 @@ class NativeModule {
221226 if ( ! this . exportKeys ) {
222227 // When using --expose-internals, we do not want to reflect the named
223228 // exports from core modules as this can trigger unnecessary getters.
224- const internal = this . id . startsWith ( 'internal/' ) ;
229+ const internal = StringPrototypeStartsWith ( this . id , 'internal/' ) ;
225230 this . exportKeys = internal ? [ ] : ObjectKeys ( this . exports ) ;
226231 }
227232 this . getESMFacade ( ) ;
@@ -271,7 +276,7 @@ class NativeModule {
271276 this . loading = true ;
272277
273278 try {
274- const requireFn = this . id . startsWith ( 'internal/deps/' ) ?
279+ const requireFn = StringPrototypeStartsWith ( this . id , 'internal/deps/' ) ?
275280 requireWithFallbackInDeps : nativeModuleRequire ;
276281
277282 const fn = compileFunction ( id ) ;
@@ -282,7 +287,7 @@ class NativeModule {
282287 this . loading = false ;
283288 }
284289
285- moduleLoadList . push ( `NativeModule ${ id } ` ) ;
290+ ArrayPrototypePush ( moduleLoadList , `NativeModule ${ id } ` ) ;
286291 return this . exports ;
287292 }
288293}
0 commit comments