stream: prefer sync iterator in fromSync · nodejs/node@3f8b446 · GitHub
Skip to content

Commit 3f8b446

Browse files
trivikraduh95
authored andcommitted
stream: prefer sync iterator in fromSync
When an input provides Symbol.iterator, fromSync() should consume the synchronous iterator instead of rejecting the input because it also exposes an asynchronous or promise-like protocol. Continue rejecting async-only iterables and promise/thenable-only inputs, but allow sync iterables that also define Symbol.asyncIterator or then(). Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 PR-URL: #64294 Fixes: #64292 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8461d18 commit 3f8b446

2 files changed

Lines changed: 36 additions & 5 deletions

File tree

lib/internal/streams/iter/from.js

Lines changed: 9 additions & 4 deletions

test/parallel/test-stream-iter-from-sync.js

Lines changed: 27 additions & 1 deletion

0 commit comments

Comments
 (0)