function hideSensitiveInfo(prefixLength, suffixLength, optionalInfix, info) {
if (!info) {
return '';
}
const prefix = info.slice(0, prefixLength);
const suffix = info.length - prefixLength - suffixLength > 0 ?
info.slice(-suffixLength) : '';
const infixLength = info.length - prefixLength - suffixLength < 2 ?
2 :
info.length - prefixLength - suffixLength + 1;
const infix = optionalInfix === null ?
Array(infixLength).join('*') :
optionalInfix;
return prefix + infix + suffix;
}
hideSensitiveInfo('崔宇浩'', 1, 1, '*')
console