Update 'index.js'

This commit is contained in:
wumpus 2022-08-05 21:04:37 +02:00
parent b6bcb92498
commit 866b5a1ef4

View File

@ -1,19 +1,17 @@
let fs = require("fs");
function DB(databaseFile) {
let _db;
if (fs.existsSync(databaseFile)) {
_db = JSON.parse(fs.readFileSync(databaseFile, "utf8"));
} else {
fs.writeFileSync(databaseFile, JSON.stringify({}));
_db = {};
}
return class {
constructor() {
class DB {
constructor(databaseFile) {
let _db;
if (fs.existsSync(databaseFile)) {
_db = JSON.parse(fs.readFileSync(databaseFile, "utf8"));
} else {
fs.writeFileSync(databaseFile, JSON.stringify({}));
_db = {};
}
this.v = _db
this.update = function() {
fs.writeFileSync(databaseFile, JSON.stringify(this.v));
}
}
}
}
exports.DB = DB;