-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
doc: Update backpressuring-in-streams.md
by introducing pipeline
since v10.0.0
#1758
Conversation
since v10.0.0 Ref: #1668
/cc @mcollina @mafintosh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to stay consistent with other parts of the document, lets rephrase this:
Here is an example of using pipeline:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
); | ||
``` | ||
or if you wanna `async` with `await`, you can use it wrapped by [`promisify`][]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's replace "wanna" since it is not formal english
You can call [
promisify
][] onpipeline
to 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tar file
-> video file
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@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()
.