/*
f_create_keymap(layout1, layout2)
return a map object.
layout1 is a string.
such as
"
a b c d
"
layout2 is a string.
such as
"
a o e i
"
return a map, such as
[
[a,a]
[b,o]
[c,e]
[d,i]
]
if the strings in the argument is not the same length, return error.
*/constf_create_keymap = (layout1, layout2) => {
constxresultMap = newMap([]);
[...layout1].forEach((item, index) => {
if (item === layout2[index]) {
} else {
xresultMap.set(item, layout2[index]);
}
});
returnxresultMap;
};
const layout1 = `
qwertyuiop[]\\
asdfghjkl;'
zxcvbnm,./
`;
const layout2 = `
byou';ldwvz=\\
ciea,.htsnq
gxjk-/rmfp
`;
console.log(f_create_keymap(layout1, layout2));