doc: Update backpressuring-in-streams.md by introducing pipeline since v10.0.0#1758
doc: Update backpressuring-in-streams.md by introducing pipeline since v10.0.0#17583 commits merged into
backpressuring-in-streams.md by introducing pipeline since v10.0.0#1758Conversation
since v10.0.0 Ref: #1668
|
/cc @mcollina @mafintosh |
mcollina
left a comment
There was a problem hiding this comment.
LGTM. I’ll soon be releasing readable-stream@3 that enables pipeline in Node 6+.
We should be updating this accordingly.
|
If What do you think? If you’d like, I can push a small example. |
Bamieh
left a comment
There was a problem hiding this comment.
Thank you for taking the time to improve this
| [`pump`][]. This is a module method to pipe between streams forwarding errors | ||
| and properly cleaning up and provide a callback when the pipeline is complete. | ||
|
|
||
| You can use it like this following: |
There was a problem hiding this comment.
to stay consistent with other parts of the document, lets rephrase this:
Here is an example of using pipeline:
| } | ||
| ); | ||
| ``` | ||
| or if you wanna `async` with `await`, you can use it wrapped by [`promisify`][]: |
There was a problem hiding this comment.
Let's replace "wanna" since it is not formal english
You can call [
promisify][] onpipelineto use it withasync/await:
| // Either of the following ways you can call the `run()`: | ||
|
|
||
| // Way 1: You can use this to catch exceptions in async mode. | ||
| run().catch((err) => console.log('Pipeline failed', err)); |
There was a problem hiding this comment.
I feel this is redundant, maybe just having the following code snippet is enough:
async function run() {
try {
await pipeline(
fs.createReadStream('The.Matrix.1080p.mkv'),
zlib.createGzip(),
fs.createWriteStream('The.Matrix.1080p.mkv.gz'),
);
} catch(err) {
console.error('Pipeline failed', err);
}
}|
Closes #1668 |
|
|
||
| // Use the pipeline API to easily pipe a series of streams | ||
| // together and get notified when the pipeline is fully done. | ||
| // A pipeline to gzip a potentially huge tar file efficiently: |
There was a problem hiding this comment.
tar file -> video file?
|
@vsemozhetbyt, @sonicdoe & @Bamieh: @sonicdoe:The @Bamieh:Maybe when this submit is merged, you can close your issue, or I'll help to close. |
|
@mcollina:I've merged this, and waiting for your changes onto my submitted one. Then I'll call other translators to make a translation on what we've changed. |
|
I think you can go ahead and start translating this change. It might take me a bit more time, and I do not want to stop any activity. |
|
OK. Thanks! @mcollina |
1) Translations of files in `locale\zh-cn\docs` 2) Update for `pipeline` Ref: #1758
Ref: #1668
PS:Considering the method is introduced since v10.0.0, and we can still use chains of
pipe()together, so I still keep the original codes and explainations. But just add for new introductions ofpipeline().