0
0
Fork 0

Add functional code

This commit is contained in:
Tyler-A 2020-04-20 15:48:01 -06:00
parent 23bc6c10f5
commit f34b4f2cb3
5 changed files with 251 additions and 0 deletions

21
src/database.ts Normal file
View file

@ -0,0 +1,21 @@
import { MSG_ID_FILE, DB_NAME } from "./config";
import * as fs from "fs";
export const LOAD_MSG_ID = (): string => {
return fs.readFileSync(`./${MSG_ID_FILE}`, `utf8`)
};
export const WRITE_MSG_ID = (new_id: string) => {
return fs.writeFileSync(`./${MSG_ID_FILE}`, new_id)
};
export const LOAD_USED_QUOTES = (): string[] => {
return JSON.parse(fs.readFileSync(`./${DB_NAME}`, `utf`));
};
export const WRITE_USED_QUOTES = (data: string[]) => {
fs.writeFileSync(`${DB_NAME}`, JSON.stringify(data));
}