Download lib/lowdb/adapters/JSONFile.js from RamaZyx/StableBOT: direct link, hf CLI and curl.
- Browser
- Download file 465 Bytes
-
https://huggingface.co/RamaZyx/StableBOT/resolve/main/lib/lowdb/adapters/JSONFile.js
- Command line
-
hf download hf://RamaZyx/StableBOT/lib/lowdb/adapters/JSONFile.js
-
curl -L -o JSONFile.js https://huggingface.co/RamaZyx/StableBOT/resolve/main/lib/lowdb/adapters/JSONFile.js
465 Bytes
| 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 }; | |