@@ -49,6 +49,13 @@ module.exports = class BodyReadable extends Readable {
4949 return super . on ( ev , ...args )
5050 }
5151
52+ addListener ( ev , ...args ) {
53+ if ( ev === 'data' || ev === 'readable' ) {
54+ this [ kReading ] = true
55+ }
56+ return super . addListener ( ev , ...args )
57+ }
58+
5259 push ( chunk , encoding ) {
5360 if ( this [ kConsume ] && chunk !== null && ! this [ kReading ] ) {
5461 // Fast path.
@@ -90,6 +97,7 @@ module.exports = class BodyReadable extends Readable {
9097 return isDisturbed ( this )
9198 }
9299
100+ // https://fetch.spec.whatwg.org/#dom-body-body
93101 get body ( ) {
94102 if ( this [ kConsume ] && this [ kConsume ] . type === kWebStreamType ) {
95103 return this [ kConsume ] . stream
@@ -125,20 +133,16 @@ function isUnusable (self) {
125133
126134async function consume ( parent , type ) {
127135 if ( isUnusable ( parent ) ) {
128- // eslint-disable-next-line no-restricted-syntax
129136 throw new TypeError ( 'unusable' )
130137 }
131138
132139 if ( parent [ kConsume ] ) {
133- // TODO: Should multiple consume in same tick be possible?
134- // eslint-disable-next-line no-restricted-syntax
135140 throw new TypeError ( 'unusable' )
136141 }
137142
138143 if ( type === kWebStreamType ) {
139144 const consume = parent [ kConsume ] = {
140145 type,
141- // TODO: Optimized implementation for web streams.
142146 stream : Readable . toWeb ( parent )
143147 }
144148
0 commit comments