Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/doodle-node-cli / src / utils / strings.js
Size: Mime:
/**
 * 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,
};