hyper/lib/command-registry.js
Philippe Potvin 93b2229ff5 Implements Commands Key mapping (#1876)
Keymaps part 2
2017-06-02 20:03:47 -04:00

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