@@ -330,24 +330,47 @@ EventEmitter.setMaxListeners =
330
330
EventEmitter . init = function ( opts ) {
331
331
332
332
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
+ } ) ;
337
349
} else {
338
- this [ kShapeMode ] = true ;
350
+ ObjectDefineProperty ( this , kShapeMode , {
351
+ __proto__ : null ,
352
+ value : true ,
353
+ } ) ;
339
354
}
340
355
341
- this . _maxListeners ||= undefined ;
342
-
356
+ ObjectDefineProperty ( this , '_maxListeners' , {
357
+ __proto__ : null ,
358
+ value : this . _maxListeners || undefined ,
359
+ } ) ;
343
360
344
361
if ( opts ?. captureRejections ) {
345
362
validateBoolean ( opts . captureRejections , 'options.captureRejections' ) ;
346
- this [ kCapture ] = Boolean ( opts . captureRejections ) ;
363
+ ObjectDefineProperty ( this , kCapture , {
364
+ __proto__ : null ,
365
+ value : Boolean ( opts . captureRejections ) ,
366
+ } ) ;
347
367
} else {
348
368
// Assigning the kCapture property directly saves an expensive
349
369
// 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
+ } ) ;
351
374
}
352
375
} ;
353
376
0 commit comments