Download lib/lowdb/adapters/TextFile.js from RamaZyx/StableBOT: direct link, hf CLI and curl.
- Browser
- Download file 578 Bytes
-
https://huggingface.co/RamaZyx/StableBOT/resolve/main/lib/lowdb/adapters/TextFile.js
- Command line
-
hf download hf://RamaZyx/StableBOT/lib/lowdb/adapters/TextFile.js
-
curl -L -o TextFile.js https://huggingface.co/RamaZyx/StableBOT/resolve/main/lib/lowdb/adapters/TextFile.js
578 Bytes
| const fs = require('fs'); | |
| const { Writer } = require('steno'); | |
| class TextFile { | |
| constructor(filename) { | |
| this.filename = filename; | |
| this.writer = new Writer(filename); | |
| } | |
| async read() { | |
| let data; | |
| try { | |
| data = await fs.promises.readFile(this.filename, 'utf-8'); | |
| } | |
| catch (e) { | |
| if (e.code === 'ENOENT') { | |
| return null; | |
| } | |
| throw e; | |
| } | |
| return data; | |
| } | |
| write(str) { | |
| return this.writer.write(str); | |
| } | |
| } | |
| module.exports = { TextFile }; |