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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mail-safe

v1.1.0

Published

Validate, normalise & detect disposable email addresses

Downloads

284

Readme

mail-safe

Validate, normalise & detect disposable email addresses

Small Node library that caches and checks disposable email domains from the upstream blocklist (https://github.com/eramitgupta/disposable-email).

Installation

npm install mail-safe

Quick start

Importing and checking an email (async — will fetch & cache if needed):

import { isDisposableEmail } from 'mail-safe';

const isDisposable = await isDisposableEmail('[email protected]');
console.log(isDisposable); // true

Synchronous check against an in-memory set (fast, no IO):

import { isDisposableEmailSync } from 'mail-safe';

const domains = new Set(['mailinator.com']);
console.log(isDisposableEmailSync('[email protected]', domains)); // true

API

Constants

  • DEFAULT_SOURCE_URL — default upstream JSON list URL.
  • DEFAULT_CACHE_FILE — default cache location on disk.
  • DEFAULT_MAX_AGE_MS — default cache staleness window (24 hours).

Async helpers (cached)

loadDisposableEmailState(options?)

  • Loads the cached snapshot or fetches a fresh one when stale.
  • Returns { fetchedAt, sourceUrl, cacheFile, domains }.
  • Falls back to the cached snapshot if refresh fails.

refreshDisposableEmailState(options?)

  • Forces a refresh from the upstream list and overwrites the cache.
  • Returns { fetchedAt, sourceUrl, cacheFile, domains }.

checkDisposableEmail(email, options?)

  • Returns a detailed result: { email, domain, matchedDomain, isDisposable, sourceUrl, cacheFile, fetchedAt }.

isDisposableEmail(email, options?)

  • Convenience boolean wrapper around checkDisposableEmail.

Sync helpers (no IO)

isDisposableEmailSync(email, domains)

  • Fast sync check when you already have a Set of domains.

isDisposableDomain(domain, domains)

  • Checks if a domain (including subdomains) matches a disposable entry.

extractEmailDomain(email)

  • Normalizes and returns the domain portion of an email, or null if invalid.

Options

All async helpers accept DisposableEmailOptions:

  • sourceUrl?: string — override the upstream list URL.
  • cacheFile?: string — override the cache file path.
  • maxAgeMs?: number — max cache age before refresh (ms).
  • forceRefresh?: boolean — bypass cache even if fresh.
  • signal?: AbortSignal — cancel network requests.

Cache behavior

  • The first async call downloads the list and caches it on disk.
  • Subsequent calls reuse the cache until it is stale (default 24h).
  • If refresh fails, the last cached snapshot is used instead.

TypeScript

  • All public functions and types are fully typed.
  • JSDoc comments surface in IntelliSense for parameters and return values.

Testing

Run the test suite (Jest + ts-jest):

npm install
npm test

Build

npm run build

Publishing

The package is prepared for publishing with a prepublish step that builds the TypeScript sources. See npm publish for details — if you use automation tokens, store them in CI secrets and never commit them to the repo.

Contributing

See CONTRIBUTING.md for the contribution guide and running tests locally.

License

ISC — see LICENSE.