@@ -330,24 +330,47 @@ EventEmitter.setMaxListeners =
330330EventEmitter . init = function ( opts ) {
331331
332332 if ( this . _events === undefined ||
333- this . _events === ObjectGetPrototypeOf ( this ) . _events ) {
334- this . _events = { __proto__ : null } ;
335- this . _eventsCount = 0 ;
336- this [ kShapeMode ] = false ;
333+ this . _events === ObjectGetPrototypeOf ( this ) . _events ) {
334+ ObjectDefineProperties ( this , {
335+ __proto__ : null ,
336+ _events : {
337+ __proto__ : null ,
338+ value : { __proto__ : null } ,
339+ } ,
340+ _eventCount : {
341+ __proto__ : null ,
342+ value : 0 ,
343+ } ,
344+ [ kShapeMode ] : {
345+ __proto__ : null ,
346+ value : false ,
347+ } ,
348+ } ) ;
337349 } else {
338- this [ kShapeMode ] = true ;
350+ ObjectDefineProperty ( this , kShapeMode , {
351+ __proto__ : null ,
352+ value : true ,
353+ } ) ;
339354 }
340355
341- this . _maxListeners ||= undefined ;
342-
356+ ObjectDefineProperty ( this , '_maxListeners' , {
357+ __proto__ : null ,
358+ value : this . _maxListeners || undefined ,
359+ } ) ;
343360
344361 if ( opts ?. captureRejections ) {
345362 validateBoolean ( opts . captureRejections , 'options.captureRejections' ) ;
346- this [ kCapture ] = Boolean ( opts . captureRejections ) ;
363+ ObjectDefineProperty ( this , kCapture , {
364+ __proto__ : null ,
365+ value : Boolean ( opts . captureRejections ) ,
366+ } ) ;
347367 } else {
348368 // Assigning the kCapture property directly saves an expensive
349369 // prototype lookup in a very sensitive hot path.
350- this [ kCapture ] = EventEmitter . prototype [ kCapture ] ;
370+ ObjectDefineProperty ( this , kCapture , {
371+ __proto__ : null ,
372+ value : Boolean ( opts . captureRejections ) ,
373+ } ) ;
351374 }
352375} ;
353376
0 commit comments