mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
27 lines
508 B
JavaScript
27 lines
508 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
|
|
};
|