-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: document default length as buffer.length #40354
base: main
Are you sure you want to change the base?
Conversation
The Buffer documentation documents the 'buf.length' property as: 'Returns the number of bytes in buf.' It uses the .length property in its own internal references on that page. Buffer.byteLength is a static function which takes a string parameter.
One character over on one line of a commit comment. Kind of frustrating to have to redo for that! Maybe someone else can pick it up from here. |
@@ -3022,7 +3022,7 @@ changes: | |||
* `options` {Object} | |||
* `buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)` | |||
* `offset` {integer} **Default:** `0` | |||
* `length` {integer} **Default:** `buffer.byteLength` | |||
* `length` {integer} **Default:** `buffer.length` (`.byteLength` for TypedArray|DataView types) |
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 personally don't think this makes it much clearer. buffer.byteLength
is correct for Buffer
and TypedArray
, whereas buffer.length
is only correct for Buffer
(and Uint8Array
).
buffer.byteLength
is always correct, buffer.length
is not.
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.
According to the documentation, Buffer.byteLength
is a function that does not return the number of bytes in the buffer. Buffer.length
does provide that data.
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.
@wbt Buffer
extends Uint8Array
. buffer.byteLength
is the instance property that is inherited from Uint8Array
. Buffer.byteLength()
(capital B
) is the static method.
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.
@tniessen Does the latest commit seem to provide more helpful clarification?
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.
FWIW I agree with Tobias, we should keep referencing .byteLength
– it's also what the code is doing.
Per review comment: nodejs#40354 (comment)
to meet 80 character limit
enabling easier find on page for folks coming from the fs documentation, per comment at nodejs#40354 (comment)
since this editor doesn't do that automatically....
@@ -2308,6 +2308,7 @@ added: v0.1.90 | |||
* {integer} | |||
|
|||
Returns the number of bytes in `buf`. | |||
An alias of the inherited [`buf.byteLength`][]. |
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 think it's more correct to say it's the inherited buf.length
– which happens to be the same as buf.byteLength
. I would remove this change from this PR.
This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open. |
I think there's still a useful contribution, but blockers like being one character over on a commit comment underscore somewhat artificially high barriers to contribution here. |
Chances are your contribution is useful :-), but if you'd like to provide information about the "artistically high barriers", please open a new issue, and im sure members of Node.js will be happy to discuss! |
The PR was originally rejected because one of the six commit comments was a single character too long, and the process of trying to go through and change history is a nontrivial amount of work relative to the size of the proposed change. If someone's interested in learning more about the large total value of contributions that is discarded when small valuable contributions are no longer worth making because the cost of making the contribution exceeds the value of the individual contribution, I'd recommend Clay Shirky's books (example here) as an entry point. While I don't think the barrier to contribution should be at zero, I don't think it should be higher than is really necessary and this rejection really felt like a strong example of the barriers being higher than necessary. |
Here are the instructions, at least how I understand them
git rebase -i HEAD~6
|
Hi @wbt please don't feel discouraged, if you don't mind resolving the conflict, I could help you make the commit message body pass the pipeline check (as a vim user this is really just press |
The Buffer documentation documents the 'buf.length' property as:
'Returns the number of bytes in buf.'
It uses the .length property in its own internal references on that page.
Buffer.byteLength is a static function which takes a string parameter.
The documentation was confusing; this PR should help clarify it.