Public
pomdtr
neverthrow
Script
Usage import { Failure, Success } from "https://esm.town/v/pomdtr/neverthrow?v=5";
const demoFunction = () => {
const result = Math.random();
if (result > 0.5) {
return Failure(
"Math. random produced too high a number",
);
}
return Success(result);
};
const res = demoFunction();
if (res.ok) {
console.log(res.value);
} else {
console.error(res.error);
}
1
Updated: August 16, 2024