1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| const fsRead = (url: string) => { return new Promise((resolve, reject) => { fs.readFile(url, {flag: 'r', encoding: "utf-8"}, (err, data) => { if(!err) { resolve(data) } else { reject(err) } }) }) }
const fsWrite = (url: string, data: any) => { return new Promise((resolve, reject) => { fs.writeFile(url, data, {flag: 'a', encoding: 'utf-8' }, (err) => { if(!err) { resolve() } else { reject(err) } }) }) }
const fsDir = (url) => { return new Promise((resolve, reject) => { fs.mkdir(url, (err) => { if(!err) { resolve() } }) }) } module.exports = {fsDir,fsRead, fsWrite}
|