forked from willwhite/freemail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (20 loc) · 821 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var fs = require('fs');
var tldjs = require('tldjs');
var disposable = fs.readFileSync(__dirname + '/data/disposable.txt').toString().split('\n');
var free = fs.readFileSync(__dirname + '/data/free.txt').toString().split('\n').concat(disposable);
function isFree(email) {
if (typeof email !== 'string') throw new TypeError('email must be a string');
console.log(email);
var domain = tldjs.getDomain(email.split('@').pop());
console.log(domain, free.indexOf(domain));
return free.indexOf(domain) !== -1;
}
function isDisposable(email) {
if (typeof email !== 'string') throw new TypeError('email must be a string');
var domain = tldjs.getDomain(email.split('@').pop());
return disposable.indexOf(domain) !== -1;
}
module.exports = {
isFree: isFree,
isDisposible: isDisposable
};