function Promise_async(makeGenerator) {
    return function spawn() {
        // when verb is "next", arg is a value
        // when verb is "throw", arg is an exception
        function continuer(verb, arg) {
            var iteration;
            try {
                iteration = generator[verb](arg);
            } catch (exception) {
                return Promise_throw(exception);
            }
            if (iteration.done) {
                return Promise_return(iteration.value);
            } else {
                return Promise_return(iteration.value).then(callback, errback);
            }
        }
        var generator = makeGenerator.apply(this, arguments);
        var callback = continuer.bind(continuer, "next");
        var errback = continuer.bind(continuer, "throw");
        return callback();
    };
}
The async function is a decorator for generator functions, turning
them into asynchronous generators. Although generators are only
part of the newest ECMAScript 6 drafts, this code does not cause
syntax errors in older engines. This code should continue to work
and will in fact improve over time as the language improves.

ES6 generators are currently part of V8 version 3.19 with the
`--harmony-generators` runtime flag enabled. This function does not
support the former, Pythonic generators that were only implemented
by SpiderMonkey.

Decorates a generator function such that:
 - it may yield promises
 - execution will continue when that promise is fulfilled
 - the value of the yield expression will be the fulfilled value
 - it returns a promise for the return value (when the generator
   stops iterating)
 - the decorated function returns a promise for the return value
   of the generator or the first rejected promise among those
   yielded.
 - if an error is thrown in the generator, it propagates through
   every following yield until it is caught, or until it escapes
   the generator function altogether, and is translated into a
   rejection for the promise returned by the decorated generator.