Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document require("stream/promises").pipeline end option #48970

Merged
merged 2 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@

<!-- YAML
added: v15.0.0
changes:
- version:
- v18.0.0
- v17.2.0
- v16.14.0
pr-url: https://github.com/nodejs/node/pull/40886

Check warning on line 73 in doc/api/stream.md

View workflow job for this annotation

GitHub Actions / lint-pr-url

pr-url doesn't match the URL of the current PR.
description: Add the `end` option, which can be set to `false` to prevent
automatically closing the destination stream when the source
ends.
-->

* `streams` {Stream\[]|Iterable\[]|AsyncIterable\[]|Function\[]}
Expand All @@ -76,9 +85,11 @@
* `destination` {Stream|Function}
* `source` {AsyncIterable}
* Returns: {Promise|AsyncIterable}
* `options` {Object}
* `options` {Object} Pipeline options
* `signal` {AbortSignal}
* `end` {boolean}
* `end` {boolean} End the destination stream when the source stream ends.
Transform streams are always ended, even if this value is `false`.
**Default:** `true`.
* Returns: {Promise} Fulfills when the pipeline is complete.

```cjs
Expand Down
6 changes: 5 additions & 1 deletion test/parallel/test-stream-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1476,10 +1476,14 @@ const tsp = require('timers/promises');
});

const duplex = new PassThrough();
const transform = new PassThrough();

read.push(null);

await pipelinePromise(read, duplex, { end: false });
await pipelinePromise(read, transform, duplex, { end: false });

assert.strictEqual(transform.destroyed, true);
assert.strictEqual(transform.writableEnded, true);

assert.strictEqual(duplex.destroyed, false);
assert.strictEqual(duplex.writableEnded, false);
Expand Down
Loading