Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade ReadableStream[Symbol.asyncIterator] ponyfill #128

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"concat"
],
"dependencies": {
"@sec-ant/readable-stream": "^0.3.2",
"@sec-ant/readable-stream": "^0.4.1",
"is-stream": "^4.0.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions source/stream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {isReadableStream} from 'is-stream';
import {ponyfill} from './web-stream.js';
import {asyncIterator} from '@sec-ant/readable-stream/ponyfill';

export const getAsyncIterable = stream => {
if (isReadableStream(stream, {checkOpen: false}) && nodeImports.on !== undefined) {
Expand All @@ -12,7 +12,7 @@ export const getAsyncIterable = stream => {

// `ReadableStream[Symbol.asyncIterator]` support is missing in multiple browsers, so we ponyfill it
if (toString.call(stream) === '[object ReadableStream]') {
return ponyfill.asyncIterator.call(stream);
return asyncIterator.call(stream);
}

throw new TypeError('The first argument must be a Readable, a ReadableStream, or an async iterable.');
Expand Down
13 changes: 0 additions & 13 deletions source/web-stream.js

This file was deleted.

14 changes: 3 additions & 11 deletions test/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import {Duplex, Readable} from 'node:stream';
import {finished} from 'node:stream/promises';

// @todo Use ReadableStream.from() after dropping support for Node 18
export {fromAnyIterable as readableStreamFrom} from '@sec-ant/readable-stream/ponyfill';

export const createStream = streamDefinition => typeof streamDefinition === 'function'
? Duplex.from(streamDefinition)
: Readable.from(streamDefinition);

// @todo Use ReadableStream.from() after dropping support for Node 18
export const readableStreamFrom = chunks => new ReadableStream({
start(controller) {
for (const chunk of chunks) {
controller.enqueue(chunk);
}

controller.close();
},
});

// Tests related to big buffers/strings can be slow. We run them serially and
// with a higher timeout to ensure they do not randomly fail.
export const BIG_TEST_DURATION = '2m';
Expand Down