Skip to content

wefixers/disposable-email

Repository files navigation

Disposable Email

npm version npm downloads License

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.

Install

pnpm i @fixers/disposable-email
npm install @fixers/disposable-email

Usage

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')) {
  //
}

Bulk Validation

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]')