@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
15 lines (14 loc) • 499 B
TypeScript
/**
* Masks an email address for privacy by replacing part of the email with asterisks.
*
* The function preserves the first character, the domain, and the `@` symbol,
* while masking the rest of the email's username.
*
* @param email - The email address to mask.
* @returns The masked email address.
*
* @example
* maskEmail('test@example.com'); // "t***@example.com"
* maskEmail('johndoe@gmail.com'); // "j******@gmail.com"
*/
export default function maskEmail(email: string): string;