Skip to content

Commit

Permalink
stream: fix wrong stream type in adapters.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CGQAQ committed Jul 21, 2023
1 parent a87605f commit 16737b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
14 changes: 7 additions & 7 deletions lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const {
CountQueuingStrategy,
} = require('internal/webstreams/queuingstrategies');

const { kFresh } = require('internal/webstreams/util');

const {
Writable,
Readable,
Expand Down Expand Up @@ -455,14 +453,16 @@ function newReadableStreamFromStreamReadable(streamReadable, options = kEmptyObj
return controller.error(error);
controller.close();
});

streamReadable.on('data', onData);

return new ReadableStream({
start(c) {
controller = c;
controller[kFresh] = true;
},
// CGQAQ: we know that `Readable.readableHighWaterMark
// size is always in bytes, so we can use `bytes` here
// to make the `ReadableStream` a byte stream.
// Ref: https://streams.spec.whatwg.org/#high-water-mark:~:text=Concretely%2C%20a%20queuing,floating%2Dpoint%20units.
type: "bytes",

start(c) { controller = c; },

pull() { streamReadable.resume(); },

Expand Down
5 changes: 0 additions & 5 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ const {
iteratorNext,
kType,
kState,
kFresh,
} = require('internal/webstreams/util');

const {
Expand Down Expand Up @@ -2287,10 +2286,6 @@ function readableStreamDefaultControllerGetDesiredSize(controller) {
}

function readableStreamDefaultControllerShouldCallPull(controller) {
if (controller[kFresh]) {
controller[kFresh] = false;
return false;
}
const {
stream,
} = controller[kState];
Expand Down
2 changes: 0 additions & 2 deletions lib/internal/webstreams/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const {
validateFunction,
} = require('internal/validators');

const kFresh = Symbol('kFresh');
const kState = Symbol('kState');
const kType = Symbol('kType');

Expand Down Expand Up @@ -299,5 +298,4 @@ module.exports = {
iteratorNext,
kType,
kState,
kFresh,
};

0 comments on commit 16737b3

Please sign in to comment.