onrails
    Preparing search index...

    Variable fromPromiseConst

    fromPromise: <T, E>(
        promise: PromiseLike<T>,
        onReject: (error: unknown) => E,
    ) => ResultAsync<T, E> = ResultAsync.fromPromise

    Wraps a PromiseLike<T> into a ResultAsync. Reject reasons go through onReject to become typed Errs; success becomes Ok<T>.

    Type Declaration

      • <T, E>(
            promise: PromiseLike<T>,
            onReject: (error: unknown) => E,
        ): ResultAsync<T, E>
      • Type Parameters

        • T
        • E

        Parameters

        • promise: PromiseLike<T>
        • onReject: (error: unknown) => E

        Returns ResultAsync<T, E>

    const body = fromPromise(
    fetch(url).then((r) => r.text()),
    (e): NetworkError => ({ kind: "network", cause: String(e) }),
    );