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: improve util.promisify() content in readline.md #42552

Merged
merged 1 commit into from Apr 3, 2022

Conversation

Copy link
Member

@Trott Trott commented Apr 1, 2022

No description provided.

@nodejs-github-bot nodejs-github-bot added doc readline labels Apr 1, 2022
@Trott Trott removed doc readline labels Apr 1, 2022
bnb
bnb approved these changes Apr 1, 2022
Copy link
Contributor

@aduh95 aduh95 left a comment

I don't think we want to recommend using util.promisify over the "built-in" promisified alternative.

Use [`util.promisify()`][] to create a version that returns a
promise that fulfills with the answer. If the question is canceled using
an `AbortController` it will reject with an `AbortError`.
Copy link
Contributor

@aduh95 aduh95 Apr 1, 2022

Choose a reason for hiding this comment

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

Suggested change
Use [`util.promisify()`][] to create a version that returns a
promise that fulfills with the answer. If the question is canceled using
an `AbortController` it will reject with an `AbortError`.
Don't use [`util.promisify()`][] to create a version that returns a
promise that fulfills with the answer, use `require('readline/promises').createInterface` instead. If the question is canceled using
an `AbortController` it will reject with an `AbortError`.

Copy link
Member

@targos targos Apr 1, 2022

Choose a reason for hiding this comment

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

We can also recommend AbortSignal.timeout()

Copy link
Member Author

@Trott Trott Apr 1, 2022

Choose a reason for hiding this comment

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

Since there's a documented promise API, I think we can just delete all the text, or replace it with something like "See [other API][] for a promise-based version of this API."

Copy link
Contributor

@aduh95 aduh95 Apr 1, 2022

Choose a reason for hiding this comment

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

Yes, removing it could make sense indeed. Worth noting that promise API is still marked as experimental and not available on Node.js <17, so we could expect a large chunk of our users would prefer to rely on util.promisify. Folks who want to support older release lines should check the documentation of the older release line.

@Trott
Copy link
Member Author

@Trott Trott commented Apr 2, 2022

Content removed entirely. Does that work well enough, @aduh95?

@aduh95 aduh95 added dont-land-on-v12.x dont-land-on-v14.x dont-land-on-v16.x author ready labels Apr 2, 2022
@Trott Trott added the commit-queue label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue label Apr 3, 2022
@nodejs-github-bot nodejs-github-bot merged commit 059b890 into nodejs:master Apr 3, 2022
24 checks passed
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Apr 3, 2022

Landed in 059b890

@Trott Trott deleted the promisify branch Apr 3, 2022
juanarbol added a commit to juanarbol/node that referenced this issue Apr 5, 2022
PR-URL: nodejs#42552
Reviewed-By: Mestery <[email protected]>
Reviewed-By: Tierney Cyren <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@juanarbol juanarbol mentioned this pull request Apr 5, 2022
@juanarbol juanarbol mentioned this pull request Apr 5, 2022
juanarbol added a commit that referenced this issue Apr 6, 2022
PR-URL: #42552
Reviewed-By: Mestery <[email protected]>
Reviewed-By: Tierney Cyren <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready dont-land-on-v12.x dont-land-on-v14.x dont-land-on-v16.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants