1.2.1 • Published 3 years ago

panic-fn v1.2.1

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

panic-fn

Source Deploy Coverage Status

Functional way of throwing errors in JS/TS

Why?

Have you ever tried to do this?

callback(() => throw new Error("Not implemented"));
// or this
doStuff(value ?? throw new Error("No value provided"));

But got Uncaught SyntaxError: Unexpected token 'throw'.

With panic-fn it works as expected.

callback(() => panic("Not implemented"));
// or this
doStuff(value ?? panic("No value provided"));

You can also throw custom errors:

panic(new SyntaxError(`Unexpected token 'throw'`));

Installation

Node

npm i panic-fn
import { panic } from "panic-fn";

Deno

import { panic } from "https://deno.land/x/panic_fn/mod.ts";

Module info

This module was created using denoland/dnt.

Source is written in Deno and compiles to both Node.js CJS and ESM.

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.3

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago