await and promise

Mark Volkmann r.mark.volkmann at gmail.com
Sun Mar 30 07:22:38 PDT 2014


I have seen that in Mocha tests, but this code looked different to me.
I'm looking at
https://github.com/google/traceur-compiler/blob/master/test/feature/AsyncFunctions/AlphaRenaming.js
.
I thought to use done in a Mocha test you have to have a parameter named
"done" in the test function.
I suppose I was wrong about that.


On Sun, Mar 30, 2014 at 8:59 AM, Erik Arvidsson <erik.arvidsson at gmail.com>wrote:

> The done function is injected by the Traceur test runner for async tests.
> It is standard mocha stuff.
>
>
> On Sunday, March 30, 2014 9:06:23 AM, Mark Volkmann <
> r.mark.volkmann at gmail.com> wrote:
>
>> I looked at the "async" keyword examples in Traceur for the first time
>> today. Cool stuff!
>>
>> IIUC, when a function is annotated with the async keyword, it can use
>> "await" and the "done" function is magically defined.
>>
>> An interesting corollary to that idea would be to introduce a "promise"
>> keyword that can be used to annotate a function. It would magically define
>> the functions "resolve" and "reject". It would allow a function like this:
>>
>> function foo() {
>>   return new Promise((resolve, reject) => {
>>     // some code that eventually calls resolve or reject
>>   });
>> }
>>
>> to be written like this:
>>
>> promise function foo() {
>>   // some code that eventually calls resolve or reject
>> }
>>
>> Is this a crazy idea? Perhaps if this was available, it would be very
>> rare to actually write "new Promise(" in code.
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>


-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140330/5063b26b/attachment.html>


More information about the es-discuss mailing list