Promise returning version of setTimeout
#3875
Labels
addition/proposal
New features or enhancements
needs implementer interest
Moving the issue forward requires implementers to express interest
With the popularity of
async
/await
in JavaScript and the adoption of DOM futures (promises) across new DOM APIs one pretty common request I've ran into is a promise returning version ofsetTimeout
.This can either be achieved by overloading
setTimeout
or exposing a new method that returns a promise:Ideally, it wouldn't have the string-as-parameter behaviour. One argument against this is that while it's common it's also pretty easily implemented (with the promise constructor). This is true - though I've seen people make mistakes implementing it and it's so common it might make sense to ship it from the platform.
Node also added a
util.promisify.custom
on setTimeout so it's easy to get a version of setTimeout that does this in Node.I'm not really decided myself - I'm mostly asking for this because of API discussions on a new platform that needs timers and the fact I'd rather go with a specified standard than without one - it seems weird to add
setTimeout
as specified in the timers spec taking a callback.The text was updated successfully, but these errors were encountered: