function desensitization(string="", start, end) { var star = '' var length = string.length function makeStar(number) { if (number > 0) { star += '*'; return makeStar(--number) } else { return star } }; if(length < end) { return string.substring(0, 1) + makeStar(length-2>0?length-2:0) + (length>2?string.substring(length-1):"") } return string.substring(0, start) + makeStar(end - start) + string.substring(end) } function indexOf(array, value) { return array.indexOf(value) } module.exports = { desensitization: desensitization, indexOf:indexOf, }