-
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: make Buffer documentation styles consistent #4873
Conversation
* `offset` Number | ||
* `noAssert` Boolean, Optional, Default: false | ||
* Return: Number | ||
* `offset` {Number} `0 <= offset <= buf.length` |
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.
0 <= offset <= buf.length
is very "techy", but I can't think of a better way to describe this requirement.
Offset of < 0
or > byteLength
would throw new RangeError('Index out of range')
Maybe a paragraph about this error (not sure where) instead of a "techy" requirement expression?
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.
Well, I'd say that anybody reading documentation on a module designed to do binary stuff "techy" :P
It should be fairly obvious and intuitive that one cannot read (or write) out of range, so I'd argue against having a separate paragraph for such a simple constraint.
How about:
offset
Number Must be between 0 and the length of the buffer, inclusive
I don't think it is any clearer than the pseudo-JavaScript expression however.
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.
Shouldn't it actually be 0 <= offset < buf.length
? Anyways, I'd reduce the description to just "Zero-based byte offset" or similar.
@TimothyGu .. thank you for the PR! Can I ask you to please fill the PR text in with some detail about the change (just copying over the commit text would suffice). Also, it looks like the PR needs to be rebased and updated. |
@@ -319,84 +320,18 @@ console.log(bufA.length); | |||
### Class Method: Buffer.isBuffer(obj) | |||
|
|||
* `obj` Object |
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.
Forgot to wrap?
@jasnell, PR updated. All comments addressed as well. |
Awesome! Thank you! LGTM |
* `end` Number, Optional | ||
* `value` {String or Number} | ||
* `offset` {Number} Default: 0 | ||
* `end` {Number} Default: `buffer.length` |
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.
Return value is missing
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.
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: #4873 Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in 6ad1f7b |
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: #4873 Reviewed-By: James M Snell <jasnell@gmail.com>
Blocked from backporting until other PR's are merged first |
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: #4873 Reviewed-By: James M Snell <jasnell@gmail.com>
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: #4873 Reviewed-By: James M Snell <jasnell@gmail.com>
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: #4873 Reviewed-By: James M Snell <jasnell@gmail.com>
- Maintain alphabetical order - Add documentation for `offset` and `value` where absent - Add return value documentation where absent - Remove redundant "Optional" - Move defaults to parameter enumerations PR-URL: nodejs#4873 Reviewed-By: James M Snell <jasnell@gmail.com>
offset
andvalue
where absent