Repository URL to install this package:
|
Version:
0.0.0-faef1d756148d5 ▾
|
/**
* Hide the last part of a string by masking it with ******
* @param {String} stringToObfuscate
* @param {Number} charsToReveal - The number of characters to not hide
* @returns {String}
*/
function obfuscateString(stringToObfuscate, charsToReveal = 2) {
if (typeof stringToObfuscate !== 'string') {
throw new TypeError(`obfuscateString expects a string, got ${typeof stringToObfuscate}`);
}
return `${stringToObfuscate.substr(0, charsToReveal)}**********`;
}
function titleCase(str) {
return str.toLowerCase().replace(/\b(\w)/g, s => s.toUpperCase());
}
module.exports = {
titleCase,
obfuscateString,
};