JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1237
  • Score
    100M100P100Q116288F
  • License ISC

Package Exports

  • @snomiao/die

Readme

Die

Just like PHP's DIE('REASON'), Simple function while doing functional dev

Usage

import DIE from '@snomiao/die'
const token = process.env.TOKEN ?? DIE("Missing Token")

console.log(token)

Impl

export function DIE(reason?: string | Error): never {
    if (typeof reason === "string") {
        const err = new Error(reason);
        throw err.stack;
    }
    throw reason;
}