https://github.com/bash/email-js
A collection of helpers for email addresses
https://github.com/bash/email-js
Last synced: 5 months ago
JSON representation
A collection of helpers for email addresses
- Host: GitHub
- URL: https://github.com/bash/email-js
- Owner: bash
- License: mit
- Created: 2015-10-19T21:09:37.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-04-14T18:56:09.000Z (almost 2 years ago)
- Last Synced: 2025-08-05T04:52:45.335Z (7 months ago)
- Language: JavaScript
- Homepage: https://npmjs.com/package/email-js
- Size: 124 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# email-js
[](https://badge.fury.io/js/email-js)
[](https://coveralls.io/github/bash/email-js?branch=master)
[](http://inch-ci.org/github/bash/email-js)
## Installation
```bash
npm install --save email-js
```
## Usage
```javascript
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.
```js
isValidEmail('root@localhost') // => true
```
### getDomainPart(email: ```string```) =\> ```string```
Returns the domain part of the email.
```js
getDomainPart('root@localhost') // => 'localhost'
```
### getLocalPart(email: ```string```) =\> ```string```
Returns the local part of the email.
```js
getLocalPart('root@localhost') // => 'root'
```