Check if an email is from a disposable domain, pretty self-explanatory.
Explicit memory usage, no global constants!
This library to not uses global constants, memory is allocated only when you invoke the function.
pnpm i @fixers/disposable-email
npm install @fixers/disposable-email
Note: each time you invoke this function, a new
Set
containing all the disposable domains is created.
To check if an email is from a disposable domain:
import { isDisposable } from '@fixers/disposable-email'
// check an email
if (isDisposable('[email protected]')) {
//
}
// check a domain
if (isDisposable('disposable-domain.com')) {
//
}
If you need to check a large volume of emails, you might want to allocate memory only once, create a factory function:
import { createDisposableFactory } from '@fixers/disposable-email'
// hold a reference to a Set
const isDisposable = createDisposableFactory()
// no memory allocation
isDisposable('[email protected]')
// no memory allocation
isDisposable('[email protected]')