@@ -28,6 +28,7 @@ const {
2828 ObjectDefineProperty,
2929 ObjectSetPrototypeOf,
3030 SymbolAsyncIterator,
31+ Symbol
3132} = primordials ;
3233
3334module . exports = Readable ;
@@ -51,6 +52,8 @@ const {
5152 ERR_STREAM_UNSHIFT_AFTER_END_EVENT
5253} = require ( 'internal/errors' ) . codes ;
5354
55+ const kPaused = Symbol ( 'kPaused' ) ;
56+
5457// Lazy loaded to improve the startup performance.
5558let StringDecoder ;
5659let createReadableStreamAsyncIterator ;
@@ -126,7 +129,7 @@ function ReadableState(options, stream, isDuplex) {
126129 this . emittedReadable = false ;
127130 this . readableListening = false ;
128131 this . resumeScheduled = false ;
129- this . paused = null ;
132+ this [ kPaused ] = null ;
130133
131134 // True if the error was already emitted and should not be thrown again
132135 this . errorEmitted = false ;
@@ -173,6 +176,16 @@ ObjectDefineProperty(ReadableState.prototype, 'pipesCount', {
173176 }
174177} ) ;
175178
179+ // Legacy property for `paused`
180+ ObjectDefineProperty ( ReadableState . prototype , 'paused' , {
181+ get ( ) {
182+ return this [ kPaused ] !== false ;
183+ } ,
184+ set ( value ) {
185+ this [ kPaused ] = Boolean ( value ) ;
186+ }
187+ } ) ;
188+
176189function Readable ( options ) {
177190 if ( ! ( this instanceof Readable ) )
178191 return new Readable ( options ) ;
@@ -368,7 +381,7 @@ function chunkInvalid(state, chunk) {
368381
369382
370383Readable . prototype . isPaused = function ( ) {
371- return this . _readableState . paused === true ;
384+ return this . _readableState [ kPaused ] === true ;
372385} ;
373386
374387// Backwards compatibility.
@@ -967,7 +980,7 @@ function updateReadableListening(self) {
967980 const state = self . _readableState ;
968981 state . readableListening = self . listenerCount ( 'readable' ) > 0 ;
969982
970- if ( state . resumeScheduled && state . paused === false ) {
983+ if ( state . resumeScheduled && state [ kPaused ] === false ) {
971984 // Flowing needs to be set to true now, otherwise
972985 // the upcoming resume will not flow.
973986 state . flowing = true ;
@@ -997,7 +1010,7 @@ Readable.prototype.resume = function() {
9971010 state . flowing = ! state . readableListening ;
9981011 resume ( this , state ) ;
9991012 }
1000- state . paused = false ;
1013+ state [ kPaused ] = false ;
10011014 return this ;
10021015} ;
10031016
@@ -1028,7 +1041,7 @@ Readable.prototype.pause = function() {
10281041 this . _readableState . flowing = false ;
10291042 this . emit ( 'pause' ) ;
10301043 }
1031- this . _readableState . paused = true ;
1044+ this . _readableState [ kPaused ] = true ;
10321045 return this ;
10331046} ;
10341047
0 commit comments