Giter Site home page Giter Site logo

julien-amblard / email-misspelled Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 6.0 1.27 MB

Check misspell email's domain and return a list of matching domain suggestions

Home Page: https://codepen.io/Capse/pen/LYGVRoP

License: MIT License

JavaScript 0.29% TypeScript 99.42% Shell 0.29%
email misspelled

email-misspelled's Introduction

email-misspelled

npm CircleCI Status codecov npm npm npm

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

example

Table of Contents

  1. Install
  2. Usages
  3. Options

Install

Install with npm:

    npm i email-misspelled

Install with yarn:

    yarn add email-misspelled

Usages

import emailMisspelled, { top100 } from "email-misspelled"

const emailChecker = emailMisspelled({ domains: top100 })

emailChecker("[email protected]")
/**
 * [{ 
 *      suggest: "hotmail.com", 
 *      misspelledCount: 1, 
 *      corrected:"[email protected]", 
 *      original: "[email protected]"
 * }]
 **/

Options

domains

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:"[email protected]", 
 *      original: "[email protected]"
 *   }
 * ]
 **/

List of domains avaibles :

More details here

examples

import { top100, hotmail, live } from "email-misspelled"  

Feel free to contribute


maxMisspelled

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:"[email protected]",  
 *      original: "[email protected]"
 * }]
 **/
emailChecker1("[email protected]") // []

const emailChecker2 = emailMisspelled({ maxMisspelled: 3, domains: top100 })

emailChecker2("[email protected]")
/**
 * return :
 * [{  
 *      suggest: "hotmail.com",  
 *      misspelledCount: 2,  
 *      corrected:"[email protected]",  
 *      original: "[email protected]"  
 * }]
 **/
emailChecker2("[email protected]")
/**
 * return :
 * [{  
 *      suggest: "hotmail.com",  
 *      misspelledCount: 3,  
 *      corrected:"[email protected]",  
 *      original: "[email protected]"  
 * }]
 **/
emailChecker2("[email protected]") //4 misspelled, return []

lengthDiffMax

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:"[email protected]",
 *      original: "[email protected]"
 * }]
 **/
emailChecker1("[email protected]") // []

const emailChecker2 = emailMisspelled({ lengthDiffMax: 2, domains: top100 })

emailChecker2("[email protected]")
/**
 * return :
 * [{ 
 *      suggest: "hotmail.com",
 *      misspelledCount: 1,
 *      corrected:"[email protected]",
 *      original: "[email protected]"
 * }]
 **/
emailChecker2("[email protected]")
/**
 * return :
 * [{
 *      suggest: "gmail.com",
 *      misspelledCount: 1,
 *      corrected:"[email protected]",
 *      original: "[email protected]"
 * },
 * {
 *      suggest: "hotmail.com",
 *      misspelledCount: 2,
 *      corrected:"[email protected]",
 *      original: "[email protected]"
 * }]
 **/

Top 100 domains list

ordered by number of existing email

  • gmail.com
  • yahoo.com
  • hotmail.com
  • aol.com
  • hotmail.co.uk
  • hotmail.fr
  • msn.com
  • yahoo.fr
  • wanadoo.fr
  • orange.fr
  • comcast.net
  • yahoo.co.uk
  • yahoo.com.br
  • yahoo.co.in
  • live.com
  • rediffmail.com
  • free.fr
  • gmx.de
  • web.de
  • yandex.ru
  • ymail.com
  • libero.it
  • outlook.com
  • uol.com.br
  • bol.com.br
  • mail.ru
  • cox.net
  • hotmail.it
  • sbcglobal.net
  • sfr.fr
  • live.fr
  • verizon.net
  • live.co.uk
  • googlemail.com
  • yahoo.es
  • ig.com.br
  • live.nl
  • bigpond.com
  • terra.com.br
  • yahoo.it
  • neuf.fr
  • yahoo.de
  • alice.it
  • rocketmail.com
  • att.net
  • laposte.net
  • facebook.com
  • bellsouth.net
  • yahoo.in
  • hotmail.es
  • charter.net
  • yahoo.ca
  • yahoo.com.au
  • rambler.ru
  • hotmail.de
  • tiscali.it
  • shaw.ca
  • yahoo.co.jp
  • sky.com
  • earthlink.net
  • optonline.net
  • freenet.de
  • t-online.de
  • aliceadsl.fr
  • virgilio.it
  • home.nl
  • qq.com
  • telenet.be
  • me.com
  • yahoo.com.ar
  • tiscali.co.uk
  • yahoo.com.mx
  • voila.fr
  • gmx.net
  • mail.com
  • planet.nl
  • tin.it
  • live.it
  • ntlworld.com
  • arcor.de
  • yahoo.co.id
  • frontiernet.net
  • hetnet.nl
  • live.com.au
  • yahoo.com.sg
  • zonnet.nl
  • club-internet.fr
  • juno.com
  • optusnet.com.au
  • blueyonder.co.uk
  • bluewin.ch
  • skynet.be
  • sympatico.ca
  • windstream.net
  • mac.com
  • centurytel.net
  • chello.nl
  • live.ca
  • aim.com
  • bigpond.net.au

email-misspelled's People

Contributors

dependabot[bot] avatar johnfraney avatar julien-amblard avatar limonte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

email-misspelled's Issues

type keyword in lib/index.d.ts file causes build error

When I try to compile an angular library with typescript 3.4.5, I get the error

An unhandled exception occurred: node_modules/email-misspelled/lib/index.d.ts(3,1): error TS1128: Declaration or statement expected.
node_modules/email-misspelled/lib/index.d.ts(3,13): error TS1005: ';' expected.
node_modules/email-misspelled/lib/index.d.ts(3,109): error TS1005: ';' expected.

It happens due to type keyword
https://github.com/sl-julienamblard/email-misspelled/blob/7e8e62fe67c39fc68deed5e9f726aa6755c97867/src/index.ts#L3

I'm not that good in TypeScript, but when I do remove the keyword it works fine.

Does it really do something there? :)

Freshness of email domain list

The top100 list for example hasn't been updated since July 2020. Was the underlying data fresh at that point? Is there a source you used previously that I can pull from to create a PR to update?

How to import CJS version in Typescript?

Describe the bug
I have a Typescript project and trying to upgrade this module. Problem is my project is CJS and I can't convert to ESM yet. When I try to import this package it fails even though I see the folder /dist/cjs there. Is there any specific way how to import it in Typescript?

error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("email-misspelled")' call instead.
  To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`.

To Reproduce

  1. run npm install email-misspelled
  2. run tsc --noEmit on CJS file with this import import emailMisspelled, {all} from 'email-misspelled';
// tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022", // Specify ECMAScript target version, see https://node.green/#ES2023
    "module": "NodeNext", // https://www.typescriptlang.org/tsconfig#module
    "outDir": "./build", // Redirect output structure to the directory.
    "rootDir": "./src", // Specify the root directory of input files. Use to control the output directory structure with --outDir.
    "noImplicitAny": false, // Raise error on expressions and declarations with an implied 'any' type.
    "skipLibCheck": true, // Skip type checking of declaration files.
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true, // Disallow inconsistently-cased references to the same file.
    "noEmitHelpers": true, // https://docs.sentry.io/platforms/node/guides/express/typescript/#dealing-with-tslib
    "importHelpers": true,
    "alwaysStrict": true,
    "strict": true,
  },
  "include": ["src"],
}

Desktop (please complete the following information):

  • MacOS + Node.js 22.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.