From dc2d2fa26207480f31968795fddd8620af3ec83f Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Fri, 7 Jul 2023 22:05:32 +1000 Subject: [PATCH] Delete unused file --- src/database.ts | 58 ------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/database.ts diff --git a/src/database.ts b/src/database.ts deleted file mode 100644 index 2940f90..0000000 --- a/src/database.ts +++ /dev/null @@ -1,58 +0,0 @@ -import path from 'node:path'; -import { readFileSync, writeFileSync } from 'node:fs'; -import moment from 'moment'; -export class Database { - public _dataType: string; - public _path: string; - public _interval?: NodeJS.Timer; - public _saveNotifs: boolean; - public _content: any; - constructor(dir: string, dataType: string){ - this._dataType = dataType; - this._path = path.resolve(dir); - this._interval = undefined; - this._saveNotifs = true; - this._content = dataType === 'array' ? [] : {}; - } - addData(data: any, data1?: any){ - if (Array.isArray(this._content)) this._content.push(data); - else if (typeof this._content === 'object') this._content[data] = data1; - return this; - } - removeData(key: any, type: number, element: any){ - if (this._dataType === 'array'){ - ({ - 0: ()=>this._content = this._content.filter((x:any)=>x!=key), - 1: ()=>this._content = this._content.filter((x:any)=>x[element]!=key) - })[type]() - } else if (this._dataType === 'object') delete this._content[key]; - return this; - } - initLoad(){ - this._content = JSON.parse(readFileSync(this._path, {encoding: 'utf8'})); - console.log(this._path + ' Database loaded'); - return this; - } - forceSave(db=this, force=false){ - const oldJson = readFileSync(db._path, {encoding: 'utf8'}); - const newJson = JSON.stringify(db._content); - if (oldJson !== newJson || force){ - writeFileSync(this._path, JSON.stringify(this._content, null, 2)); - if (this._saveNotifs) console.log(`[${moment().format('DD/MM/YY HH:mm:ss')}] ` + this._path + ' DB saved'); - } - return db; - } - intervalSave(milliseconds?: number){ - this._interval = setInterval(()=>this.forceSave(this), milliseconds || 60000); - return this; - } - stopInterval(){ - if (this._interval) clearInterval(this._interval); - return this; - } - disableSaveNotifs(){ - this._saveNotifs = false; - console.log(this._path + ' "DB saved" Notifications disabled'); - return this; - } -}