@thepeoplescoder/throw_
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

throw_

A package that provides a single function:

function throw_(thing: any): never

If thing is a function, throw thing() is executed, otherwise throw thing is executed.

That's it.

How To build

Run this in a terminal window:

npm run build

Usage

Using ES6 modules:

import { throw_ } from "@thepeoplescoder/throw_";

Using CommonJS:

const { throw_ } = require("@thepeoplescoder/throw_");

Afterwards, you can do things along the lines of this:

expression = isErrorCondition
  ? throw_(anErrorObjectOrAFunctionThatReturnsSomethingThrowable)
  : intendedValueOfExpression;

Package Sidebar

Install

npm i @thepeoplescoder/throw_

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.37 kB

Total Files

6

Last publish

Collaborators

  • thepeoplescoder