npm install -save email-butler
Suggest email if domain closly matches popular email domains. If no suggestion, returns undefined. Otherwise returns { address, domain, full }, where address is everything before @, domain is everything after, and full is the full suggestion. Method accepts an email and an option object, which overrides the default values to compare the email to. The different options are:
- domains: string[], matches email to this list of emails (gmail.com)
- topLevelDomains: string[], matches top level domains to this list of top level domains (com)
- secondLevelDomains: string[], matches domains to this list of domains (gmail)
import { suggest } from "email-butler";
const suggestion = suggest("[email protected]");
console.log(suggestion.full); // [email protected]
const mySuggest = (email: string) => suggest(email, { domains: ["facebook.com"] });
const suggestionOne = mySuggest("[email protected]");
console.log(suggestionOne.full); // undefined
const suggestionTwo = mySuggest("[email protected]");
console.log(suggestionTwo.full); // facebook.com
import { validate } from "email-butler";
let isValid = validate("[email protected]");
console.log(isValid); // true
isValid = validate("test$gnail.com");
console.log(isValid); // false