Promise-returning delay function

Andrea Giammarchi andrea.giammarchi at
Mon Oct 27 03:21:55 PDT 2014

Not sure if discussed already but I believe `.cancel()` or
`.forgetAboutIt()` mechanism should be proposed before introducing any

Promises often put developers in unmanaged roads where things keep being
"forgotten" and/or impossible to drop without ending up in the next chain,
undesired, or the error stack, even less desired.

What I mean is that if `setTimeout` is a desired pattern to replicate
through `.delay(ms)`, but I really don't understand why that would be a
desired pattern at all, `clearTimeout` functionality should be considered
as well.

A generic `.cancel()` would be most likely the easier approach but it
should be implemented upfront.


On Mon, Oct 27, 2014 at 4:41 AM, Brendan Eich <brendan at> wrote:

> Domenic Denicola wrote:
>> BTW I definitely agree that promise-returning `delay(ms)` as a better
>> `setTimeout` should be part of the standard library.
> See where I'm
> subtweeted but with some justice. setTimeout began life taking only a
> program to eval, and given the general implicit-conversion mania afflicting
> me and others at Netscape, it converts its first argument to string source
> for that program. Only in Netscape 3 did the funarg-first form come in.
> Sorry about that, and you're right -- at some promise-allocation and
> cognitive load costs, a new API could win. Another option is to have a new
> functional API, but I bet it won't be easy to name well or get approved.
> /be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list