Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
stream: add webstreams async iterator toStringTag
WebIDL gives an async iterator prototype the class string
"<interface> AsyncIterator", so ReadableStream iterators now report
'ReadableStream AsyncIterator' through Symbol.toStringTag.

Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina committed Oct 2, 2026
commit 01fc4d2886973ff4c6a536e8c502c34918c9d466
2 changes: 2 additions & 0 deletions lib/internal/webstreams/readablestream.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ ObjectSetPrototypeOf(ReadableStreamAsyncIterator.prototype,
ObjectDefineProperties(ReadableStreamAsyncIterator.prototype, {
next: kEnumerableProperty,
return: kEnumerableProperty,
[SymbolToStringTag]:
getNonWritablePropertyDescriptor('ReadableStream AsyncIterator'),
});

class DefaultReadRequest {
Expand Down
13 changes: 12 additions & 1 deletion test/parallel/test-whatwg-readablestream-async-iterator-shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ const proto = Object.getPrototypeOf(a);

assert.strictEqual(Object.getPrototypeOf(b), proto);
assert.deepStrictEqual(Reflect.ownKeys(a), []);
assert.deepStrictEqual(Reflect.ownKeys(proto), ['next', 'return']);
assert.deepStrictEqual(Reflect.ownKeys(proto),
['next', 'return', Symbol.toStringTag]);
assert.strictEqual(Object.prototype.toString.call(a),
'[object ReadableStream AsyncIterator]');
assert.deepStrictEqual(
Object.getOwnPropertyDescriptor(proto, Symbol.toStringTag),
{
value: 'ReadableStream AsyncIterator',
writable: false,
enumerable: false,
configurable: true,
});
assert.strictEqual(a[Symbol.asyncIterator](), a);

for (const method of ['next', 'return']) {
Expand Down
Loading