import { log } from "./index";1/**2* This class will create a new StoreManager with an appended prefix to it. The generic is there to tell you what that prefix ***is***3*4* **Note: there is already a defaultStore available! In most situations, you'll want to use that.**5*6* <code>7* const newStore = new StoreManager("incog");8*9* // Appends the prefix to the key passed. (EX: "incog||test")10* // Will return a string.11* newStore.getVal("test")12*13* // As stated above the prefix will automatically be appended to the key param (EX: "incog||test")14* newStore.setVal("test", "newVal");15* </code>16*/17class StoreManager<Prefix extends string /* This is here so I know what prefix is appended. It's inferred from the constructor */> {18#prefix: Prefix;19constructor(pref: Prefix) {20this.#prefix = pref;21}22getVal(key: string): string {23log({ type: 'info', bg: true, prefix: true }, `Getting key: ${key} \nFull key: ${this.#prefix}||${key}`);24return localStorage.getItem(`${this.#prefix}||${key}`) as string;25}26setVal(key: string, val: string): void {27log({ type: 'info', bg: false, prefix: true }, `Setting ${key} with value: ${val}`);28localStorage.setItem(`${this.#prefix}||${key}`, val);29}30removeVal(key: string): void {31log({ type: 'info', bg: true, prefix: true }, `Removing ${this.#prefix}||${key}`);32localStorage.removeItem(`${this.#prefix}||${key}`);33}34}3536//this is done so I can see the prefix used.37const defaultStore = new StoreManager("nebula");3839export { StoreManager, defaultStore };404142