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

die-statement

v1.0.3

Published

A simple and easy way to kill any application whenever you want, be it on a new line or as an inline statement!

Readme

die() - Because Sometimes Code Needs to Just... Stop

npm License

A simple and easy way to kill any application whenever you want, be it on a new line or as an inline statement!

Installation

npm i die-statement

Or just drop the function in your codebase. No npm bloat, no build step, no regrets. Here it is, i'll make it easy for ya!

function die(message = "Fatal Error") {
    return (() => {
        const error = new Error();
        const match = error.stack?.match(/^(?!die).*@(.*:\d+:\d+)$/m);
        if (match) {
            console.error(message, "\n\nDied at:", match[1]);
        } else {
            console.error(message, "\n\nDied at (location unknown)");
        }
        throw error;
    })();
}

Usage

die(message?)

Parameters

  • message (string, optional): Your last words before everything crashes. Defaults to "Fatal Error" if you're feeling uncreative.

Returns

Nothing. It throws an Error. Your code stops here. Game over.

Examples

As a fallback (the fancy way):

const necessaryElement = document.getElementById("#important") || die();

When you've had enough (the direct way):

if (userDidSomethingDumb) {
    die("User did something unforgivable");
}

The dramatic exit:

const config = loadConfig() || die("No config, no service. I quit.");

What It Does

When called, die() will:

  1. Log your message (or the default one) to the console
  2. Show you exactly where your code gave up on life (Died at: file.js:42:10)
  3. Throw an Error to stop execution immediately

Why Use This?

Sometimes throw new Error() is too many characters. Sometimes you want your failures to feel more... deliberate. Sometimes you just want to watch the world burn, but in a traceable way.

Also, if you've ever missed PHP's die() function and tried to use throw new Error() in a statement only to have JavaScript laugh at you—well, now you don't have to miss it anymore.

Notes

  • The stack trace parsing works in modern browsers. If it fails, you'll get "(location unknown)" instead. Even die() has its limits.
  • This is blocking and synchronous. If you call it, everything stops. That's the point.

"To die, to sleep—no more—and by a sleep to say we end the heartache..." - Shakespeare, probably talking about JavaScript