commonUtil.js
429 Bytes
// 把文字中间4个字符换成“*”号
export const replaceTextToStar = (params = '') => {
let value = String(params)
if (!value || !value.length || value.length <= 0) return '';
let len = value.length;
let medianNumber = Math.floor(len / 2);
console.log(medianNumber)
return `${value.substr(0, medianNumber-2)}****${value.substr(medianNumber + 2, value.length)}`;
}
module.exports = {
replaceTextToStar,
}