A setTimeout that returns a promise that resolves after specified time.
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- javascript
Research direction
No source file, test, or entry point is named. Begin by reading the proposal and linked ES discussion; done would require agreement on the API and its specified behavior before implementation.
Written by the indexing model from the issue text.
Description
I really love Promise.resolve("some value"), however if you want to delay this resolving you have to do something much uglier like
new Promise(resolve => setTimeout(() => resolve("some value"), 1000));
Would love a way to create a promise that waits and resolves. I made a proposal for Promise.after to ES and was informed it is a better fit to recommend here.
It seems a global function might make more sense in this context. Maybe something like resolveIn(1000) that would return a promise that resolves in 1000 milliseconds. This could even be implemented like so:
function resolveIn(milliseconds) {
return new Promise(resolve => setTimeout(() => resolve(milliseconds), milliseconds));
}
And could be used like:
resolveIn(1000).then(/* do something */);
And could be used to resolve a specified value after a delay like so:
resolveIn(1000).then(() => "some value").then(/* do something with "some value" */);
- Dominant language
- HTML
- Stars
- 9.4k
- Forks
- 3.2k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 38
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from whatwg/html
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
topic: media topic: rendering
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
-
clarification
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
compat topic: navigation topic: navigation API
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-api#45 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·