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

Support for converting a NodeJS.Immediate to a number #56776

Open
fabiospampinato opened this issue Jan 26, 2025 · 3 comments
Open

Support for converting a NodeJS.Immediate to a number #56776

fabiospampinato opened this issue Jan 26, 2025 · 3 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@fabiospampinato
Copy link

fabiospampinato commented Jan 26, 2025

What is the problem this feature will solve?

Objects returned by setTimeout and setInterval support being converted to a raw number, for better compatibility with the web I guess, but setImmediate doesn't support the same, which seems an ugly luck a symmetry.

Basically this is a thing for timeouts:

const id = +setTimeout ( () => {} );
clearTimeout ( id );

It is a thing for intervals:

const id = +setInterval ( () => {} );
clearInterval ( id );

But it's not a thing for "immediates" (?):

const id = +setImmediate ( () => {} );
clearImmediate ( id );

What is the feature you are proposing to solve the problem?

Presumably there should be a counter dedicated to immediate callbacks?

What alternatives have you considered?

Implementing this in userland I guess?

@fabiospampinato fabiospampinato added the feature request Issues that request new features to be added to Node.js. label Jan 26, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Jan 26, 2025
@aduh95
Copy link
Contributor

aduh95 commented Jan 27, 2025

Is it just for aesthetic sake, or do you have an actual use-case in mind?

@fabiospampinato
Copy link
Author

fabiospampinato commented Jan 27, 2025

@aduh95 my use case is providing setImmediate/clearImmediate functions that work in the browser too, with the same interface, and I don't think I should be returning a "NodeJS.Immediate" object thing in a browser environment. It's easy enough to make up a number in userland though, so the main point about this issue is actually about the ugliness required to do that, imo.

@nodejs nodejs deleted a comment from alialobidm Feb 3, 2025
@nodejs nodejs deleted a comment from alialobidm Feb 3, 2025
@bnoordhuis
Copy link
Member

Doesn't seem objectionable to me and I don't think there are backwards compatibility risks. Pull request welcome, I suppose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
Status: Awaiting Triage
Development

No branches or pull requests

3 participants