Skip to content

Commit

Permalink
Fix ReadableStream.from accepts iterable/async iterable
Browse files Browse the repository at this point in the history
The proposal accepts Iterable/AsyncIterable objects, but previous tests
tested IterableIterator/AsyncIterableIterator.

This change breaks Deno v1.43.5.
However, Node v20.13.1 and Firefox 126.0 are implemented correctly.
  • Loading branch information
Milly authored and domenic committed May 20, 2024
1 parent ad2c43b commit 8dd0e0a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions streams/readable-streams/from.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,44 +51,50 @@ const iterableFactories = [

['a sync iterable of values', () => {
const chunks = ['a', 'b'];
const it = {
const iterator = {
next() {
return {
done: chunks.length === 0,
value: chunks.shift()
};
},
[Symbol.iterator]: () => it
}
};
const iterable = {
[Symbol.iterator]: () => iterator
};
return it;
return iterable;
}],

['a sync iterable of promises', () => {
const chunks = ['a', 'b'];
const it = {
const iterator = {
next() {
return chunks.length === 0 ? { done: true } : {
done: false,
value: Promise.resolve(chunks.shift())
};
},
[Symbol.iterator]: () => it
}
};
return it;
const iterable = {
[Symbol.iterator]: () => iterator
};
return iterable;
}],

['an async iterable', () => {
const chunks = ['a', 'b'];
const it = {
const asyncIterator = {
next() {
return Promise.resolve({
done: chunks.length === 0,
value: chunks.shift()
})
},
[Symbol.asyncIterator]: () => it
}
};
const asyncIterable = {
[Symbol.asyncIterator]: () => asyncIterator
};
return it;
return asyncIterable;
}],

['a ReadableStream', () => {
Expand Down

0 comments on commit 8dd0e0a

Please sign in to comment.