const fs = require('fs')
let out = after(2,()=>{
console.log(renderObj)
})
const after = (times,fn)=>()=>--times == 0 && fn()
let renderObj = {}
fs.readFile('./name.txt','utf-8',function(err,data){
renderObj.name = data;
out()
})
fs.readFile('./age.txt','utf-8',function(err,data){
renderObj.age = data
out()
})
核心是通过计数来保证同时获取多个并发的完整数据 类似的方法还有promise.all()