33
44'use strict' ;
55
6+ const {
7+ FunctionPrototype,
8+ FunctionPrototypeCall,
9+ } = primordials ;
610const {
711 ERR_STREAM_PREMATURE_CLOSE
812} = require ( 'internal/errors' ) . codes ;
@@ -53,7 +57,7 @@ function isWritableFinished(stream) {
5357 return wState . finished || ( wState . ended && wState . length === 0 ) ;
5458}
5559
56- function nop ( ) { }
60+ const nop = FunctionPrototype ;
5761
5862function isReadableEnded ( stream ) {
5963 if ( stream . readableEnded ) return true ;
@@ -110,7 +114,7 @@ function eos(stream, options, callback) {
110114 if ( stream . destroyed ) willEmitClose = false ;
111115
112116 if ( willEmitClose && ( ! stream . readable || readable ) ) return ;
113- if ( ! readable || readableEnded ) callback . call ( stream ) ;
117+ if ( ! readable || readableEnded ) FunctionPrototypeCall ( callback , stream ) ;
114118 } ;
115119
116120 let readableEnded = stream . readableEnded ||
@@ -123,23 +127,25 @@ function eos(stream, options, callback) {
123127 if ( stream . destroyed ) willEmitClose = false ;
124128
125129 if ( willEmitClose && ( ! stream . writable || writable ) ) return ;
126- if ( ! writable || writableFinished ) callback . call ( stream ) ;
130+ if ( ! writable || writableFinished ) FunctionPrototypeCall ( callback , stream ) ;
127131 } ;
128132
129133 const onerror = ( err ) => {
130- callback . call ( stream , err ) ;
134+ FunctionPrototypeCall ( callback , stream , err ) ;
131135 } ;
132136
133137 const onclose = ( ) => {
134138 if ( readable && ! readableEnded ) {
135139 if ( ! isReadableEnded ( stream ) )
136- return callback . call ( stream , new ERR_STREAM_PREMATURE_CLOSE ( ) ) ;
140+ return FunctionPrototypeCall ( callback , stream ,
141+ new ERR_STREAM_PREMATURE_CLOSE ( ) ) ;
137142 }
138143 if ( writable && ! writableFinished ) {
139144 if ( ! isWritableFinished ( stream ) )
140- return callback . call ( stream , new ERR_STREAM_PREMATURE_CLOSE ( ) ) ;
145+ return FunctionPrototypeCall ( callback , stream ,
146+ new ERR_STREAM_PREMATURE_CLOSE ( ) ) ;
141147 }
142- callback . call ( stream ) ;
148+ FunctionPrototypeCall ( callback , stream ) ;
143149 } ;
144150
145151 const onrequest = ( ) => {
0 commit comments