Created
August 23, 2024 12:27
-
-
Save petja/3ff1f26569ee2018370015daf758429e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maskLine(text: string) { | |
const len = text.length; | |
const first = text.substring(0, 1); | |
const first2 = text.substring(0, 2); | |
const last = text.substring(len - 1); | |
if (len < 2) return text; | |
if (len === 2) return first + '•'; | |
if (len === 3) return first + '••'; | |
return first2 + '•'.repeat(len - 3) + last; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment