Support for await and async
The description from MDN:
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module.
Await is useful for calling and waiting for results from remote services and code readability.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await
Since ECMAScript 4 proposed generators without using a * prefix in function names unlike in ECMAScript Harmony, I suggest, please... maybe do not introduce the async modifier and comply with ECMAScript 4?
Not that it's difficult to parse, but it'd be nice to have a general consensus in the syntax, since ActionScript 3.0 implements most of ECMAScript 4.
ES4 examples:
/* methodThatYields(): Iterator.<Number> */
function methodThatYields(): Number {
for (var i = 0; i < 10; i++) {
yield i
}
}
Example of asynchronous methods as in AS3Parser:
function asynchronousMethod1(): Promise.<Number> (
Promise.resolve(10)
);
function asynchronousMethod2(): Promise.<Number> {
return await asynchronousMethod1();
}
I've an implementation of Promise in my repository, as well (based on a polyfill), but I added a simple type parameter, so you may want to look at agera.util instead.