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