0.1.0 • Published 7 years ago

catchr v0.1.0

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

Instead of:

let x;
try {
  x = exceptionThrowingFunction();
} catch(ex) {
  x = reasonableDefault;
}
useX(x);

This:

const [x] = catchr(_ => exceptionThrowingFunction(), reasonableDefault);
useX(x);

You can also receive the exception:

const [x, err] = catchr(_ => exceptionThrowingFunction(), reasonableDefault);
if (err.name !== "SyntaxError") {
  useX(x);
}
0.1.0

7 years ago