Lightweight < 3ko lib
Check the misspelled email's domain and return a list of matching domain suggestions sorted by corrections needed
The string comparison is based on this algorithm
Install with npm:
npm i email-misspelled --saveInstall with yarn:
yarn add email-misspelledimport emailMisspelled, { top100 } from "email-misspelled"
const emailChecker = emailMisspelled({ domains: top100 })
emailChecker("[email protected]")
/**
* [{
* suggest: "hotmail.com",
* misspelledCount: 1,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/Returned object model
Result
Result = {
/** suggested domain */
suggest: string
/** corrected email */
corrected: string
/** number correction needed */
misspelledCount: number
/** original email */
original: string
}[]| Type | Required | Description |
|---|---|---|
string[] DomainList |
true | list of domains to compare |
import emailMisspelled from "email-misspelled"
const emailChecker = emailMisspelled({ domains: ["random.org"] })
emailChecker("[email protected]") // []
emailChecker("[email protected]")
/**
* return :
* [{
* suggest: "random.org",
* misspelledCount: 1,
* corrected:"user@random.org",
* original: "[email protected]"
* }]
**/List of domains avaibles :
- Top 100 domains list
- Hotmail
- Live
- Outlook
- Microsoft (a combination of hotmail, live and outlook emails)
- Yahoo
- Aol
- Others domains
- All (all previous domains in one list)
examples
import { top100, hotmail, live } from "email-misspelled" or
import { top100, hotmail, live } from "email-misspelled/domains"
//etc or
import top100 from "email-misspelled/domains/popular"
import hotmail from "email-misspelled/domains/hotmail"
import live from "email-misspelled/domains/live"
//etc Feel free to contribute
| Type | Required | Default | Description |
|---|---|---|---|
number |
false | 2 |
max possible misspelled |
import emailMisspelled, { top100 } from "email-misspelled"
const emailChecker1 = emailMisspelled({ maxMisspelled: 1, domains: top100 })
emailChecker1("[email protected]")
/**
* return :
* [{
* suggest: "hotmail.com",
* misspelledCount: 1,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/
emailChecker1("[email protected]") // []
const emailChecker2 = emailMisspelled({ maxMisspelled: 3, domains: top100 })
emailChecker2("[email protected]")
/**
* return :
* [{
* suggest: "hotmail.com",
* misspelledCount: 2,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/
emailChecker2("[email protected]")
/**
* return :
* [{
* suggest: "hotmail.com",
* misspelledCount: 3,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/
emailChecker2("[email protected]") //4 misspelled, return []| Type | Required | Default | Description |
|---|---|---|---|
number |
false | 3 |
max length difference between two string |
import emailMisspelled, { top100 } from "email-misspelled"
const emailChecker1 = emailMisspelled({ lengthDiffMax: 1, domains: top100 })
emailChecker1("[email protected]")
/**
* return :
* [{
* suggest: "hotmail.com",
* misspelledCount: 1,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/
emailChecker1("[email protected]") // []
const emailChecker2 = emailMisspelled({ lengthDiffMax: 2, domains: top100 })
emailChecker2("[email protected]")
/**
* return :
* [{
* suggest: "hotmail.com",
* misspelledCount: 1,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/
emailChecker2("[email protected]")
/**
* return :
* [{
* suggest: "gmail.com",
* misspelledCount: 1,
* corrected:"user@gmail.com",
* original: "[email protected]"
* },
* {
* suggest: "hotmail.com",
* misspelledCount: 2,
* corrected:"user@hotmail.com",
* original: "[email protected]"
* }]
**/You can find Types and Interfaces under the /typings folder
DomainList
import { DomainList } from "email-misspelled/typings"
string[]EmailMisspelledConstructor
import { EmailMisspelledConstructor } from "email-misspelled/typings"
(config: {
lengthDiffMax?: number;
maxMisspelled?: number;
domains: DomainList;
}): EmailMisspelled;EmailMisspelled
import { EmailMisspelled } from "email-misspelled/typings"
(email: string): Result[]Result
import { Result } from "email-misspelled/typings"
{
suggest: string;
corrected: string;
misspelledCount: number;
original: string;
}ordered by number of existing email
gmail.comyahoo.comhotmail.comaol.comhotmail.co.ukhotmail.frmsn.comyahoo.frwanadoo.frorange.frcomcast.netyahoo.co.ukyahoo.com.bryahoo.co.inlive.comrediffmail.comfree.frgmx.deweb.deyandex.ruymail.comlibero.itoutlook.comuol.com.brbol.com.brmail.rucox.nethotmail.itsbcglobal.netsfr.frlive.frverizon.netlive.co.ukgooglemail.comyahoo.esig.com.brlive.nlbigpond.comterra.com.bryahoo.itneuf.fryahoo.dealice.itrocketmail.comatt.netlaposte.netfacebook.combellsouth.netyahoo.inhotmail.escharter.netyahoo.cayahoo.com.aurambler.ruhotmail.detiscali.itshaw.cayahoo.co.jpsky.comearthlink.netoptonline.netfreenet.det-online.dealiceadsl.frvirgilio.ithome.nlqq.comtelenet.beme.comyahoo.com.artiscali.co.ukyahoo.com.mxvoila.frgmx.netmail.complanet.nltin.itlive.itntlworld.comarcor.deyahoo.co.idfrontiernet.nethetnet.nllive.com.auyahoo.com.sgzonnet.nlclub-internet.frjuno.comoptusnet.com.aublueyonder.co.ukbluewin.chskynet.besympatico.cawindstream.netmac.comcenturytel.netchello.nllive.caaim.combigpond.net.au
- external domain list
- split domain list into smallest part (only hotmail, only gmail etc)
- Doc
- TU
- TS
- Extend default domain list
- explicit folder for types exports
- update demo
- allow returning only first result
