Skip to content

Commit df42674

Browse files
authored
Upgrade ReadableStream[Symbol.asyncIterator] ponyfill (#128)
1 parent 26c7e41 commit df42674

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"concat"
4646
],
4747
"dependencies": {
48-
"@sec-ant/readable-stream": "^0.3.2",
48+
"@sec-ant/readable-stream": "^0.4.1",
4949
"is-stream": "^4.0.1"
5050
},
5151
"devDependencies": {

source/stream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {isReadableStream} from 'is-stream';
2-
import {ponyfill} from './web-stream.js';
2+
import {asyncIterator} from '@sec-ant/readable-stream/ponyfill';
33

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

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

1818
throw new TypeError('The first argument must be a Readable, a ReadableStream, or an async iterable.');

source/web-stream.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/helpers/index.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import {Duplex, Readable} from 'node:stream';
22
import {finished} from 'node:stream/promises';
33

4+
// @todo Use ReadableStream.from() after dropping support for Node 18
5+
export {fromAnyIterable as readableStreamFrom} from '@sec-ant/readable-stream/ponyfill';
6+
47
export const createStream = streamDefinition => typeof streamDefinition === 'function'
58
? Duplex.from(streamDefinition)
69
: Readable.from(streamDefinition);
710

8-
// @todo Use ReadableStream.from() after dropping support for Node 18
9-
export const readableStreamFrom = chunks => new ReadableStream({
10-
start(controller) {
11-
for (const chunk of chunks) {
12-
controller.enqueue(chunk);
13-
}
14-
15-
controller.close();
16-
},
17-
});
18-
1911
// Tests related to big buffers/strings can be slow. We run them serially and
2012
// with a higher timeout to ensure they do not randomly fail.
2113
export const BIG_TEST_DURATION = '2m';

0 commit comments

Comments
 (0)