sidekicker
TypeScript icon, indicating that this package has built-in type declarations

0.1.7 • Public • Published

sidekicker

Methods

tryCatch

A simple implementation of tryCatch, inspired in Java Exceptions+TryCatch.

const sum = tryCatch(
    (x: number) => {
        if (x === 1) throw new CustomError()
        if (x === 2) throw () => {
        };
        if (x === 3) throw "==>"
        return 1 + 1
    },
    // Will call this function if the throw==CustomError
    exception(CustomError, (e) => `THIS IS A ${e.name}`),
    // Will call this function if throw a function
    exception(Function, (e) => `THIS IS A __${e.constructor.name}__ ERROR`),
    // Will call this function if throw a string
    exception(String, (e) => `${e} string error`),
)

Readme

Keywords

none

Package Sidebar

Install

npm i sidekicker

Weekly Downloads

57

Version

0.1.7

License

MIT

Unpacked Size

221 kB

Total Files

8

Last publish

Collaborators

  • g4rcez