38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
const HIPPIE = (function () {
|
|
'use strict';
|
|
|
|
const onerowAlphabet = "/\\ ]3 ( |) [- /= (_, |-| | _T /< |_ |\\/| |\\| () |^ ()_ /? _\\~ ~|~ |_| \\/ \\/\\/ >< `/ ~/_ ";
|
|
const onerowDigits = "(\\) \'| ^/_1 -} +| ;~ (o \"/ {} \"| ";
|
|
|
|
function mapStringToValues(input, values) {
|
|
if (typeof values === 'string') {
|
|
values = values.split(' ');
|
|
}
|
|
|
|
return input
|
|
.toUpperCase()
|
|
.split('')
|
|
.map(char => {
|
|
const charCode = char.charCodeAt(0);
|
|
let index;
|
|
|
|
if (charCode >= 65 && charCode <= 90) { // Check for A-Z
|
|
index = charCode - 65;
|
|
} else if (charCode >= 48 && charCode <= 57) { // Check for 0-9
|
|
index = 26 + (charCode - 48);
|
|
} else {
|
|
return char;
|
|
}
|
|
|
|
return values[index];
|
|
})
|
|
.join('');
|
|
}
|
|
|
|
return {
|
|
mapStringToValues: mapStringToValues,
|
|
alphabet: onerowAlphabet,
|
|
digits: onerowDigits,
|
|
brand: mapStringToValues('h i p p i e', onerowAlphabet + onerowDigits)
|
|
};
|
|
})();
|