@@ -30,7 +30,7 @@ var Duplex;
3030Readable . ReadableState = ReadableState ;
3131
3232/*<replacement>*/
33- const EE = require ( 'events' ) . EventEmitter ;
33+ var EE = require ( 'events' ) . EventEmitter ;
3434var EElistenerCount = function EElistenerCount ( emitter , type ) {
3535 return emitter . listeners ( type ) . length ;
3636} ;
@@ -40,8 +40,8 @@ var EElistenerCount = function EElistenerCount(emitter, type) {
4040var Stream = require ( './internal/streams/stream' ) ;
4141/*</replacement>*/
4242
43- const Buffer = require ( 'buffer' ) . Buffer ;
44- const OurUint8Array = ( typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : { } ) . Uint8Array || function ( ) { } ;
43+ var Buffer = require ( 'buffer' ) . Buffer ;
44+ var OurUint8Array = ( typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : { } ) . Uint8Array || function ( ) { } ;
4545function _uint8ArrayToBuffer ( chunk ) {
4646 return Buffer . from ( chunk ) ;
4747}
@@ -50,32 +50,32 @@ function _isUint8Array(obj) {
5050}
5151
5252/*<replacement>*/
53- const debugUtil = require ( 'util' ) ;
54- let debug ;
53+ var debugUtil = require ( 'util' ) ;
54+ var debug ;
5555if ( debugUtil && debugUtil . debuglog ) {
5656 debug = debugUtil . debuglog ( 'stream' ) ;
5757} else {
5858 debug = function debug ( ) { } ;
5959}
6060/*</replacement>*/
6161
62- const BufferList = require ( './internal/streams/buffer_list' ) ;
63- const destroyImpl = require ( './internal/streams/destroy' ) ;
64- const _require = require ( './internal/streams/state' ) ,
62+ var BufferList = require ( './internal/streams/buffer_list' ) ;
63+ var destroyImpl = require ( './internal/streams/destroy' ) ;
64+ var _require = require ( './internal/streams/state' ) ,
6565 getHighWaterMark = _require . getHighWaterMark ;
66- const _require$codes = require ( '../errors' ) . codes ,
66+ var _require$codes = require ( '../errors' ) . codes ,
6767 ERR_INVALID_ARG_TYPE = _require$codes . ERR_INVALID_ARG_TYPE ,
6868 ERR_STREAM_PUSH_AFTER_EOF = _require$codes . ERR_STREAM_PUSH_AFTER_EOF ,
6969 ERR_METHOD_NOT_IMPLEMENTED = _require$codes . ERR_METHOD_NOT_IMPLEMENTED ,
7070 ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes . ERR_STREAM_UNSHIFT_AFTER_END_EVENT ;
7171
7272// Lazy loaded to improve the startup performance.
73- let StringDecoder ;
74- let createReadableStreamAsyncIterator ;
75- let from ;
73+ var StringDecoder ;
74+ var createReadableStreamAsyncIterator ;
75+ var from ;
7676require ( 'inherits' ) ( Readable , Stream ) ;
77- const errorOrDestroy = destroyImpl . errorOrDestroy ;
78- const kProxyEvents = [ 'error' , 'close' , 'destroy' , 'pause' , 'resume' ] ;
77+ var errorOrDestroy = destroyImpl . errorOrDestroy ;
78+ var kProxyEvents = [ 'error' , 'close' , 'destroy' , 'pause' , 'resume' ] ;
7979function prependListener ( emitter , event , fn ) {
8080 // Sadly this is not cacheable as some libraries bundle their own
8181 // event emitter implementation with them.
@@ -166,7 +166,7 @@ function Readable(options) {
166166
167167 // Checking for a Stream.Duplex instance is faster here instead of inside
168168 // the ReadableState constructor, at least with V8 6.5
169- const isDuplex = this instanceof Duplex ;
169+ var isDuplex = this instanceof Duplex ;
170170 this . _readableState = new ReadableState ( options , this , isDuplex ) ;
171171
172172 // legacy
@@ -182,13 +182,13 @@ Object.defineProperty(Readable.prototype, 'destroyed', {
182182 // because otherwise some prototype manipulation in
183183 // userland will fail
184184 enumerable : false ,
185- get ( ) {
185+ get : function get ( ) {
186186 if ( this . _readableState === undefined ) {
187187 return false ;
188188 }
189189 return this . _readableState . destroyed ;
190190 } ,
191- set ( value ) {
191+ set : function set ( value ) {
192192 // we ignore the value if the stream
193193 // has not been initialized yet
194194 if ( ! this . _readableState ) {
@@ -299,14 +299,14 @@ Readable.prototype.isPaused = function () {
299299// backwards compatibility.
300300Readable . prototype . setEncoding = function ( enc ) {
301301 if ( ! StringDecoder ) StringDecoder = require ( 'string_decoder/' ) . StringDecoder ;
302- const decoder = new StringDecoder ( enc ) ;
302+ var decoder = new StringDecoder ( enc ) ;
303303 this . _readableState . decoder = decoder ;
304304 // If setEncoding(null), decoder.encoding equals utf8
305305 this . _readableState . encoding = this . _readableState . decoder . encoding ;
306306
307307 // Iterate over current buffer to convert already stored Buffers:
308- let p = this . _readableState . buffer . head ;
309- let content = '' ;
308+ var p = this . _readableState . buffer . head ;
309+ var content = '' ;
310310 while ( p !== null ) {
311311 content += decoder . write ( p . data ) ;
312312 p = p . next ;
@@ -318,7 +318,7 @@ Readable.prototype.setEncoding = function (enc) {
318318} ;
319319
320320// Don't raise the hwm > 1GB
321- const MAX_HWM = 0x40000000 ;
321+ var MAX_HWM = 0x40000000 ;
322322function computeNewHighWaterMark ( n ) {
323323 if ( n >= MAX_HWM ) {
324324 // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
@@ -545,7 +545,7 @@ function maybeReadMore_(stream, state) {
545545 // read()s. The execution ends in this method again after the _read() ends
546546 // up calling push() with more data.
547547 while ( ! state . reading && ! state . ended && ( state . length < state . highWaterMark || state . flowing && state . length === 0 ) ) {
548- const len = state . length ;
548+ var len = state . length ;
549549 debug ( 'maybeReadMore read 0' ) ;
550550 stream . read ( 0 ) ;
551551 if ( len === state . length )
@@ -742,8 +742,8 @@ Readable.prototype.unpipe = function (dest) {
742742// set up data events if they are asked for
743743// Ensure readable listeners eventually get something
744744Readable . prototype . on = function ( ev , fn ) {
745- const res = Stream . prototype . on . call ( this , ev , fn ) ;
746- const state = this . _readableState ;
745+ var res = Stream . prototype . on . call ( this , ev , fn ) ;
746+ var state = this . _readableState ;
747747 if ( ev === 'data' ) {
748748 // update readableListening so that resume() may be a no-op
749749 // a few lines down. This is needed to support once('readable').
@@ -768,7 +768,7 @@ Readable.prototype.on = function (ev, fn) {
768768} ;
769769Readable . prototype . addListener = Readable . prototype . on ;
770770Readable . prototype . removeListener = function ( ev , fn ) {
771- const res = Stream . prototype . removeListener . call ( this , ev , fn ) ;
771+ var res = Stream . prototype . removeListener . call ( this , ev , fn ) ;
772772 if ( ev === 'readable' ) {
773773 // We need to check if there is someone still listening to
774774 // readable and reset the state. However this needs to happen
@@ -781,7 +781,7 @@ Readable.prototype.removeListener = function (ev, fn) {
781781 return res ;
782782} ;
783783Readable . prototype . removeAllListeners = function ( ev ) {
784- const res = Stream . prototype . removeAllListeners . apply ( this , arguments ) ;
784+ var res = Stream . prototype . removeAllListeners . apply ( this , arguments ) ;
785785 if ( ev === 'readable' || ev === undefined ) {
786786 // We need to check if there is someone still listening to
787787 // readable and reset the state. However this needs to happen
@@ -794,7 +794,7 @@ Readable.prototype.removeAllListeners = function (ev) {
794794 return res ;
795795} ;
796796function updateReadableListening ( self ) {
797- const state = self . _readableState ;
797+ var state = self . _readableState ;
798798 state . readableListening = self . listenerCount ( 'readable' ) > 0 ;
799799 if ( state . resumeScheduled && ! state . paused ) {
800800 // flowing needs to be set to true now, otherwise
@@ -853,7 +853,7 @@ Readable.prototype.pause = function () {
853853 return this ;
854854} ;
855855function flow ( stream ) {
856- const state = stream . _readableState ;
856+ var state = stream . _readableState ;
857857 debug ( 'flow' , state . flowing ) ;
858858 while ( state . flowing && stream . read ( ) !== null ) ;
859859}
@@ -862,23 +862,24 @@ function flow(stream) {
862862// This is *not* part of the readable stream interface.
863863// It is an ugly unfortunate mess of history.
864864Readable . prototype . wrap = function ( stream ) {
865+ var _this = this ;
865866 var state = this . _readableState ;
866867 var paused = false ;
867- stream . on ( 'end' , ( ) => {
868+ stream . on ( 'end' , function ( ) {
868869 debug ( 'wrapped end' ) ;
869870 if ( state . decoder && ! state . ended ) {
870871 var chunk = state . decoder . end ( ) ;
871- if ( chunk && chunk . length ) this . push ( chunk ) ;
872+ if ( chunk && chunk . length ) _this . push ( chunk ) ;
872873 }
873- this . push ( null ) ;
874+ _this . push ( null ) ;
874875 } ) ;
875- stream . on ( 'data' , chunk => {
876+ stream . on ( 'data' , function ( chunk ) {
876877 debug ( 'wrapped data' ) ;
877878 if ( state . decoder ) chunk = state . decoder . write ( chunk ) ;
878879
879880 // don't skip over falsy values in objectMode
880881 if ( state . objectMode && ( chunk === null || chunk === undefined ) ) return ; else if ( ! state . objectMode && ( ! chunk || ! chunk . length ) ) return ;
881- var ret = this . push ( chunk ) ;
882+ var ret = _this . push ( chunk ) ;
882883 if ( ! ret ) {
883884 paused = true ;
884885 stream . pause ( ) ;
@@ -904,7 +905,7 @@ Readable.prototype.wrap = function (stream) {
904905
905906 // when we try to consume some more bytes, simply unpause the
906907 // underlying stream.
907- this . _read = n => {
908+ this . _read = function ( n ) {
908909 debug ( 'wrapped _read' , n ) ;
909910 if ( paused ) {
910911 paused = false ;
@@ -961,7 +962,7 @@ Object.defineProperty(Readable.prototype, 'readableLength', {
961962 // because otherwise some prototype manipulation in
962963 // userland will fail
963964 enumerable : false ,
964- get ( ) {
965+ get : function get ( ) {
965966 return this . _readableState . length ;
966967 }
967968} ) ;
@@ -1003,7 +1004,7 @@ function endReadableNT(state, stream) {
10031004 if ( state . autoDestroy ) {
10041005 // In case of duplex streams we need a way to detect
10051006 // if the writable side is ready for autoDestroy as well
1006- const wState = stream . _writableState ;
1007+ var wState = stream . _writableState ;
10071008 if ( ! wState || wState . autoDestroy && wState . finished ) {
10081009 stream . destroy ( ) ;
10091010 }
0 commit comments