build/moon-unit.js
function(iter) {

        var front = null, back = null;

        return _esdown.computed({

            next: function(val) { return send("next", val) },
            throw: function(val) { return send("throw", val) },
            return: function(val) { return send("return", val) },
            }, Symbol.asyncIterator, { _: function() { return this },
        });

        function send(type, value) {

            return new Promise(function(resolve, reject) {

                var x = { type: type, value: value, resolve: resolve, reject: reject, next: null };

                if (back) {

                    // If list is not empty, then push onto the end
                    back = back.next = x;

                } else {

                    // Create new list and resume generator
                    front = back = x;
                    resume(type, value);
                }
            });
        }

        function fulfill(type, value) {

            switch (type) {

                case "return":
                    front.resolve({ value: value, done: true });
                    break;

                case "throw":
                    front.reject(value);
                    break;

                default:
                    front.resolve({ value: value, done: false });
                    break;
            }

            front = front.next;

            if (front) resume(front.type, front.value);
            else back = null;
        }

        function awaitValue(result) {

            var value = result.value;

            if (typeof value === "object" && "_esdown_await" in value) {

                if (result.done)
                    throw new Error("Invalid async generator return");

                return value._esdown_await;
            }

            return null;
        }

        function resume(type, value) {

            // HACK: If the generator does not support the "return" method, then
            // emulate it (poorly) using throw.  (V8 circa 2015-02-13 does not support
            // generator.return.)
            if (type === "return" && !(type in iter)) {

                type = "throw";
                value = { value: value, __return: true };
            }

            try {

                var result$1 = iter[type](value),
                    awaited$0 = awaitValue(result$1);

                if (awaited$0) {

                    Promise.resolve(awaited$0).then(
                        function(x) { return resume("next", x); },
                        function(x) { return resume("throw", x); });

                } else {

                    Promise.resolve(result$1.value).then(
                        function(x) { return fulfill(result$1.done ? "return" : "normal", x); },
                        function(x) { return fulfill("throw", x); });
                }

            } catch (x) {

                // HACK: Return-as-throw
                if (x && x.__return === true)
                    return fulfill("return", x.value);

                fulfill("throw", x);
            }
        }
    }
function(iter) {

        var front = null, back = null;

        return _esdown.computed({

            next: function(val) { return send("next", val) },
            throw: function(val) { return send("throw", val) },
            return: function(val) { return send("return", val) },
            }, Symbol.asyncIterator, { _: function() { return this },
        });

        function send(type, value) {

            return new Promise(function(resolve, reject) {

                var x = { type: type, value: value, resolve: resolve, reject: reject, next: null };

                if (back) {

                    // If list is not empty, then push onto the end
                    back = back.next = x;

                } else {

                    // Create new list and resume generator
                    front = back = x;
                    resume(type, value);
                }
            });
        }

        function fulfill(type, value) {

            switch (type) {

                case "return":
                    front.resolve({ value: value, done: true });
                    break;

                case "throw":
                    front.reject(value);
                    break;

                default:
                    front.resolve({ value: value, done: false });
                    break;
            }

            front = front.next;

            if (front) resume(front.type, front.value);
            else back = null;
        }

        function awaitValue(result) {

            var value = result.value;

            if (typeof value === "object" && "_esdown_await" in value) {

                if (result.done)
                    throw new Error("Invalid async generator return");

                return value._esdown_await;
            }

            return null;
        }

        function resume(type, value) {

            // HACK: If the generator does not support the "return" method, then
            // emulate it (poorly) using throw.  (V8 circa 2015-02-13 does not support
            // generator.return.)
            if (type === "return" && !(type in iter)) {

                type = "throw";
                value = { value: value, __return: true };
            }

            try {

                var result$1 = iter[type](value),
                    awaited$0 = awaitValue(result$1);

                if (awaited$0) {

                    Promise.resolve(awaited$0).then(
                        function(x) { return resume("next", x); },
                        function(x) { return resume("throw", x); });

                } else {

                    Promise.resolve(result$1.value).then(
                        function(x) { return fulfill(result$1.done ? "return" : "normal", x); },
                        function(x) { return fulfill("throw", x); });
                }

            } catch (x) {

                // HACK: Return-as-throw
                if (x && x.__return === true)
                    return fulfill("return", x.value);

                fulfill("throw", x);
            }
        }
    }
function ( iter ) { var front = null , back = null ; return _esdown . computed ( { next : function ( val ) { return send ( "next" , val ) } , throw : function ( val ) { return send ( "throw" , val ) } , return : function ( val ) { return send ( "return" , val ) } , } , Symbol . asyncIterator , { _ : function ( ) { return this } , } ) ; function send ( type , value ) { return new Promise ( function ( resolve , reject ) { var x = { type : type , value : value , resolve : resolve , reject : reject , next : null } ; if ( back ) { // If list is not empty, then push onto the end back = back . next = x ; } else { // Create new list and resume generator front = back = x ; resume ( type , value ) ; } } ) ; } function fulfill ( type , value ) { switch ( type ) { case "return" : front . resolve ( { value : value , done : true } ) ; break ; case "throw" : front . reject ( value ) ; break ; default : front . resolve ( { value : value , done : false } ) ; break ; } front = front . next ; if ( front ) resume ( front . type , front . value ) ; else back = null ; } function awaitValue ( result ) { var value = result . value ; if ( typeof value === "object" && "_esdown_await" in value ) { if ( result . done ) throw new Error ( "Invalid async generator return" ) ; return value . _esdown_await ; } return null ; } function resume ( type , value ) { // HACK: If the generator does not support the "return" method, then // emulate it (poorly) using throw.  (V8 circa 2015-02-13 does not support // generator.return.) if ( type === "return" && ! ( type in iter ) ) { type = "throw" ; value = { value : value , __return : true } ; } try { var result$1 = iter [ type ] ( value ) , awaited$0 = awaitValue ( result$1 ) ; if ( awaited$0 ) { Promise . resolve ( awaited$0 ) . then ( function ( x ) { return resume ( "next" , x ) ; } , function ( x ) { return resume ( "throw" , x ) ; } ) ; } else { Promise . resolve ( result$1 . value ) . then ( function ( x ) { return fulfill ( result$1 . done ? "return" : "normal" , x ) ; } , function ( x ) { return fulfill ( "throw" , x ) ; } ) ; } } catch ( x ) { // HACK: Return-as-throw if ( x && x . __return === true ) return fulfill ( "return" , x . value ) ; fulfill ( "throw" , x ) ; } } }
Support for async generators
Support for async generators