try-or-die
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

pipeline status coverage report

try-or-die

Inspired by Scala's Try classes (including Success and Failure).

Try and succeed

By using try-or-die you can avoid most try-catch blocks in your code. That is because try-or-die wraps around possible exceptions and simply returns the thing you want, or whatever else you want.

Don't get it? Here is an example that will always succeed:

let result = Try<User>(() => userFactory.create('Jack'))
                .map(e => e.name)
                .map(e => e.substr(-1) === 'k')
                .value;

// Result will be true.
console.log(result);

Readme

Keywords

none

Package Sidebar

Install

npm i try-or-die

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

21.2 kB

Total Files

18

Last publish

Collaborators

  • wolfenrain