node package manager

email-js

email-js

Build Status npm version Coverage Status Inline docs

Version 1.x can be found here: https://github.com/bash/email-js/tree/v1.4.0
npm install --save email-js@1

Installation

npm install --save email-js

Usage

const { isValidEmail, getDomainPart, getLocalPart } = require('email-js');
 
console.log(isValidEmail('robot@example.com')); // => true 
console.log(getDomainPart('robot@example.com')); // => example.com 
console.log(getLocalPart('robot@example.com')); // => robot 

API

isValidEmail(email: string) => boolean

Returns true if the email is valid. The address is validated on by the same regex used by Webkit.

isValidEmail('root@localhost') // => true 

getDomainPart(email: string) => string

Returns the domain part of the email.

getDomainPart('root@localhost') // => 'localhost' 

getLocalPart(email: string) => string

Returns the local part of the email.

getLocalPart('root@localhost') // => 'root'