Skip to content

Commit d6f5472

Browse files
committed
stream: throw TypeError when criteria fulfilled in getIterator
1 parent bcdbf88 commit d6f5472

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/internal/webstreams/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const {
1818

1919
const {
2020
codes: {
21+
ERR_ARG_NOT_ITERABLE,
2122
ERR_INVALID_ARG_VALUE,
2223
ERR_INVALID_STATE,
2324
ERR_OPERATION_FAILED,
@@ -235,6 +236,11 @@ function getIterator(obj, kind = 'sync', method) {
235236
method = obj[SymbolAsyncIterator];
236237
if (method === undefined) {
237238
const syncMethod = obj[SymbolIterator];
239+
240+
if (syncMethod === undefined) {
241+
throw new ERR_ARG_NOT_ITERABLE(obj);
242+
}
243+
238244
const syncIteratorRecord = getIterator(obj, 'sync', syncMethod);
239245
return createAsyncFromSyncIterator(syncIteratorRecord);
240246
}
@@ -243,6 +249,10 @@ function getIterator(obj, kind = 'sync', method) {
243249
}
244250
}
245251

252+
if (method === undefined) {
253+
throw new ERR_ARG_NOT_ITERABLE(obj);
254+
}
255+
246256
const iterator = FunctionPrototypeCall(method, obj);
247257
if (typeof iterator !== 'object' || iterator === null) {
248258
throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object');

0 commit comments

Comments
 (0)