UNPKG

maskdata

Version:

Node module to mask various kinds of data in the required formats

48 lines (35 loc) 1.5 kB
## Mask Email id Use this method instead of maskEmail(). To mask with the default options, don't pass the configurations. ```javascript const MaskData = require('./maskdata'); const emailMask2Options = { maskWith: "*", unmaskedStartCharactersBeforeAt: 3, unmaskedEndCharactersAfterAt: 2, maskAtTheRate: false }; const email = "my.test.email@testEmail.com"; const maskedEmail = MaskData.maskEmail2(email, emailMask2Options); //Output: my.********@**********om ``` ### Consider an email: abcd@email.com Here, - number of characters before @ -> 4 - number of characters after @ --> 9 1. **unmaskedStartCharactersBeforeAt** --> number of starting characters (before @)not to be masked. * If unmaskedStartCharactersBeforeAt > number of characters before @, then it will not mask the characters before @ 2. **unmaskedEndCharactersAfterAt** --> number of characters not to be masked starting from the end till @. * If unmaskedEndCharactersAfterAt > number of characters after @, then it will not mask the characters after @ ### Mask only the characters before '@' ```javascript const MaskData = require('./maskdata'); const emailMask2Options = { maskWith: "*", unmaskedStartCharactersBeforeAt: 0, unmaskedEndCharactersAfterAt: 257, // Give a number which is more than the characters after @ maskAtTheRate: false }; const email = "abcd@email.com"; const maskedEmail = MaskData.maskEmail2(email, emailMask2Options); //Output: ****@email.com ```