Readded map options, simplified ShortcutManager

This commit is contained in:
Davide Passoni
2024-06-27 14:46:28 +02:00
parent fb96926d1e
commit 222a296b4f
19 changed files with 1363 additions and 476 deletions

View File

@@ -1,7 +0,0 @@
import { Manager } from "./manager";
export abstract class EventsManager extends Manager {
constructor() {
super();
}
}

View File

@@ -1,37 +0,0 @@
import { Context } from "../context/context";
export class Manager {
#items: { [key: string]: any } = {};
constructor() {
}
add(name: string, item: any) {
const regex = new RegExp("^[a-z][a-z0-9]{2,}$", "i");
if (regex.test(name) === false) {
throw new Error(`Item name "${name}" does not match regex: ${regex.toString()}.`);
}
if (this.#items.hasOwnProperty(name)) {
throw new Error(`Item with name "${name}" already exists.`);
}
this.#items[name] = item;
return this;
}
get(name: string) {
if (this.#items.hasOwnProperty(name)) {
return this.#items[name];
} else {
return false;
}
}
getAll() {
return this.#items;
}
}