diff options
Diffstat (limited to 'ext/web/06_streams.js')
-rw-r--r-- | ext/web/06_streams.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 4f472984d..9fc15d1ad 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -12,6 +12,7 @@ const { op_arraybuffer_was_detached, op_transfer_arraybuffer, op_readable_stream_resource_allocate, + op_readable_stream_resource_allocate_sized, op_readable_stream_resource_get_sink, op_readable_stream_resource_write_error, op_readable_stream_resource_write_buf, @@ -863,13 +864,16 @@ function readableStreamReadFn(reader, sink) { * read operations, and those read operations will be fed by the output of the * ReadableStream source. * @param {ReadableStream<Uint8Array>} stream + * @param {number | undefined} length * @returns {number} */ -function resourceForReadableStream(stream) { +function resourceForReadableStream(stream, length) { const reader = acquireReadableStreamDefaultReader(stream); // Allocate the resource - const rid = op_readable_stream_resource_allocate(); + const rid = typeof length == "number" + ? op_readable_stream_resource_allocate_sized(length) + : op_readable_stream_resource_allocate(); // Close the Reader we get from the ReadableStream when the resource is closed, ignoring any errors PromisePrototypeCatch( |