@voiceflow/common
Version:
Junk drawer of utility functions
32 lines (31 loc) • 703 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hex2abc = void 0;
const mapping = {
a: 'a',
b: 'b',
c: 'c',
d: 'd',
e: 'e',
f: 'f',
0: 'g',
1: 'h',
2: 'i',
3: 'j',
4: 'k',
5: 'l',
6: 'm',
7: 'n',
8: 'o',
9: 'p',
// Just in case someone passes a string like 0xabc
x: 'x',
};
/**
* Turns a hexadecimal string into lowercase alphabetical characters.
*
* @param hex - The hexadecimal string to convert
* @returns A string of lowercase alphabetical characters
*/
const hex2abc = (hex) => Array.prototype.map.call(hex.toLowerCase(), (char) => mapping[char]).join('');
exports.hex2abc = hex2abc;