npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mistyep

v1.0.8

Published

Catch when tricky or non-standard words are mistyped.

Downloads

43

Readme

Mistyep

Catch when tricky or non-standard words are ~mistyepd~ mistyped.

Live demo

Installation

npm install mistyep --save

Usage

var mistyep = require('mistyep');

Then...

For emails

var emailInput = '[email protected]';  // get your user's email input from e.g. a form

var correctedEmail = mistyep.email(emailInput);  // returns the original emailInput if no correction is found.

if (emailInput !== correctedEmail) {
  // suggest the alternative spelling to the user.
}

If you want to include custom email domains or TLDs, see the code example in the "Email Defaults" section below.

For custom words

mistyep is flexible enough to handle an arbitrary list of specialty words. Perhaps your users are only allowed to write in Elvish, or there is app-level jargon that needs to be spelled right. You can check against your own word list with the custom method:

// "standup" is the word you're checking, the following string array is your customized word bank.
mistyep.custom('standup', ['ux', 'stand-up', 'bae', 'tbh']);

Email Defaults

The default email values that mistyep checks against are the following:

Domains: gmail | yahoo | aol | outlook | att | msn | mchsi | comcast | live | mail | ymail | googlemail | hotmail

Common TLDs: com | org | net | info | edu | gov | int | mil | biz | mobi | asia

Common country code TLDs: ad | as | br | bz | ca | cc | cd | co | co.uk | cn | de | dj | eu | fm | fr | in | io | jp | la | ly | me | ms | nu | ru | sc | sr | su | tk | to | tv | us | ws

Obviously, this is not a complete list. I tried to pick many of the most common values, but you may have a different use-case, serve in a specific country, or serve to users with internal email addresses. In that case, you can supply custom domains or TLDs with the following optional parameters:

mistyep.email(
  emailInput, 
  { 
    customDomains: ['example', 'mycompany'], 
    customTLDs: ['ninja', 'chat', 'news', 'to', 'bz']
  });

Make sure you pass string arrays into customDomains and customTLDs if you choose to include them.

If I missed something glaring in the default lists, feel free to add it in a PR.

In the wild

You can see mistyep in action on the Penmob login page (watch a suggestion pop up if you type in an invalid email):

penmob.com/login

Example GIF

Let me know (via email or a PR on GitHub) if you use mistyep in your own app, and I'll add it to this page.

Testing

npm test

Motivation

There is no sure-fire way to auto-verify that an email address exists, but there are a few things we can do to mitigate simple errors. When a user signs up for a new service with their email address, there is a nonzero chance that they'll mistype it, thus making a confirmation or further communication with them impossible.

This package uses most of the common email providers' domain names to offset the chance that someone will accidentally type, for example, gnail instead of gmail. It's best to offer the suggestion returned by mistyep rather than to automatically change their input.

How it works

mistyep uses a modified version of Levenshtein distance (or "edit distance") to correct a misspelled word, which I call the "physical edit distance". The theory being, it's much more likely that a user will miss with their finger by a key or two, and the physical distance between keys on the keyboard should influence which word is selected as a replacement.

This is an imperfect solution, but if used as a heuristic, it catches most accidental mistypings.

Caveats

The initial version was meant to be used as an email checker only, so the custom method has a lot of room for improvement. It does not handle capitalized letters, or any special characters with accents or umlauts. This version also only handles misspellings committed on a standard QWERTY computer.