nodejs.org icon indicating copy to clipboard operation
nodejs.org copied to clipboard

fix: legacy - use Buffer.from() instead of btoa()

Open shi-gg opened this issue 1 year ago • 5 comments

Description

Fix homepage example for "Work with Threads": btoa("") is a legacy function, Buffer.from("").toString("base64") should be used instead.

image

Validation

Related Issues

Check List

  • [x] I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • [x] I have run npx turbo format to ensure the code follows the style guide.
  • [x] I have run npx turbo test to check if all tests are passing.
  • [x] I have run npx turbo build to check if the website builds without errors.
  • [x] I've covered new added functionality with unit tests if necessary.

shi-gg avatar Mar 24 '24 12:03 shi-gg

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Mar 24, 2024 0:16am

vercel[bot] avatar Mar 24 '24 12:03 vercel[bot]

The reason why we're using btoa here is for simplicity, by adding imports to Buffer the snippet becomes even more convoluted.

ovflowd avatar Mar 24 '24 12:03 ovflowd

I understand that, though it’s awkward if the official homepage shows deprecated/legacy examples

shi-gg avatar Mar 24 '24 12:03 shi-gg

I understand that, though it’s awkward if the official homepage shows deprecated/legacy examples

Maybe, but it's just a silly example. The important part is the worker communication. For all intends and purposes we can remove btoa and simply do .toUppercase()

The intent was just to show that a separate worker would handle the "work" and that it can work on the "data" you've initially sent.

ovflowd avatar Mar 24 '24 14:03 ovflowd

@Luna-devv do you want to make amends to this PR?

ovflowd avatar Mar 28 '24 23:03 ovflowd