Skip to content

dsundeep/email-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@js-genie/email-parser

A javascript utility package to parse email addresses

Installation

npm i --save @js-genie/email-parser

Email Parser

  • isValid() function is used to check if the input is a valid email address or not.
const { isValid } = require('@js-genie/email-parser');

isValid('[email protected]'); // returns true
isValid('[email protected]'); // returns true
isValid('{key : [email protected]}'); // returns false
isValid('[email protected]'); // returns false
  • getUsername() function is used to get the username part of the input email address.
const { getUsername } = require('@js-genie/email-parser');

getUsername("{}teststring"); // returns ''
getUsername({key: '[email protected]'}); // returns ''
getUsername("[email protected]"); // returns 'testemail'
  • getDomain() function is used to get the domain part of the input email address.
const { getDomain } = require('@js-genie/email-parser');

getDomain("{}teststring"); // returns ''
getDomain({key: '[email protected]'}); // returns ''
getDomain("[email protected]"); // returns 'test.com'

Note: If the typeof input email address is not string or the input email is not valid, an empty value is returned.

About

A common javascript utility package to parse different types

Resources

License

Stars

Watchers

Forks

Packages

No packages published