@@ -1138,26 +1138,6 @@ Readable.prototype.iterator = function(options) {
11381138 return streamToAsyncIterator ( this , options ) ;
11391139} ;
11401140
1141- // https://fetch.spec.whatwg.org/#dom-body-text
1142- Readable . prototype . text = function text ( ) {
1143- return consume ( this , kTextType ) ;
1144- } ;
1145-
1146- // https://fetch.spec.whatwg.org/#dom-body-json
1147- Readable . prototype . json = function json ( ) {
1148- return consume ( this , kJSONType ) ;
1149- } ;
1150-
1151- // https://fetch.spec.whatwg.org/#dom-body-blob
1152- Readable . prototype . blob = function blob ( ) {
1153- return consume ( this , kBlobType ) ;
1154- } ;
1155-
1156- // https://fetch.spec.whatwg.org/#dom-body-arraybuffer
1157- Readable . prototype . arrayBuffer = function arrayBuffer ( ) {
1158- return consume ( this , kArrayBufferType ) ;
1159- } ;
1160-
11611141function streamToAsyncIterator ( stream , options ) {
11621142 if ( typeof stream . read !== 'function' ) {
11631143 // v1 stream
@@ -1325,34 +1305,6 @@ ObjectDefineProperties(Readable.prototype, {
13251305 get ( ) {
13261306 return this . _readableState ? this . _readableState . endEmitted : false ;
13271307 }
1328- } ,
1329-
1330- // https://fetch.spec.whatwg.org/#dom-body-bodyused
1331- bodyUsed : {
1332- get ( ) {
1333- return isDisturbed ( this ) ;
1334- }
1335- } ,
1336-
1337- // https://fetch.spec.whatwg.org/#dom-body-body
1338- body : {
1339- get ( ) {
1340- // Compat
1341- if ( this [ kHasBody ] ) {
1342- return this [ kBody ] ;
1343- }
1344-
1345- if ( this [ kConsume ] && this [ kConsume ] . type === kWebStreamType ) {
1346- return this [ kConsume ] . stream ;
1347- }
1348-
1349- return consume ( this , kWebStreamType ) ;
1350- } ,
1351- // Compat
1352- set ( value ) {
1353- this [ kBody ] = value ;
1354- this [ kHasBody ] = true ;
1355- }
13561308 }
13571309} ) ;
13581310
@@ -1696,6 +1648,63 @@ function endWritableNT(state, stream) {
16961648 }
16971649}
16981650
1651+ function bodyMixin ( readable ) {
1652+ // https://fetch.spec.whatwg.org/#dom-body-text
1653+ readable . text = function text ( ) {
1654+ return consume ( this , kTextType ) ;
1655+ } ;
1656+
1657+ // https://fetch.spec.whatwg.org/#dom-body-json
1658+ readable . json = function json ( ) {
1659+ return consume ( this , kJSONType ) ;
1660+ } ;
1661+
1662+ // https://fetch.spec.whatwg.org/#dom-body-blob
1663+ readable . blob = function blob ( ) {
1664+ return consume ( this , kBlobType ) ;
1665+ } ;
1666+
1667+ // https://fetch.spec.whatwg.org/#dom-body-arraybuffer
1668+ readable . arrayBuffer = function arrayBuffer ( ) {
1669+ return consume ( this , kArrayBufferType ) ;
1670+ } ;
1671+
1672+
1673+ ObjectDefineProperties ( readable , {
1674+ // https://fetch.spec.whatwg.org/#dom-body-bodyused
1675+ bodyUsed : {
1676+ get ( ) {
1677+ return isDisturbed ( this ) ;
1678+ }
1679+ } ,
1680+
1681+ // https://fetch.spec.whatwg.org/#dom-body-body
1682+ body : {
1683+ get ( ) {
1684+ // Compat
1685+ if ( this [ kHasBody ] ) {
1686+ return this [ kBody ] ;
1687+ }
1688+
1689+ if ( this [ kConsume ] && this [ kConsume ] . type === kWebStreamType ) {
1690+ return this [ kConsume ] . stream ;
1691+ }
1692+
1693+ return consume ( this , kWebStreamType ) ;
1694+ } ,
1695+ // Compat
1696+ set ( value ) {
1697+ this [ kBody ] = value ;
1698+ this [ kHasBody ] = true ;
1699+ }
1700+ }
1701+ } ) ;
1702+
1703+ return readable ;
1704+ }
1705+
1706+ Readable . bodyMixin = bodyMixin ;
1707+
16991708Readable . from = function ( iterable , opts ) {
17001709 return from ( Readable , iterable , opts ) ;
17011710} ;
0 commit comments