Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jajbshjahavahh
GitHub Repository: jajbshjahavahh/Gojo-Satoru
Path: blob/master/lib/lowdb/adapters/JSONFile.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 { TextFile } = require('./TextFile.js');
10
class JSONFile {
11
constructor(filename) {
12
this.adapter = new TextFile(filename);
13
}
14
async read() {
15
const data = await this.adapter.read();
16
if (data === null) {
17
return null;
18
}
19
else {
20
return JSON.parse(data);
21
}
22
}
23
write(obj) {
24
return this.adapter.write(JSON.stringify(obj, null, 2));
25
}
26
}
27
module.exports = { JSONFile };
28
29