Skip to content

Instantly share code, notes, and snippets.

@nortonwong
Created September 3, 2019 00:59
Show Gist options
  • Save nortonwong/6b24886c50a05740b187e74775cdded8 to your computer and use it in GitHub Desktop.
Save nortonwong/6b24886c50a05740b187e74775cdded8 to your computer and use it in GitHub Desktop.
((text = '') => {
const map = {
a: '𝓪',
A: '𝓐',
};
const shift = (char, shift) => String.fromCodePoint(char.codePointAt(0) + shift);
Object.entries(map).forEach(([from, to]) => {
for (let i = 0; i < 26; i++) {
map[shift(from, i)] = shift(to, i);
}
});
return text.split('').map(c => map[c] || c).join('') || map;
})(`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment