Gathering detailed insights and metrics for email-typo-fixer
Gathering detailed insights and metrics for email-typo-fixer
Gathering detailed insights and metrics for email-typo-fixer
Gathering detailed insights and metrics for email-typo-fixer
npm install email-typo-fixer
Typescript
Module System
Node Version
NPM Version
59
Supply Chain
97.8
Quality
83.7
Maintenance
100
Vulnerability
99.6
License
TypeScript (100%)
Total Downloads
612
Last Day
12
Last Week
83
Last Month
612
Last Year
612
8 Stars
15 Commits
3 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.1.0
Package Id
email-typo-fixer@1.1.0
Unpacked Size
41.09 kB
Size
8.19 kB
File Count
9
NPM Version
10.8.2
Node Version
18.20.5
Publised On
22 Nov 2024
Cumulative downloads
Total Downloads
Last day
100%
12
Compared to previous day
Last week
6.4%
83
Compared to previous week
Last month
0%
612
Compared to previous month
Last year
0%
612
Compared to previous year
1
3
A TypeScript library that fixes common email typos and formatting issues. It handles various advanced scenarios like Outlook-style emails, special characters, multiple @ symbols, and more.
1npm install email-typo-fixer 2# or 3yarn add email-typo-fixer 4# or 5pnpm add email-typo-fixer 6# or 7bun add email-typo-fixer
1import { emailTypoFixer, DEFAULT_DOMAINS } from 'email-typo-fixer'; 2 3// Basic usage (using default domains) 4const result = emailTypoFixer('user@gmial.com'); 5console.log(result); 6// Output: 7// { 8// original: 'user@gmial.com', 9// suggested: 'user@gmail.com', 10// hasCorrection: true 11// } 12 13// Outlook-style email 14const result2 = emailTypoFixer('John Doe <john.doe@@gmail.com>'); 15console.log(result2.suggested); // 'john.doe@gmail.com' 16 17// With custom domains (overriding defaults) 18const result3 = emailTypoFixer('user@company.internal', { 19 domains: ['company.internal', 'corp.example.com'] 20}); 21console.log(result3.suggested); // 'user@company.internal' 22 23// Combining default domains with custom domains 24const result4 = emailTypoFixer('user@comapny.com', { 25 domains: [...DEFAULT_DOMAINS, 'company.com'] 26}); 27console.log(result4.suggested); // 'user@comapny.com'
emailTypoFixer(email: string, opts?: EmailTypoFixerOptions): EmailTypoFixerResult
email
: The email address to fixopts
(optional): Configuration options
domains
: Array of valid domains to use for corrections. Defaults to:
1[ 2 "gmail.com", 3 "yahoo.com", 4 "hotmail.com", 5 "outlook.com", 6 "icloud.com", 7 "aol.com" 8]
domainMatchDistance
: Maximum allowed distance for domain corrections (default: 3). Lower values are more strict:
1// More strict (only minor typos) 2emailTypoFixer('user@outl00k.com', { domainMatchDistance: 2 }); // No correction 3 4// Default behavior 5emailTypoFixer('user@outl00k.com', { domainMatchDistance: 3 }); // Suggests: user@outlook.com 6 7// More lenient 8emailTypoFixer('user@gmaillll.com', { domainMatchDistance: 5 }); // Suggests: user@gmail.com
1interface EmailTypoFixerResult { 2 original: string; // Original input 3 suggested: string | undefined; // Corrected email (if changes were made) 4 hasCorrection: boolean; // Whether any corrections were made 5}
Here are some common fixes the library handles:
"John Doe <john.doe@example.com>"
→ "john.doe@example.com"
"user@@gmail.com"
→ "user@gmail.com"
"user.name+tag@domain.com$"
→ "user.name+tag@domain.com"
"user@gmial.com"
→ "user@gmail.com"
"John Smith <test,user@@gmial..com>"
→ "test.user@gmail.com"
For a comprehensive list of examples and edge cases, check out our test file
This project builds upon ideas from:
MIT
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
No vulnerabilities found.
No security vulnerabilities found.