hyper/app/utils/keymaps-normalize.js
2017-09-17 10:43:58 +02:00

23 lines
488 B
JavaScript

const {getKeymaps} = require('../config/keymaps');
const normalize = keybinding => {
function sortAlphabetically(a, b) {
return a.localeCompare(b);
}
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
};