node package manager

email-js

email-js

Build Status npm version Coverage Status Inline docs

Installation

npm install --save email-js

Usage

EmailAddress('<email>')

Example

const EmailAddress = require('email-js');
 
console.log(EmailAddress('ruby@fog.im')); // => EmailAddress(ruby@fog.im) 
EmailAddress('a') // => TypeError 

API

.isValid(email: string) => boolean

Returns true if the email is valid. The email address is validated on construction by Webkit's regex.

console.log(EmailAddress.isValid('root@localhost')) // => true 

#getDomain() => string

Returns the domain part of the email.

console.log(EmailAddress('root@localhost').getDomain()) // => 'localhost' 

#getLocal() => string

Returns the local part of the email.

console.log(EmailAddress('root@localhost').getLocal()) // => 'root' 

#toString() => string

Converts the email address back to a string.

console.log(EmailAddress('root@localhost').toString()) // => 'root@localhost' 

#length => number

Returns the email's length.

console.log(EmailAddress('root@localhost').length) // => 14