@lucid-softworks/promise-result
v0.1.0
Published
Capture a Promise rejection in a Result.
Maintainers
Readme
@lucid-softworks/promise-result
Adapt a Promise rejection to @lucid-softworks/result.
import { promiseResult } from "@lucid-softworks/promise-result";
const response = await promiseResult(fetch(url), (cause) => ({
type: "network-error" as const,
cause,
}));Fulfilled values become Ok. Rejection reasons become Err unchanged unless
an error mapper is supplied. This package accepts an existing PromiseLike;
use @lucid-softworks/try-result for synchronous operations.
