1.0.0 • Published 2 years ago

1812b-lzy3 v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

fs算法

打印文本内容

let fs = require("fs");

function fun(url) {
    return new Promise((resolve, reject) => {
        fs.readFile(url, "utf-8", (err, data) => {
            if (err) {
                reject(err);
                return;
            } else {
                resolve(data)
            }
        })
    })
}
fun("1.txt").then(data1 => {
    console.log(data1)
    return fun("2.txt");
}).then(data2 => {
    console.log(data2)
    return fun("3.txt");
})
1.0.0

2 years ago