Promise-returning delay function
C. Scott Ananian
ecmascript at cscott.net
Tue Sep 9 05:07:10 PDT 2014
The npm `prfun` package uses both prototypes patching and subclassing,
fwiw. And it implements both `Promise.delay` and
`Promise.prototype.delay`. I'd be interested in feedback after folks use
it a bit.
On Sep 9, 2014 4:43 AM, "Sébastien Cevey" <seb.cevey at guardian.co.uk> wrote:
> On 9 Sep 2014 00:13, "Domenic Denicola" <domenic at domenicdenicola.com>
> > (I also find the name `sleep` somewhat attractive, as a re-appropriation
> from threaded contexts. `await sleep(1000)`, heh.)
> Sleep has blocking semantics in all languages I've used it in (eg. C,
> Java, Ruby, Bash, etc) so perhaps best avoid any confusion?
> I've found `delay` very useful and natural in the context of
> Rx.Observables, where it is a method to delay each element in a stream,
> although that's a slightly different use case to what's proposed here.
> What's the recommended way to add capabilities to Promises? Utility
> functions, as suggested here? Promise subclassing/"casting"? Prototype
> monkey patching (I guess not, but some will do that if there's no better
> Reminds me from the elegant/surprising obj::func() binding syntax Domenic
> showed the other day in a presentation, too.
> Visit theguardian.com. On your mobile and tablet, download the Guardian
> iPhone and Android apps theguardian.com/guardianapp and our tablet
> editions theguardian.com/editions. Save up to 57% by subscribing to the
> Guardian and Observer - choose the papers you want and get full digital
> access. Visit subscribe.theguardian.com
> This e-mail and all attachments are confidential and may also be
> privileged. If you are not the named recipient, please notify the sender
> and delete the e-mail and all attachments immediately. Do not disclose the
> contents to another person. You may not use the information for any
> purpose, or store, or copy, it in any way. Guardian News & Media Limited
> is not liable for any computer viruses or other material transmitted with
> or as part of this e-mail. You should employ virus checking software.
> Guardian News & Media Limited is a member of Guardian Media Group plc. Registered
> Office: PO Box 68164, Kings Place, 90 York Way, London, N1P 2AP. Registered
> in England Number 908396
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss