11'use strict' ;
22
33const {
4+ ArrayPrototypeMap,
5+ ArrayPrototypePush,
6+ FunctionPrototypeCall,
47 ObjectAssign,
58 ObjectCreate,
69 ObjectDefineProperty,
710 ObjectGetOwnPropertyDescriptors,
811 ObjectGetPrototypeOf,
912 ObjectSetPrototypeOf,
13+ ReflectApply,
1014 Symbol,
1115} = primordials ;
1216
@@ -87,7 +91,7 @@ ObjectDefineProperty(
8791{
8892value : function ( data , type ) {
8993if ( type !== 'message' && type !== 'messageerror' ) {
90- return originalCreateEvent . call ( this , data , type ) ;
94+ return ReflectApply ( originalCreateEvent , this , arguments ) ;
9195}
9296return new MessageEvent ( data , this , type ) ;
9397} ,
@@ -131,7 +135,7 @@ ObjectDefineProperty(MessagePort.prototype, handleOnCloseSymbol, {
131135MessagePort . prototype . close = function ( cb ) {
132136if ( typeof cb === 'function' )
133137this . once ( 'close' , cb ) ;
134- MessagePortPrototype . close . call ( this ) ;
138+ FunctionPrototypeCall ( MessagePortPrototype . close , this ) ;
135139} ;
136140
137141ObjectDefineProperty ( MessagePort . prototype , inspect . custom , {
@@ -142,7 +146,7 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
142146try {
143147// This may throw when `this` does not refer to a native object,
144148// e.g. when accessing the prototype directly.
145- ref = MessagePortPrototype . hasRef . call ( this ) ;
149+ ref = FunctionPrototypeCall ( MessagePortPrototype . hasRef , this ) ;
146150} catch { return this ; }
147151return ObjectAssign ( ObjectCreate ( MessagePort . prototype ) ,
148152ref === undefined ? {
@@ -170,18 +174,18 @@ function setupPortReferencing(port, eventEmitter, eventName) {
170174const origNewListener = eventEmitter [ kNewListener ] ;
171175eventEmitter [ kNewListener ] = function ( size , type , ...args ) {
172176if ( type === eventName ) newListener ( size - 1 ) ;
173- return origNewListener . call ( this , size , type , ... args ) ;
177+ return ReflectApply ( origNewListener , this , arguments ) ;
174178} ;
175179const origRemoveListener = eventEmitter [ kRemoveListener ] ;
176180eventEmitter [ kRemoveListener ] = function ( size , type , ...args ) {
177181if ( type === eventName ) removeListener ( size ) ;
178- return origRemoveListener . call ( this , size , type , ... args ) ;
182+ return ReflectApply ( origRemoveListener , this , arguments ) ;
179183} ;
180184
181185function newListener ( size ) {
182186if ( size === 0 ) {
183187port . ref ( ) ;
184- MessagePortPrototype . start . call ( port ) ;
188+ FunctionPrototypeCall ( MessagePortPrototype . start , port ) ;
185189}
186190}
187191
@@ -235,9 +239,10 @@ class WritableWorkerStdio extends Writable {
235239this [ kPort ] . postMessage ( {
236240type : messageTypes . STDIO_PAYLOAD ,
237241stream : this [ kName ] ,
238- chunks : chunks . map ( ( { chunk, encoding } ) => ( { chunk, encoding } ) )
242+ chunks : ArrayPrototypeMap ( chunks ,
243+ ( { chunk, encoding } ) => ( { chunk, encoding } ) ) ,
239244} ) ;
240- this [ kWritableCallbacks ] . push ( cb ) ;
245+ ArrayPrototypePush ( this [ kWritableCallbacks ] , cb ) ;
241246if ( this [ kPort ] [ kWaitingStreams ] ++ === 0 )
242247this [ kPort ] . ref ( ) ;
243248}
0 commit comments