gyfzk
v1.0.0
Published
```js //首页创建3个文件.txt 要同级关系
Downloads
1
Readme
//首页创建3个文件.txt 要同级关系
//创建2个js文件 一个叫main 另一个叫index
//index 代码如下
const readFile = require("./main");
async function read() {
let str1 = await readFile("1.txt");
let str2 = await readFile("2.txt");
let str3 = await readFile("3.txt");
console.log(str1, str2, str3)
}
read()
//main代码 如下
const fs = require("fs");
const readFile = (pathfile, encoding = "utf8") => {
return new Promise((resolve, reject) => {
fs.readFile(pathfile, encoding, (err, data) => {
if (err) {
reject(err);
return;
}
resolve(data)
})
})
}
module.exports = readFile