-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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 undocumented methods on buffer prototype #48041
base: main
Are you sure you want to change the base?
Conversation
c19dbc9
to
69433b7
Compare
ab71c21
to
3145d10
Compare
@nodejs/buffer |
Any chance it get merged? |
@nodejs/documentation |
Commit Queue failed- Loading data for nodejs/node/pull/48041 ✔ Done loading data for nodejs/node/pull/48041 ----------------------------------- PR info ------------------------------------ Title doc: document undocumented methods on buffer prototype (#48041) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch Xstoudi:doc/buffer-undocumented-slice-write -> nodejs:main Labels buffer, doc, author ready Commits 7 - doc: document undocumented method on buffer prototype - doc: lint markdown - doc: remove trailing spaces - doc: forgot two trailing spaces - fix: remove trailing spaces - doc: add added date meta - doc: add missing console.log(bytesWritten) Committers 2 - Xavier Stouder - GitHub PR-URL: https://github.com/nodejs/node/pull/48041 Fixes: https://github.com/nodejs/node/issues/46467 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/48041 Fixes: https://github.com/nodejs/node/issues/46467 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - doc: add missing console.log(bytesWritten) ℹ This PR was created on Tue, 16 May 2023 22:18:43 GMT ✔ Approvals: 2 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/48041#pullrequestreview-1449803511 ✔ - Trivikram Kamat (@trivikr): https://github.com/nodejs/node/pull/48041#pullrequestreview-1549147920 ✔ Last GitHub CI successful ℹ Green GitHub CI is sufficient -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/5678981877 |
**Default**: `buf.length`. | ||
* Returns: {string} | ||
|
||
Decodes buf to a string according ASCII character encoding. `start` and |
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.
Decodes buf to a string according ASCII character encoding. `start` and | |
Decodes `buf` to a string according ASCII character encoding. `start` and |
**Default**: `buf.length`. | ||
* Returns: {string} | ||
|
||
Decodes buf to a string according to base64 character encoding. `start` and |
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.
Decodes buf to a string according to base64 character encoding. `start` and | |
Decodes `buf` to a string according to base64 character encoding. `start` and |
**Default**: `buf.length`. | ||
* Returns: {string} | ||
|
||
Decodes buf to a string according to base64url character encoding. `start` |
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.
Decodes buf to a string according to base64url character encoding. `start` | |
Decodes `buf` to a string according to base64url character encoding. `start` |
**Default**: `buf.length`. | ||
* Returns: {string} | ||
|
||
Decodes buf to a string according to hex character encoding. `start` and |
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.
Decodes buf to a string according to hex character encoding. `start` and | |
Decodes `buf` to a string according to hex character encoding. `start` and |
**Default**: `buf.length`. | ||
* Returns: {string} | ||
|
||
Decodes buf to a string according to latin1 character encoding. `start` and |
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.
Decodes buf to a string according to latin1 character encoding. `start` and | |
Decodes `buf` to a string according to latin1 character encoding. `start` and |
|
||
### `buf.asciiWrite(string[, offset[, length]])` | ||
|
||
* `string` {string} String to write to `buf`. |
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.
Does the string needs to be ASCII? Or what happens if it contains non-ASCII chars?
Writes `string` to `buf` at `offset` according to the base64 character encoding | ||
and returns the number of bytes written. If `buf` did not contain enough space | ||
to fit the entire string, only part of `string` will be written. However, | ||
partially encoded characters will not be written. |
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'm not sure I'd know what to expect if the input string contains non-ASCII chars, does it first convert to UTF-8 or some other encoding then convert it to base64?
Writes `string` to `buf` at `offset` according to the base64url character | ||
encoding and returns the number of bytes written. If `buf` did not contain | ||
enough space to fit the entire string, only part of `string` will be written. | ||
However, partially encoded characters will not be written. |
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.
Same question here
Writes `string` to `buf` at `offset` according to the hex character encoding | ||
and returns the number of bytes written. If `buf` did not contain enough space | ||
to fit the entire string, only part of `string` will be written. However, | ||
partially encoded characters will not be written. |
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.
And here
const bytesWritten = buf.latin1Write('buffer'); | ||
console.log(bytesWritten); | ||
// Prints: 2 |
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.
How does 'buffer'
fit in a 2-byte representation? 🤔
Fixes: #46467