hyper/lib/command-registry.js

24 lines
363 B
JavaScript
Raw Normal View History

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();