SOURCE

function Thunkify(fn){
    return function(){
        const arg = [].silce.call(arguments)
        return function(cb){
            arg.push(cb)
            return fn.apply(this, args);
        }
    }
}

function run(fn) {
  var gen = fn();

  function next(err, data) {
    var result = gen.next(data);
    if (result.done) return;
    result.value(next);
  }

  next();
}

// async await原理
function spawn(genF){
    return new Promise(function(resolve,reject){
        const gen = genF();
        function step(nextF){
            let next;
            try{
                next = nextF()
            }catch(e){
                reject(e)
            }
            if(next.done){
                resolve(next.value)
            }
            Promise.resolve(next.value).then(function(v){
                step(function() { return gen.next(v)})
            },function(e){
                step(function() { return gen.throw(e)})
            })
        }
        step(function() {return gen.next(undefined)})
    })
}
console 命令行工具 X clear

                    
>
console