@thepeoplescoder/throw_
v1.0.0
Published
Allows throwing exceptions as part of an expression.
Downloads
5
Maintainers
Readme
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;