let fs = require(‘fs‘)
// 封装 异步读取文件
function fsRead(path){
return new Promise(function(resolve,reject){
fs.readFile(path,{flag:"r",encoding:"utf-8"},function(err,data){
if(err){
reject(err);
}else{
resolve(data);
}
})
})
}
// 封装 异步写入文件
function fsWrite(path,content){
return new Promise(function(resolve,reject){
fs.writeFile(path,content,{flag:"a",encoding:"utf-8"},function(err){
if(err){
reject(err)
}else{
resolve()
}
})
})
}
module.exports = {
fsRead,
fsWrite
}