@@ -30,7 +30,7 @@ var Duplex;
30
30
Readable . ReadableState = ReadableState ;
31
31
32
32
/*<replacement>*/
33
- const EE = require ( 'events' ) . EventEmitter ;
33
+ var EE = require ( 'events' ) . EventEmitter ;
34
34
var EElistenerCount = function EElistenerCount ( emitter , type ) {
35
35
return emitter . listeners ( type ) . length ;
36
36
} ;
@@ -40,8 +40,8 @@ var EElistenerCount = function EElistenerCount(emitter, type) {
40
40
var Stream = require ( './internal/streams/stream' ) ;
41
41
/*</replacement>*/
42
42
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 ( ) { } ;
45
45
function _uint8ArrayToBuffer ( chunk ) {
46
46
return Buffer . from ( chunk ) ;
47
47
}
@@ -50,32 +50,32 @@ function _isUint8Array(obj) {
50
50
}
51
51
52
52
/*<replacement>*/
53
- const debugUtil = require ( 'util' ) ;
54
- let debug ;
53
+ var debugUtil = require ( 'util' ) ;
54
+ var debug ;
55
55
if ( debugUtil && debugUtil . debuglog ) {
56
56
debug = debugUtil . debuglog ( 'stream' ) ;
57
57
} else {
58
58
debug = function debug ( ) { } ;
59
59
}
60
60
/*</replacement>*/
61
61
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' ) ,
65
65
getHighWaterMark = _require . getHighWaterMark ;
66
- const _require$codes = require ( '../errors' ) . codes ,
66
+ var _require$codes = require ( '../errors' ) . codes ,
67
67
ERR_INVALID_ARG_TYPE = _require$codes . ERR_INVALID_ARG_TYPE ,
68
68
ERR_STREAM_PUSH_AFTER_EOF = _require$codes . ERR_STREAM_PUSH_AFTER_EOF ,
69
69
ERR_METHOD_NOT_IMPLEMENTED = _require$codes . ERR_METHOD_NOT_IMPLEMENTED ,
70
70
ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes . ERR_STREAM_UNSHIFT_AFTER_END_EVENT ;
71
71
72
72
// 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 ;
76
76
require ( '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' ] ;
79
79
function prependListener ( emitter , event , fn ) {
80
80
// Sadly this is not cacheable as some libraries bundle their own
81
81
// event emitter implementation with them.
@@ -166,7 +166,7 @@ function Readable(options) {
166
166
167
167
// Checking for a Stream.Duplex instance is faster here instead of inside
168
168
// the ReadableState constructor, at least with V8 6.5
169
- const isDuplex = this instanceof Duplex ;
169
+ var isDuplex = this instanceof Duplex ;
170
170
this . _readableState = new ReadableState ( options , this , isDuplex ) ;
171
171
172
172
// legacy
@@ -182,13 +182,13 @@ Object.defineProperty(Readable.prototype, 'destroyed', {
182
182
// because otherwise some prototype manipulation in
183
183
// userland will fail
184
184
enumerable : false ,
185
- get ( ) {
185
+ get : function get ( ) {
186
186
if ( this . _readableState === undefined ) {
187
187
return false ;
188
188
}
189
189
return this . _readableState . destroyed ;
190
190
} ,
191
- set ( value ) {
191
+ set : function set ( value ) {
192
192
// we ignore the value if the stream
193
193
// has not been initialized yet
194
194
if ( ! this . _readableState ) {
@@ -299,14 +299,14 @@ Readable.prototype.isPaused = function () {
299
299
// backwards compatibility.
300
300
Readable . prototype . setEncoding = function ( enc ) {
301
301
if ( ! StringDecoder ) StringDecoder = require ( 'string_decoder/' ) . StringDecoder ;
302
- const decoder = new StringDecoder ( enc ) ;
302
+ var decoder = new StringDecoder ( enc ) ;
303
303
this . _readableState . decoder = decoder ;
304
304
// If setEncoding(null), decoder.encoding equals utf8
305
305
this . _readableState . encoding = this . _readableState . decoder . encoding ;
306
306
307
307
// 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 = '' ;
310
310
while ( p !== null ) {
311
311
content += decoder . write ( p . data ) ;
312
312
p = p . next ;
@@ -318,7 +318,7 @@ Readable.prototype.setEncoding = function (enc) {
318
318
} ;
319
319
320
320
// Don't raise the hwm > 1GB
321
- const MAX_HWM = 0x40000000 ;
321
+ var MAX_HWM = 0x40000000 ;
322
322
function computeNewHighWaterMark ( n ) {
323
323
if ( n >= MAX_HWM ) {
324
324
// TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
@@ -545,7 +545,7 @@ function maybeReadMore_(stream, state) {
545
545
// read()s. The execution ends in this method again after the _read() ends
546
546
// up calling push() with more data.
547
547
while ( ! state . reading && ! state . ended && ( state . length < state . highWaterMark || state . flowing && state . length === 0 ) ) {
548
- const len = state . length ;
548
+ var len = state . length ;
549
549
debug ( 'maybeReadMore read 0' ) ;
550
550
stream . read ( 0 ) ;
551
551
if ( len === state . length )
@@ -742,8 +742,8 @@ Readable.prototype.unpipe = function (dest) {
742
742
// set up data events if they are asked for
743
743
// Ensure readable listeners eventually get something
744
744
Readable . 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 ;
747
747
if ( ev === 'data' ) {
748
748
// update readableListening so that resume() may be a no-op
749
749
// a few lines down. This is needed to support once('readable').
@@ -768,7 +768,7 @@ Readable.prototype.on = function (ev, fn) {
768
768
} ;
769
769
Readable . prototype . addListener = Readable . prototype . on ;
770
770
Readable . 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 ) ;
772
772
if ( ev === 'readable' ) {
773
773
// We need to check if there is someone still listening to
774
774
// readable and reset the state. However this needs to happen
@@ -781,7 +781,7 @@ Readable.prototype.removeListener = function (ev, fn) {
781
781
return res ;
782
782
} ;
783
783
Readable . prototype . removeAllListeners = function ( ev ) {
784
- const res = Stream . prototype . removeAllListeners . apply ( this , arguments ) ;
784
+ var res = Stream . prototype . removeAllListeners . apply ( this , arguments ) ;
785
785
if ( ev === 'readable' || ev === undefined ) {
786
786
// We need to check if there is someone still listening to
787
787
// readable and reset the state. However this needs to happen
@@ -794,7 +794,7 @@ Readable.prototype.removeAllListeners = function (ev) {
794
794
return res ;
795
795
} ;
796
796
function updateReadableListening ( self ) {
797
- const state = self . _readableState ;
797
+ var state = self . _readableState ;
798
798
state . readableListening = self . listenerCount ( 'readable' ) > 0 ;
799
799
if ( state . resumeScheduled && ! state . paused ) {
800
800
// flowing needs to be set to true now, otherwise
@@ -853,7 +853,7 @@ Readable.prototype.pause = function () {
853
853
return this ;
854
854
} ;
855
855
function flow ( stream ) {
856
- const state = stream . _readableState ;
856
+ var state = stream . _readableState ;
857
857
debug ( 'flow' , state . flowing ) ;
858
858
while ( state . flowing && stream . read ( ) !== null ) ;
859
859
}
@@ -862,23 +862,24 @@ function flow(stream) {
862
862
// This is *not* part of the readable stream interface.
863
863
// It is an ugly unfortunate mess of history.
864
864
Readable . prototype . wrap = function ( stream ) {
865
+ var _this = this ;
865
866
var state = this . _readableState ;
866
867
var paused = false ;
867
- stream . on ( 'end' , ( ) => {
868
+ stream . on ( 'end' , function ( ) {
868
869
debug ( 'wrapped end' ) ;
869
870
if ( state . decoder && ! state . ended ) {
870
871
var chunk = state . decoder . end ( ) ;
871
- if ( chunk && chunk . length ) this . push ( chunk ) ;
872
+ if ( chunk && chunk . length ) _this . push ( chunk ) ;
872
873
}
873
- this . push ( null ) ;
874
+ _this . push ( null ) ;
874
875
} ) ;
875
- stream . on ( 'data' , chunk => {
876
+ stream . on ( 'data' , function ( chunk ) {
876
877
debug ( 'wrapped data' ) ;
877
878
if ( state . decoder ) chunk = state . decoder . write ( chunk ) ;
878
879
879
880
// don't skip over falsy values in objectMode
880
881
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 ) ;
882
883
if ( ! ret ) {
883
884
paused = true ;
884
885
stream . pause ( ) ;
@@ -904,7 +905,7 @@ Readable.prototype.wrap = function (stream) {
904
905
905
906
// when we try to consume some more bytes, simply unpause the
906
907
// underlying stream.
907
- this . _read = n => {
908
+ this . _read = function ( n ) {
908
909
debug ( 'wrapped _read' , n ) ;
909
910
if ( paused ) {
910
911
paused = false ;
@@ -961,7 +962,7 @@ Object.defineProperty(Readable.prototype, 'readableLength', {
961
962
// because otherwise some prototype manipulation in
962
963
// userland will fail
963
964
enumerable : false ,
964
- get ( ) {
965
+ get : function get ( ) {
965
966
return this . _readableState . length ;
966
967
}
967
968
} ) ;
@@ -1003,7 +1004,7 @@ function endReadableNT(state, stream) {
1003
1004
if ( state . autoDestroy ) {
1004
1005
// In case of duplex streams we need a way to detect
1005
1006
// if the writable side is ready for autoDestroy as well
1006
- const wState = stream . _writableState ;
1007
+ var wState = stream . _writableState ;
1007
1008
if ( ! wState || wState . autoDestroy && wState . finished ) {
1008
1009
stream . destroy ( ) ;
1009
1010
}
0 commit comments