mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 12:38:39 -09:00
24 lines
363 B
JavaScript
24 lines
363 B
JavaScript
|
|
const commands = {};
|
||
|
|
|
||
|
|
class CommandRegistry {
|
||
|
|
register(cmds) {
|
||
|
|
if (cmds) {
|
||
|
|
for (const command in cmds) {
|
||
|
|
if (command) {
|
||
|
|
commands[command] = cmds[command];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
getCommand(cmd) {
|
||
|
|
return commands[cmd] !== undefined;
|
||
|
|
}
|
||
|
|
|
||
|
|
exec(cmd, e) {
|
||
|
|
commands[cmd](e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default new CommandRegistry();
|