Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/lib/lowdb/adapters/TextFile.js
2591 views
1
//═══════════════════════════════════════════════════════//
2
//If you want to recode, reupload
3
//or copy the codes/script,
4
//pls give credit
5
//no credit? i will take action immediately
6
//© 2022 Xeon Bot Inc. Cheems Bot MD
7
//Thank you to Lord Buddha, Family and Myself
8
//════════════════════════════//
9
const fs = require('fs');
10
const { Writer } = require('steno');
11
class TextFile {
12
constructor(filename) {
13
this.filename = filename;
14
this.writer = new Writer(filename);
15
}
16
async read() {
17
let data;
18
try {
19
data = await fs.promises.readFile(this.filename, 'utf-8');
20
}
21
catch (e) {
22
if (e.code === 'ENOENT') {
23
return null;
24
}
25
throw e;
26
}
27
return data;
28
}
29
write(str) {
30
return this.writer.write(str);
31
}
32
}
33
module.exports = { TextFile };
34