Skip to content

Documentation / @andrew_l/toolkit / maskingEmail

Function: maskingEmail() ​

maskingEmail(value): string

Masks part of the email address to provide a simple level of privacy. The username part is partially masked with asterisks, while the domain remains intact.

⚠️ Returns an empty string if the provided value is invalid.

Parameters ​

value ​

string

The email address to be masked.

Returns ​

string

The masked email address or an empty string if the value is invalid.

Example ​

ts
maskingEmail('andrew@gmail.com'); // 'a****w@gmail.com'
maskingEmail('user@domain.com'); // 'u***r@domain.com'
maskingEmail('invalidemail'); // ''

Released under the MIT License.