Skip to content

Commit b2ec188

Browse files
committed
doc: fix promise nomenclature in stream_iter.md
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #63406 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 771afd6 commit b2ec188

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

doc/api/fs.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,16 +1031,16 @@ added: v25.9.0
10311031
Set this to match the reader's `chunkSize` for optimal `pipeTo()`
10321032
performance. **Default:** `131072` (128 KB).
10331033
* Returns: {Object}
1034-
* `write(chunk[, options])` {Function} Returns {Promise\<void>}.
1034+
* `write(chunk[, options])` {Function} Returns {Promise}.
10351035
Accepts `Uint8Array`, `Buffer`, or string (UTF-8 encoded).
10361036
* `chunk` {Buffer|TypedArray|DataView|string}
10371037
* `options` {Object}
10381038
* `signal` {AbortSignal} If the signal is already aborted, the write
10391039
rejects with `AbortError` without performing I/O.
1040-
* `writev(chunks[, options])` {Function} Returns {Promise\<void>}. Uses
1040+
* `writev(chunks[, options])` {Function} Returns {Promise}. Uses
10411041
scatter/gather I/O via a single `writev()` syscall. Accepts mixed
10421042
`Uint8Array`/string arrays.
1043-
* `chunks` {Array\<Buffer|TypedArray|DataView|string>}
1043+
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|string\[]}
10441044
* `options` {Object}
10451045
* `signal` {AbortSignal} If the signal is already aborted, the write
10461046
rejects with `AbortError` without performing I/O.
@@ -1052,10 +1052,10 @@ added: v25.9.0
10521052
* `chunk` {Buffer|TypedArray|DataView|string}
10531053
* `writevSync(chunks)` {Function} Returns {boolean}. Synchronous batch
10541054
write. Same fallback semantics as `writeSync()`.
1055-
* `chunks` {Array\<Buffer|TypedArray|DataView|string>}
1056-
* `end([options])` {Function} Returns {Promise\<number>} total bytes
1057-
written. Idempotent: returns `totalBytesWritten` if already closed,
1058-
returns the pending promise if already closing. Rejects if the writer
1055+
* `chunks` {Buffer\[]|TypedArray\[]|DataView\[]|string\[]}
1056+
* `end([options])` {Function} Returns {Promise}, fulfills with the total
1057+
number of bytes written. Idempotent: returns `totalBytesWritten` if already
1058+
closed, returns the pending promise if already closing. Rejects if the writer
10591059
is in an errored state.
10601060
* `options` {Object}
10611061
* `signal` {AbortSignal} If the signal is already aborted, `end()`
@@ -2812,7 +2812,7 @@ changes:
28122812
* `filter` {Function} Function to filter copied files/directories. Return
28132813
`true` to copy the item, `false` to ignore it. When ignoring a directory,
28142814
all of its contents will be skipped as well. Can also return a `Promise`
2815-
that resolves to `true` or `false` **Default:** `undefined`.
2815+
that fulfills with `true` or `false`. **Default:** `undefined`.
28162816
* `src` {string} source path to copy.
28172817
* `dest` {string} destination path to copy to.
28182818
* Returns: {boolean|Promise} A value that is coercible to `boolean` or

doc/api/stream_iter.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ that closes when the bucket is full:
220220

221221
* **Pending writes (the hose)** -- writes waiting for slot space. After
222222
the consumer drains, pending writes are promoted into the now-empty
223-
slots and their promises resolve.
223+
slots and their promises settle.
224224

225225
How each policy uses these buffers:
226226

@@ -430,7 +430,7 @@ The value is always non-negative.
430430
* `options` {Object}
431431
* `signal` {AbortSignal} Cancel just this operation. The signal cancels only
432432
the pending `end()` call; it does not fail the writer itself.
433-
* Returns: {Promise\<number>} Total bytes written.
433+
* Returns: {Promise} Fulfills with the total number of bytes written.
434434

435435
Signal that no more data will be written.
436436

@@ -463,9 +463,9 @@ transition with no async work to perform.
463463
* `options` {Object}
464464
* `signal` {AbortSignal} Cancel just this write operation. The signal cancels
465465
only the pending `write()` call; it does not fail the writer itself.
466-
* Returns: {Promise\<void>}
466+
* Returns: {Promise} Fulfills with `undefined` when buffer space is available.
467467

468-
Write a chunk. The promise resolves when buffer space is available.
468+
Write a chunk.
469469

470470
#### `writer.writeSync(chunk)`
471471

@@ -481,7 +481,7 @@ Synchronous write. Does not block; returns `false` if backpressure is active.
481481
* `options` {Object}
482482
* `signal` {AbortSignal} Cancel just this write operation. The signal cancels
483483
only the pending `writev()` call; it does not fail the writer itself.
484-
* Returns: {Promise\<void>}
484+
* Returns: {Promise}
485485

