UNPKG

free-email-domains-list

Version:

Fresh list of all free email domain providers. Can be used to check if an email address belongs to a company. Updated weekly.

34 lines (33 loc) 1.33 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DOMAINS = exports.isCompanyEmail = exports.isFreeEmail = void 0; const constants_1 = require("./constants"); Object.defineProperty(exports, "DOMAINS", { enumerable: true, get: function () { return constants_1.DOMAINS; } }); const isEmail_1 = __importDefault(require("validator/lib/isEmail")); const isEmailValid = (email, emailValidation = {}) => { if (typeof email !== 'string') { return false; } return (0, isEmail_1.default)(email, emailValidation); }; const isFreeEmail = (email, emailValidation = {}) => { var _a; if (!isEmailValid(email, emailValidation)) { return false; } const domain = (_a = email.split('@')[1]) !== null && _a !== void 0 ? _a : ''; return constants_1.DOMAINS.has(domain); }; exports.isFreeEmail = isFreeEmail; const isCompanyEmail = (email, emailValidation = {}) => { var _a; if (!isEmailValid(email, emailValidation)) { return false; } const domain = (_a = email.split('@')[1]) !== null && _a !== void 0 ? _a : ''; return !constants_1.DOMAINS.has(domain); }; exports.isCompanyEmail = isCompanyEmail;