SOURCE

const readFile = (fileName) => (callback) => callback()

let n = 0
readFile('fileName')(function(){
     n += 1;
     return n;
})

var gen = function* (){
  var f1 = yield readFile('fileA');
  var f2 = yield readFile('fileB');
  // ...
  var fn = yield readFile('fileN');
};


// 自动流程执行
var run = function (gen){
    // 初始化迭代器
    const g = gen();    
    // 执行
    process();

    function process(err, valueFromYield){
        const {value, done}= g.next(valueFromYield);
        if(err || done){
            return;
        } else {
            value(process)
        }
    }
}

run(gen)
console 命令行工具 X clear

                    
>
console