1.0.2 • Published 6 months ago

try-catch-fn v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

try-catch-fn

Functional try-catch implementation.

More info here: This is how functional try-catch transforms your JavaScript code.

Usage

import { tryCatch } from 'try-catch-fn';

const status = tryCatch({
  tryFn: () => {
    throw new Error('network error');
  },
  catchFn: (err) => 'error',
});

console.log(status); // error

Pass single function argument to simply "silence" any exception it throws.

import { tryCatch } from 'try-catch-fn';

const status = tryCatch(() => {
  throw new Error('error');
});

console.log(status); // null
1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago