<commit_before>import { Listable } from "../../common/Listable";
import { Spell } from "../../common/Spell";
import { StatBlock } from "../../common/StatBlock";
import { DnDAppFilesImporter } from "../Importers/DnDAppFilesImporter";

export class Store {
    private static _prefix = "ImprovedInitiative";

    public static readonly PlayerCharacters = "PlayerCharacters";
    public static readonly StatBlocks = "Creatures";
    public static readonly Spells = "Spells";
    public static readonly SavedEncounters = "SavedEncounters";
    public static readonly AutoSavedEncounters = "AutoSavedEncounters";
    public static readonly User = "User";

    //Legacy
    public static readonly KeyBindings = "KeyBindings";
    public static readonly ActionBar = "ActionBar";

    public static List(listName: string): string[] {
        let listKey = `${Store._prefix}.${listName}`;
        let list = Store.load(listKey);
        if (list && list.constructor === Array) {
            return list;
        }
        Store.save(listKey, []);
        return [];
    }

    public static Save<T>(listName: string, key: string, value: T) {
        if (typeof (key) !== "string") {
            throw `Can't save to non-string key ${key}`;
        }
        let listKey = `${Store._prefix}.${listName}`;
        let fullKey = `${Store._prefix}.${listName}.${key}`;
        let list = Store.List(listName);<commit_msg>Add PersistentCharacter to Store<commit_after>import { Listable } from "../../common/Listable";
import { Spell } from "../../common/Spell";
import { StatBlock } from "../../common/StatBlock";
import { DnDAppFilesImporter } from "../Importers/DnDAppFilesImporter";

export class Store {
    private static _prefix = "ImprovedInitiative";

    public static readonly PersistentCharacters = "PersistentCharacters";
    public static readonly PlayerCharacters = "PlayerCharacters";
    public static readonly StatBlocks = "Creatures";
    public static readonly Spells = "Spells";
    public static readonly SavedEncounters = "SavedEncounters";
    public static readonly AutoSavedEncounters = "AutoSavedEncounters";
    public static readonly User = "User";

    //Legacy
    public static readonly KeyBindings = "KeyBindings";
    public static readonly ActionBar = "ActionBar";

    public static List(listName: string): string[] {
        let listKey = `${Store._prefix}.${listName}`;
        let list = Store.load(listKey);
        if (list && list.constructor === Array) {
            return list;
        }
        Store.save(listKey, []);
        return [];
    }

    public static Save<T>(listName: string, key: string, value: T) {
        if (typeof (key) !== "string") {
            throw `Can't save to non-string key ${key}`;
        }
        let listKey = `${Store._prefix}.${listName}`;
        let fullKey = `${Store._prefix}.${listName}.${key}`;
        let list = Store.List(listName);
{'fraction_non_alphanumeric': 0.13544173255414232, 'fraction_numerical': 0.0, 'mean_word_length': 3.0416666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '81260', 'n_tokens_mistral': 800, 'n_tokens_neox': 817, 'n_words': 229}