File size: 380 Bytes
6c07b9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const { TextFile } = require('./TextFile.js');
class JSONFile {
constructor(filename) {
this.adapter = new TextFile(filename);
}
async read() {
const data = await this.adapter.read();
if (data === null) {
return null;
}
else {
return JSON.parse(data);
}
}
write(obj) {
return this.adapter.write(JSON.stringify(obj, null, 2));
}
}
module.exports = { JSONFile };