Skip to content

Instantly share code, notes, and snippets.

@noahlt
Created May 17, 2024 21:26
Show Gist options
  • Save noahlt/c47a5b33e6251983bc8c8a0bbf89b248 to your computer and use it in GitHub Desktop.
Save noahlt/c47a5b33e6251983bc8c8a0bbf89b248 to your computer and use it in GitHub Desktop.
// makeCharMap takes two strings and creates a mapping between characters at the
// same position, like Unix tr or Python string.translate. We don't worry about
// undefineds, since the caller of Map.get has to check for undefined anyways
// (for the case where they pass in an input char that's not in the map).
export const makeCharMap = (inChars: string, outChars: string) =>
new Map(zip(inChars.split(""), outChars.split("")));
export const dvorakKeyInputMap = makeCharMap(`p.,'ieoaujq;`, "ABCDEFGabcde");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment