| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3491f73 commit c12a767
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1365,6 +1365,9 @@ function readableStreamFromIterable(iterable) { | |||
| 1365 | 1365 | throw new ERR_ARG_NOT_ITERABLE(iterable); | |
| 1366 | 1366 | } | |
| 1367 | 1367 | const iterator = FunctionPrototypeCall(iteratorGetter, iterable); | |
| 1368 | + if (iterator === null || (typeof iterator !== 'object' && typeof iterator !== 'function')) { | ||
| 1369 | + throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object'); | ||
| 1370 | + } | ||
| 1368 | 1371 | const startAlgorithm = nonOpStart; | |
| 1369 | 1372 | ||
| 1370 | 1373 | async function pullAlgorithm() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,3 +7,22 @@ assert.throws( | |||
| 7 | 7 | () => ReadableStream.from({}), | |
| 8 | 8 | { code: 'ERR_ARG_NOT_ITERABLE', name: 'TypeError' }, | |
| 9 | 9 | ); | |
| 10 | + | ||
| 11 | + const invalidIterators = [ | ||
| 12 | + { [Symbol.iterator]: () => 42 }, | ||
| 13 | + { [Symbol.asyncIterator]: () => 42 }, | ||
| 14 | + ]; | ||
| 15 | + | ||
| 16 | + for (const iterable of invalidIterators) { | ||
| 17 | + assert.throws( | ||
| 18 | + () => ReadableStream.from(iterable), | ||
| 19 | + { code: 'ERR_INVALID_STATE', name: 'TypeError' }, | ||
| 20 | + ); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + function functionIterator() {} | ||
| 24 | + | ||
| 25 | + // doesNotThrow | ||
| 26 | + ReadableStream.from({ | ||
| 27 | + [Symbol.iterator]: () => functionIterator, | ||
| 28 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,15 +8,6 @@ | |||
| 8 | 8 | "readable-streams/cross-realm-crash.window.js": { | |
| 9 | 9 | "skip": "Browser-specific test" | |
| 10 | 10 | }, | |
| 11 | - "readable-streams/from.any.js": { | ||
| 12 | - "fail": { | ||
| 13 | - "note": "does not synchronously validate that the value returned by @@iterator/@@asyncIterator is an object", | ||
| 14 | - "expected": [ | ||
| 15 | - "ReadableStream.from throws on invalid iterables; specifically an object with an @@iterator method returning a non-object", | ||
| 16 | - "ReadableStream.from throws on invalid iterables; specifically an object with an @@asyncIterator method returning a non-object" | ||
| 17 | - ] | ||
| 18 | - } | ||
| 19 | - }, | ||
| 20 | 11 | "readable-streams/owning-type-message-port.any.js": { | |
| 21 | 12 | "fail": { | |
| 22 | 13 | "note": "Readable streams with type owning are not yet supported", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments