doc: clarified stream.Transform callback argument logic#48653
Closed
rafasofizada wants to merge 1 commit intonodejs:mainfrom
rafasofizada:main
Closed
doc: clarified stream.Transform callback argument logic#48653rafasofizada wants to merge 1 commit intonodejs:mainfrom rafasofizada:main
rafasofizada wants to merge 1 commit intonodejs:mainfrom
rafasofizada:main
Conversation
lpinca
approved these changes
Jul 6, 2023
| if an error occurred while processing the input or `null` otherwise. If a second | ||
| argument is passed to the `callback`, it will be forwarded on to the | ||
| `transform.push()` method. In other words, the following are equivalent: | ||
| `transform.push()` method, but only if the first argument is `null`. In other |
Member
There was a problem hiding this comment.
Suggested change
| `transform.push()` method, but only if the first argument is `null`. In other | |
| `transform.push()` method, but only if the first argument is falsy. In other |
Contributor
Author
|
@lpinca thanks for the approval! Could you please advice how would I go about editing the commit message to pass the lint-commit-message check? |
Member
|
Wrap the commit message body to 72 chars per line. Also use an imperative verb for commit message title (clarified -> clarify). |
Clarify that streamTransform callback second argument is passed only if the first argument is `null`, i.e. no error occured processing the chunk.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clarified that
stream.Transformcallback second argument is passed only if the first argument isnull, i.e. no error occured processing the chunk.From the way the documentation is written right now, I expected the second argument to be forwarded to
transform.push(), even if the first argument is anError. I was implementing a truncation stream, and passed both anError("stream exceeded maximum size"; could be optionally caught and ignored), and the last (truncated) chunk. Only after digging through the relevant implementaton I could confirm for sure that the second argument is entirely ignored if the first one is notnull.Please tell me if you want to adjust the wording somehow, or whether I should add an alternative example to the one following the line "In other words, the following are equivalent:". Hopefully you'll find this useful.