Skip to content

doc: add esm examples to node:readline#55335

Merged
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
mfdebian:docs-readline-esm
Dec 14, 2024
Merged

doc: add esm examples to node:readline#55335
nodejs-github-bot merged 3 commits into
nodejs:mainfrom
mfdebian:docs-readline-esm

Conversation

@mfdebian

@mfdebian mfdebian commented Oct 9, 2024

Copy link
Copy Markdown
Contributor

This PR adds the missing ESM counterparts of the CJS examples for the Readline documentation.

I've tested every single example and they all work/behave as expected.

Best regards!

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. readline Issues and PRs related to the built-in readline module. labels Oct 9, 2024
Comment thread doc/api/readline.md Outdated
```

```cjs
const readlinePromises = require('node:readline/promises');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you use destructuring in the ESM, it should probably also be used here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok! I generally try not to touch the examples that are already there, but if you think that'd be better I'll do it!

Should I do it for that example in particular or for the rest of the examples as well?

Thanks for the feedback! 🙌

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IMO all of them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

You were right, now it looks more concise with the first example as well.

Thank you! 😊

Comment thread doc/api/readline.md Outdated
Comment on lines +717 to +718
const { stdin: input, stdout: output } = require('node:process');
const rl = createInterface({ input, output });

@avivkeller avivkeller Oct 12, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This example and the MJS example should be as close to identical as possible, except for the import.

However, you don't need to require process in CJS

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In other words, the examples should look exactly the same (except the import + process). That way, users can ensure consistency

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Thank you for taking the time to review the changes and give feedback to me 🙏 !

@mfdebian

mfdebian commented Dec 5, 2024

Copy link
Copy Markdown
Contributor Author

hello @redyetidev I've made the changes you requested, can I kindly ask you to review once more and if everything looks good to you you can approve the PR? 😊 if not, let me know what other changes you'd like me to make!

I generally try to not change everything too much just so there's a lot of consistency between the CJS and ESM examples for new users but let me know your thoughts!

Thanks in advance! 🙌

@lpinca lpinca added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Dec 14, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Dec 14, 2024
@nodejs-github-bot nodejs-github-bot merged commit a7c9f85 into nodejs:main Dec 14, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in a7c9f85

aduh95 pushed a commit that referenced this pull request Dec 18, 2024
PR-URL: #55335
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. doc Issues and PRs related to the documentations. readline Issues and PRs related to the built-in readline module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants