@js-genie/email-parser
v1.0.0
Published
A javascript utility package to parse email addresses
Downloads
83
Readme
@js-genie/email-parser
A javascript utility package to parse email addresses
Installation
npm i --save @js-genie/email-parser
Email Parser
const { isValid, getUsername, getDomain } = require('@js-genie/email-parser');
isValidEmail = isValid('[email protected]'); // returns true
isValidEmail = isValid('[email protected]'); // returns true
isValidEmail = isValid('{key : [email protected]}'); // returns false
isValidEmail = isValid('[email protected]'); // returns false
username = getUsername("{}teststring"); // returns ''
username = getUsername({key: '[email protected]'}); // returns ''
username = getUsername("[email protected]"); // returns 'testemail'
domain = getDomain("{}teststring"); // returns ''
domain = getDomain({key: '[email protected]'}); // returns ''
domain = getDomain("[email protected]"); // returns 'test.com'
isValid()
function is used to check if the input is a valid email address or not.getUsername()
function is used to get the username part of the input email address.getDomain()
function is used to get the domain part of the input email address.- If the
typeof
input email address is not string or the input email is not valid, an empty value is returned.