Skip to content
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: fix typo in buffer.md - should be uint16array #38323

Merged
merged 1 commit into from
Apr 23, 2021
Merged

doc: fix typo in buffer.md - should be uint16array #38323

merged 1 commit into from
Apr 23, 2021

Conversation

theoludwig
Copy link
Contributor

There is a typo inside doc/api/buffer.md, currently the code snippets look like this:

const buf = Buffer.from('hello', 'utf16le');
const uint16arr = new Uint16Array(
  buf.buffer,
  buf.byteOffset,
  buf.length / Uint16Array.BYTES_PER_ELEMENT);

console.log(uint16array);

// Prints: Uint16Array(5) [ 104, 101, 108, 108, 111 ]

But this snippets doesn't work as we've got this error:

console.log(uint16array);
            ^

ReferenceError: uint16array is not defined
    at Object.<anonymous> (/home/divlo/Documents/testing/test/app.js:7:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

To fix it, we need to change uint16arr to uint16array, with that change it effectively prints to stdout : Uint16Array(5) [ 104, 101, 108, 108, 111 ]. 👍

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations. labels Apr 21, 2021
@RaisinTen RaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 22, 2021
'uint16arr' -> 'uint16array'

PR-URL: #38323
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
@aduh95
Copy link
Contributor

aduh95 commented Apr 23, 2021

Landed in 4f11b8b, thanks for the contribution 🎉

@aduh95 aduh95 closed this Apr 23, 2021
@aduh95 aduh95 merged commit 4f11b8b into nodejs:master Apr 23, 2021
@theoludwig theoludwig deleted the doc/fix-typo-buffer-uint16array branch April 27, 2021 09:41
targos pushed a commit that referenced this pull request Apr 29, 2021
'uint16arr' -> 'uint16array'

PR-URL: #38323
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
@targos targos mentioned this pull request May 3, 2021
targos pushed a commit that referenced this pull request May 30, 2021
'uint16arr' -> 'uint16array'

PR-URL: #38323
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
targos pushed a commit that referenced this pull request Jun 5, 2021
'uint16arr' -> 'uint16array'

PR-URL: #38323
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
targos pushed a commit that referenced this pull request Jun 11, 2021
'uint16arr' -> 'uint16array'

PR-URL: #38323
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants