doc: document stream/iter iterator results and from() identity

Some stream/iter iterators return iterator results that do not inherit
from Object.prototype, and from() returns validated sources unchanged.
Document both.

Assisted-by: OpenCode
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66504
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
James M Snell authored and Antoine du Hamel committed 2026-11-23 12:34:24 +01:00
1 parent 5ad6fdd626
commit 8317be4131
1 file changed
+9
+9
View File
@@ -119,6 +119,10 @@ async function run() {
}
```
Some iterators of this module return iterator results (`{ done, value }`
objects) that do not inherit from `Object.prototype`. Code should only rely on
their `done` and `value` properties, as `for await...of` does.
### Transforms
Transforms come in two forms:
@@ -598,6 +602,10 @@ Objects implementing `Symbol.for('Stream.toAsyncStreamable')` or
precedence over the iteration protocols (`Symbol.asyncIterator`,
`Symbol.iterator`).
The readable of a [`push()`][] stream without transforms and the iterables
returned by [`fromReadable()`][] already yield normalized batches, so `from()`
returns them unchanged.
```mjs
import { Buffer } from 'node:buffer';
import { from, text } from 'node:stream/iter';
@@ -2415,6 +2423,7 @@ console.log(textSync(stream)); // 'hello world'
[`pipeTo()`]: #pipetosource-transforms-writer-options
[`pull()`]: #pullsource-transforms-options
[`pullSync()`]: #pullsyncsource-transforms
[`push()`]: #pushtransforms-options
[`share()`]: #sharesource-options
[`stream.Readable`]: stream.md#class-streamreadable
[`stream.Writable`]: stream.md#class-streamwritable