Skip to content

Conversation

@groupsvkg
Copy link
Contributor

Description

Updated [Discover Promises in Node.js](https://nodejs.org/en/learn/asynchronous-work/discover-promises-in-nodejs#discover-promises-in-nodejs) page

Validation

Related Issues

Check List

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

Signed-off-by: Vishal Kumar Gupta <groupsvkg@gmail.com>
Copilot AI review requested due to automatic review settings May 20, 2025 15:36
@groupsvkg groupsvkg requested a review from a team as a code owner May 20, 2025 15:36
@vercel
Copy link

vercel bot commented May 20, 2025

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

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview May 20, 2025 4:01pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adjusts the code example in the Discover Promises guide to import the full fs module and use its promises property, rather than requiring the promises API directly.

  • Swapped require('node:fs').promises for require('node:fs')
  • Updated the readFile call to use fs.promises.readFile
Comments suppressed due to low confidence (1)

apps/site/pages/en/learn/asynchronous-work/discover-promises-in-nodejs.md:162

  • Consider adding a note about Node.js version requirements for the direct require('node:fs/promises') import, as it’s only available in Node.js 14+.
const fs = require('node:fs');

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this better? It's the exact same thing, except the previous example worked interchangeably with the code comment, and this would break if you replace the imported version with the promise version.

@groupsvkg
Copy link
Contributor Author

groupsvkg commented May 20, 2025

Why is this better? It's the exact same thing

its better because the text below the code snippet says fs.promises.readFile().

image

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's cool and more readable

@avivkeller
Copy link
Member

I think we should update the text to match the example. This example is purposely formatted in such a way where that time can be replaced with an fs/promises import and be used the same

Signed-off-by: Vishal Kumar Gupta <groupsvkg@gmail.com>
@groupsvkg
Copy link
Contributor Author

I think we should update the text to match the example. This example is purposely formatted in such a way where that time can be replaced with an fs/promises import and be used the same

Yes it makes sense.

@avivkeller avivkeller changed the title Update discover-promises-in-nodejs.md learn(promises): update fs/promises example May 20, 2025
@codecov-commenter
Copy link

codecov-commenter commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.08%. Comparing base (232e7f1) to head (ac4c6e8).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7763      +/-   ##
==========================================
- Coverage   75.10%   75.08%   -0.03%     
==========================================
  Files          98       98              
  Lines        7914     7914              
  Branches      196      196              
==========================================
- Hits         5944     5942       -2     
- Misses       1969     1971       +2     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2025

Lighthouse Results

URL Performance Accessibility Best Practices SEO Report
/en 🟠 77 🟢 100 🟢 100 🟢 91 🔗
/en/about 🟢 100 🟢 100 🟢 100 🟠 82 🔗
/en/about/previous-releases 🟢 100 🟢 100 🟢 100 🟠 83 🔗
/en/download 🟢 97 🟢 100 🟢 96 🟢 91 🔗
/en/blog 🟢 100 🟢 100 🟢 96 🟢 92 🔗

@avivkeller avivkeller added this pull request to the merge queue May 23, 2025
Merged via the queue into nodejs:main with commit d27573c May 23, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants