projek3 / lib /lowdb /adapters /JSONFileSync.js
devstok's picture
Upload folder using huggingface_hub
47ab1ce verified
raw
history blame contribute delete
485 Bytes
const { TextFileSync } = require('./TextFileSync.js');
class JSONFileSync {
constructor(filename) {
this.adapter = new TextFileSync(filename);
}
read() {
const data = this.adapter.read();
if (data === null) {
return null;
}
else {
return JSON.parse(data);
}
}
write(obj) {
this.adapter.write(JSON.stringify(obj, null, 2));
}
}
module.exports = { JSONFileSync };