util.wxs 483 B

123456789101112131415161718192021
  1. function desensitization(string="", start, end) {
  2. var star = ''
  3. function makeStar(number) {
  4. if (number > 0) {
  5. star += '*';
  6. return makeStar(--number)
  7. } else {
  8. return star
  9. }
  10. };
  11. return string.substring(0, start) + makeStar(end - start) + string.substring(end)
  12. }
  13. function indexOf(array, value) {
  14. return array.indexOf(value)
  15. }
  16. module.exports = {
  17. desensitization: desensitization,
  18. indexOf:indexOf,
  19. }