| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9759049 commit 713fc0c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ const { | |||
| 18 | 18 | ||
| 19 | 19 | const { | |
| 20 | 20 | codes: { | |
| 21 | + ERR_ARG_NOT_ITERABLE, | ||
| 21 | 22 | ERR_INVALID_ARG_VALUE, | |
| 22 | 23 | ERR_OPERATION_FAILED, | |
| 23 | 24 | ERR_INVALID_STATE, | |
@@ -235,6 +236,11 @@ function getIterator(obj, kind = 'sync', method) { | |||
| 235 | 236 | method = obj[SymbolAsyncIterator]; | |
| 236 | 237 | if (method === undefined) { | |
| 237 | 238 | const syncMethod = obj[SymbolIterator]; | |
| 239 | + | ||
| 240 | + if (syncMethod === undefined) { | ||
| 241 | + throw new ERR_ARG_NOT_ITERABLE(obj); | ||
| 242 | + } | ||
| 243 | + | ||
| 238 | 244 | const syncIteratorRecord = getIterator(obj, 'sync', syncMethod); | |
| 239 | 245 | return createAsyncFromSyncIterator(syncIteratorRecord); | |
| 240 | 246 | } | |
@@ -243,6 +249,10 @@ function getIterator(obj, kind = 'sync', method) { | |||
| 243 | 249 | } | |
| 244 | 250 | } | |
| 245 | 251 | ||
| 252 | + if (method === undefined) { | ||
| 253 | + throw new ERR_ARG_NOT_ITERABLE(obj); | ||
| 254 | + } | ||
| 255 | + | ||
| 246 | 256 | const iterator = FunctionPrototypeCall(method, obj); | |
| 247 | 257 | if (typeof iterator !== 'object' || iterator === null) { | |
| 248 | 258 | throw new ERR_INVALID_STATE.TypeError('The iterator method must return an object'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,9 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('node:assert'); | ||
| 5 | + | ||
| 6 | + assert.throws( | ||
| 7 | + () => ReadableStream.from({}), | ||
| 8 | + { code: 'ERR_ARG_NOT_ITERABLE', name: 'TypeError' }, | ||
| 9 | + ); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments