hyper/app/utils/keymaps-normalize.js

28 lines
508 B
JavaScript
Raw Normal View History

const {getKeymaps} = require('../config/keymaps');
const normalize = keybinding => {
function sortAlphabetically(a, b) {
return a.localeCompare(b);
}
2017-09-17 00:48:16 -08:00
return keybinding
.toLowerCase()
.split('+')
.sort(sortAlphabetically)
.join('+');
};
const findCommandByKeys = (keys, commands) => {
return commands[normalize(keys)];
};
const getCommand = keys => {
return findCommandByKeys(keys, getKeymaps().keys);
};
module.exports = {
normalize,
findCommandByKeys,
getCommand
};