Skip to content

Instantly share code, notes, and snippets.

@emersondemetrio
Last active September 29, 2022 12:41
Show Gist options
  • Save emersondemetrio/dfd8951881a35ae766d31edf3877554f to your computer and use it in GitHub Desktop.
Save emersondemetrio/dfd8951881a35ae766d31edf3877554f to your computer and use it in GitHub Desktop.
Message to Slack alphabet
console.clear()
const transformMap: { [key: string]: string } = {
'á': 'a',
'à': 'a',
'ó': 'o',
'é': 'e',
'ç': 'c',
'ã': 'a',
'¿': '?',
'o': 'o',
'a': 'a'
}
const transform = (l: string) => {
return transformMap[l] ?? l;
}
const to = (l: string, color = 'yellow') => {
if (l === ' ') return ' ';
if (l === '.') return '.';
if (l === '?') return ':question:';
if (l === '!') return ':exclamation:';
const pure = transform(l);
return `:alphabet-${color}-${pure}:`
}
const from = (w: string) => (w.split('').map(l => to(l)).join(''));
const INPUT = 'Estoy un poco cansado hoy. Y usted cómo está?'
console.log(from(INPUT, 'white))
// Try here
// https://www.typescriptlang.org/play?#code/MYewdgziA2CmB0w4EMBOAKAlAKFJGCSsaWu4EALgAQWrKQBmIqAtgLLIAOAXFQN5UA2gGtYAT16VUASzABzALqTasuVQC+VALz9sVfVQDkAQ8O9DyQwBo9BwwAOzRyzYNGAz08Mhrt-YYBLr1hfN0MAc69gULsAY68XPyMAfq8Afhj-H3MfVztLc0tsdWwySGpaeggmVm0qdGhlGXlMbQA+XTdUWAoAV1QwGjpGZnYuQWgFKjS0qmgAbmLSvEoaEDqGptVWrQ6+JOkGeuhtLR1DI1buvoGjf0W3Q+PT8-hDK57+wcM3h4MnhovIwZD43b7cACOvVglGk4G4hj++gBJzO5wAhO8qNcvkZuLAAB5IZAsZAUOFgBFIqgraicfqwOqVEasBqYRZJHG3AAG3GQ0E4AAtkAAjHoAWjEsGg0BAAHdxQASPj07rqbjcpZlVYMVAgFgbOVbFrtepy+AQTjQaQUdCGd7wUmcQG7NZszDwABWIFkdve7OW5GoAEkAHIABQAqgAVOqGACilBAYiovUGnBAoBpVWQABN1oLk-AqABNVOUWC5mnuFjrGEUYwZQP4ODwWVydC6-XoMNR6OYTBAA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment