normail
v0.2.1
Published
Normalize emails
Readme
normail
Light library that tries to normalize emails
Usage
As a sipmple function
import { mormalize } from 'normail';
const normalized = await normalize('[email protected]')
// Output
// NormalizedEmail {
// original: '[email protected]',
// normalized: '[email protected]',
// provider: 'google.com',
// error: undefined
// }Or you can create a new function that will cache the results
import { createNormalizer } from 'normail';
// create the normalizer only once
const normalize = createNormalizer({
ttl: 300, // cache the results for 300 seconds
max: 100 // max entries to keep on cache
})
// used it more times
const normalized = await normalize('[email protected]')
// Output as beforeDifferent providers have different rules, for what this library supports you can check the provider rules
Credits
The rules were copied from https://github.com/gmr/email-normalize
