<commit_before>Sample program: [server.asyncawait.js](server.asyncawait.js) using [sweet.js](http://sweetjs.org/) approximation of the proposed grammar and desugaring.

To run the example

```JavaScript
npm install 
sjs server.asyncawait.js -o server.js 
node --harmony server.js
```


# Async Functions for  ECMAScript

The introduction of Promises and Generators in ECMAScript presents an opportunity to dramatically improve the language-level model for writing asynchronous code in ECMAScript.  

A similar proposal was made with [Defered Functions](http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions) during ES6 discussions.  The proposal here supports the same use cases, using similar or the same syntax, but directly building upong generators and promises instead of defining custom mechanisms.

## Example

Take the following example, first written using Promises.  This code chains a set of animations on an element, stopping when there is an exceptionin an animation, and returning the value produced by the final succesfully executed animation.

```JavaScript
function chainAnimationsPromise(elem, animations) {
    var ret = null;
    var p = currentPromise;
    for(var anim in animations) {
        p = p.then(function(val) {<commit_msg>Cleanup<commit_after>Sample program: [server.asyncawait.js](server.asyncawait.js) using [sweet.js](http://sweetjs.org/) approximation of the proposed grammar and desugaring.

To run the example:
```JavaScript
npm install 
sjs server.asyncawait.js -o server.js 
node --harmony server.js
```

# Async Functions for  ECMAScript

The introduction of Promises and Generators in ECMAScript presents an opportunity to dramatically improve the language-level model for writing asynchronous code in ECMAScript.  

A similar proposal was made with [Defered Functions](http://wiki.ecmascript.org/doku.php?id=strawman:deferred_functions) during ES6 discussions.  The proposal here supports the same use cases, using similar or the same syntax, but directly building upong generators and promises instead of defining custom mechanisms.

## Example

Take the following example, first written using Promises.  This code chains a set of animations on an element, stopping when there is an exceptionin an animation, and returning the value produced by the final succesfully executed animation.

```JavaScript
function chainAnimationsPromise(elem, animations) {
    var ret = null;
    var p = currentPromise;
    for(var anim in animations) {
        p = p.then(function(val) {
{'fraction_non_alphanumeric': 0.06687772061733281, 'fraction_numerical': 0.0007914523149980214, 'mean_word_length': 4.811494252873564, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1230452', 'n_tokens_mistral': 669, 'n_tokens_neox': 639, 'n_words': 288}