486486
Write multiple chunks as a single batch.
487487

@@ -603,7 +603,7 @@ added: v25.9.0
603603
the source ends. **Default:** `false`.
604604
* `preventFail` {boolean} If `true`, do not call `writer.fail()` on
605605
error. **Default:** `false`.
606-
* Returns: {Promise\<number>} Total bytes written.
606+
* Returns: {Promise} Fulfills with the total number of bytes written.
607607

608608
Pipe a source through transforms into a writer. If the writer has a
609609
`writev(chunks)` method, entire batches are passed in a single call (enabling
@@ -903,7 +903,7 @@ added: v25.9.0
903903
* `signal` {AbortSignal}
904904
* `limit` {number} Maximum number of bytes to consume. If the total bytes
905905
collected exceeds limit, an `ERR_OUT_OF_RANGE` error is thrown
906-
* Returns: {Promise\<Uint8Array\[]>}
906+
* Returns: {Promise} Fulfills with an array of `Uint8Array` objects.
907907

908908
Collect all chunks as an array of `Uint8Array` values (without concatenating).
909909

@@ -918,7 +918,7 @@ added: v25.9.0
918918
* `signal` {AbortSignal}
919919
* `limit` {number} Maximum number of bytes to consume. If the total bytes
920920
collected exceeds limit, an `ERR_OUT_OF_RANGE` error is thrown
921-
* Returns: {Promise\<ArrayBuffer>}
921+
* Returns: {Promise} Fulfills with an `ArrayBuffer` object.
922922

923923
Collect all bytes into an `ArrayBuffer`.
924924

@@ -961,7 +961,7 @@ added: v25.9.0
961961
* `signal` {AbortSignal}
962962
* `limit` {number} Maximum number of bytes to consume. If the total bytes
963963
collected exceeds limit, an `ERR_OUT_OF_RANGE` error is thrown
964-
* Returns: {Promise\<Uint8Array>}
964+
* Returns: {Promise} Fulfills with an `Uint8Array` object.
965965

966966
Collect all bytes from a stream into a single `Uint8Array`.
967967

@@ -1009,7 +1009,7 @@ added: v25.9.0
10091009
* `signal` {AbortSignal}
10101010
* `limit` {number} Maximum number of bytes to consume. If the total bytes
10111011
collected exceeds limit, an `ERR_OUT_OF_RANGE` error is thrown
1012-
* Returns: {Promise\<string>}
1012+
* Returns: {Promise} Fulfills with a `string`.
10131013

10141014
Collect all bytes and decode as text.
10151015

@@ -1053,11 +1053,11 @@ added: v25.9.0
10531053
-->
10541054

10551055
* `drainable` {Object} An object implementing the drainable protocol.
1056-
* Returns: {Promise\<boolean>|null}
1056+
* Returns: {Promise|null}
10571057

1058-
Wait for a drainable writer's backpressure to clear. Returns a promise that
1059-
resolves to `true` when the writer can accept more data, or `null` if the
1060-
object does not implement the drainable protocol.
1058+
Wait for a drainable writer's backpressure to clear. Returns `null` if
1059+
the object does not implement the drainable protocol, or a promise that
1060+
fulfills with `true` when the writer can accept more data.
10611061

10621062
```mjs
10631063
import { push, ondrain, text } from 'node:stream/iter';
@@ -1768,8 +1768,8 @@ text(consumer).then(console.log); // 'hello'
17681768
* Value: `Symbol.for('Stream.drainableProtocol')`
17691769

17701770
Implement to make a writer compatible with `ondrain()`. The method should
1771-
return a promise that resolves when backpressure clears, or `null` if no
1772-
backpressure.
1771+
return `null` if no backpressure, or a promise that fulfills with a truthy value
1772+
when backpressure clears.
17731773

17741774
```mjs
17751775
import { ondrain } from 'node:stream/iter';
@@ -1975,8 +1975,8 @@ console.log(textSync(consumer)); // 'hello'
19751975
The value must be a function that converts the object into a streamable value.
19761976
When the object is encountered anywhere in the streaming pipeline (as a source
19771977
passed to `from()`, or as a value returned from a transform), this method is
1978-
called to produce the actual data. It may return (or resolve to) any streamable
1979-
value: a string, `Uint8Array`, `AsyncIterable`, `Iterable`, or another streamable
1978+
called to produce the actual data. It may return any value that resolves to:
1979+
a string, `Uint8Array`, `AsyncIterable`, `Iterable`, or another streamable
19801980
object.
19811981
19821982
```mjs

0 commit comments

Comments
 (0)