4040'use strict' ;
4141
4242// This file is compiled as if it's wrapped in a function with arguments
43- // passed by node::LoadEnvironment ()
43+ // passed by node::RunBootstrapping ()
4444/* global process, getBinding, getLinkedBinding, getInternalBinding */
45- /* global debugBreak, experimentalModules, exposeInternals */
45+ /* global experimentalModules, exposeInternals, primordials */
4646
47- if ( debugBreak )
48- debugger ; // eslint-disable-line no-debugger
49-
50- const {
51- apply : ReflectApply ,
52- deleteProperty : ReflectDeleteProperty ,
53- get : ReflectGet ,
54- getOwnPropertyDescriptor : ReflectGetOwnPropertyDescriptor ,
55- has : ReflectHas ,
56- set : ReflectSet ,
57- } = Reflect ;
5847const {
59- prototype : {
60- hasOwnProperty : ObjectHasOwnProperty ,
61- } ,
62- create : ObjectCreate ,
63- defineProperty : ObjectDefineProperty ,
64- keys : ObjectKeys ,
65- } = Object ;
48+ Reflect,
49+ Object,
50+ ObjectPrototype,
51+ SafeSet
52+ } = primordials ;
6653
6754// Set up process.moduleLoadList.
6855const moduleLoadList = [ ] ;
69- ObjectDefineProperty ( process , 'moduleLoadList' , {
56+ Object . defineProperty ( process , 'moduleLoadList' , {
7057 value : moduleLoadList ,
7158 configurable : true ,
7259 enumerable : true ,
@@ -78,7 +65,7 @@ ObjectDefineProperty(process, 'moduleLoadList', {
7865// that are whitelisted for access via process.binding()... This is used
7966// to provide a transition path for modules that are being moved over to
8067// internalBinding.
81- const internalBindingWhitelist = [
68+ const internalBindingWhitelist = new SafeSet ( [
8269 'async_wrap' ,
8370 'buffer' ,
8471 'cares_wrap' ,
@@ -108,20 +95,17 @@ const internalBindingWhitelist = [
10895 'uv' ,
10996 'v8' ,
11097 'zlib'
111- ] ;
112- // We will use a lazy loaded SafeSet in internalBindingWhitelistHas
113- // for checking existence in this list.
114- let internalBindingWhitelistSet ;
98+ ] ) ;
11599
116100// Set up process.binding() and process._linkedBinding().
117101{
118- const bindingObj = ObjectCreate ( null ) ;
102+ const bindingObj = Object . create ( null ) ;
119103
120104 process . binding = function binding ( module ) {
121105 module = String ( module ) ;
122106 // Deprecated specific process.binding() modules, but not all, allow
123107 // selective fallback to internalBinding for the deprecated ones.
124- if ( internalBindingWhitelistHas ( module ) ) {
108+ if ( internalBindingWhitelist . has ( module ) ) {
125109 return internalBinding ( module ) ;
126110 }
127111 let mod = bindingObj [ module ] ;
@@ -144,7 +128,7 @@ let internalBindingWhitelistSet;
144128// Set up internalBinding() in the closure.
145129let internalBinding ;
146130{
147- const bindingObj = ObjectCreate ( null ) ;
131+ const bindingObj = Object . create ( null ) ;
148132 internalBinding = function internalBinding ( module ) {
149133 let mod = bindingObj [ module ] ;
150134 if ( typeof mod !== 'object' ) {
@@ -245,8 +229,8 @@ NativeModule.requireWithFallbackInDeps = function(request) {
245229} ;
246230
247231const getOwn = ( target , property , receiver ) => {
248- return ReflectApply ( ObjectHasOwnProperty , target , [ property ] ) ?
249- ReflectGet ( target , property , receiver ) :
232+ return Reflect . apply ( ObjectPrototype . hasOwnProperty , target , [ property ] ) ?
233+ Reflect . get ( target , property , receiver ) :
250234 undefined ;
251235} ;
252236
@@ -255,12 +239,12 @@ const getOwn = (target, property, receiver) => {
255239// as the entire namespace (module.exports) and wrapped in a proxy such
256240// that APMs and other behavior are still left intact.
257241NativeModule . prototype . proxifyExports = function ( ) {
258- this . exportKeys = ObjectKeys ( this . exports ) ;
242+ this . exportKeys = Object . keys ( this . exports ) ;
259243
260244 const update = ( property , value ) => {
261245 if ( this . reflect !== undefined &&
262- ReflectApply ( ObjectHasOwnProperty ,
263- this . reflect . exports , [ property ] ) )
246+ Reflect . apply ( ObjectPrototype . hasOwnProperty ,
247+ this . reflect . exports , [ property ] ) )
264248 this . reflect . exports [ property ] . set ( value ) ;
265249 } ;
266250
@@ -269,12 +253,12 @@ NativeModule.prototype.proxifyExports = function() {
269253 defineProperty : ( target , prop , descriptor ) => {
270254 // Use `Object.defineProperty` instead of `Reflect.defineProperty`
271255 // to throw the appropriate error if something goes wrong.
272- ObjectDefineProperty ( target , prop , descriptor ) ;
256+ Object . defineProperty ( target , prop , descriptor ) ;
273257 if ( typeof descriptor . get === 'function' &&
274- ! ReflectHas ( handler , 'get' ) ) {
258+ ! Reflect . has ( handler , 'get' ) ) {
275259 handler . get = ( target , prop , receiver ) => {
276- const value = ReflectGet ( target , prop , receiver ) ;
277- if ( ReflectApply ( ObjectHasOwnProperty , target , [ prop ] ) )
260+ const value = Reflect . get ( target , prop , receiver ) ;
261+ if ( Reflect . apply ( ObjectPrototype . hasOwnProperty , target , [ prop ] ) )
278262 update ( prop , value ) ;
279263 return value ;
280264 } ;
@@ -283,15 +267,15 @@ NativeModule.prototype.proxifyExports = function() {
283267 return true ;
284268 } ,
285269 deleteProperty : ( target , prop ) => {
286- if ( ReflectDeleteProperty ( target , prop ) ) {
270+ if ( Reflect . deleteProperty ( target , prop ) ) {
287271 update ( prop , undefined ) ;
288272 return true ;
289273 }
290274 return false ;
291275 } ,
292276 set : ( target , prop , value , receiver ) => {
293- const descriptor = ReflectGetOwnPropertyDescriptor ( target , prop ) ;
294- if ( ReflectSet ( target , prop , value , receiver ) ) {
277+ const descriptor = Reflect . getOwnPropertyDescriptor ( target , prop ) ;
278+ if ( Reflect . set ( target , prop , value , receiver ) ) {
295279 if ( descriptor && typeof descriptor . set === 'function' ) {
296280 for ( const key of this . exportKeys ) {
297281 update ( key , getOwn ( target , key , receiver ) ) ;
@@ -319,7 +303,7 @@ NativeModule.prototype.compile = function() {
319303 NativeModule . require ;
320304
321305 const fn = compileFunction ( id ) ;
322- fn ( this . exports , requireFn , this , process , internalBinding ) ;
306+ fn ( this . exports , requireFn , this , process , internalBinding , primordials ) ;
323307
324308 if ( experimentalModules && this . canBeRequiredByUsers ) {
325309 this . proxifyExports ( ) ;
@@ -344,13 +328,5 @@ if (process.env.NODE_V8_COVERAGE) {
344328 }
345329}
346330
347- function internalBindingWhitelistHas ( name ) {
348- if ( ! internalBindingWhitelistSet ) {
349- const { SafeSet } = NativeModule . require ( 'internal/safe_globals' ) ;
350- internalBindingWhitelistSet = new SafeSet ( internalBindingWhitelist ) ;
351- }
352- return internalBindingWhitelistSet . has ( name ) ;
353- }
354-
355331// This will be passed to internal/bootstrap/node.js.
356332return loaderExports ;
0 commit comments