Function getResult

  • Converts Promise to Result

    Type Parameters

    • R

    • E

    Parameters

    • promise: Promise<R>

      target Promise

    Returns Promise<Result<R, E>>

    success result for resolved promise or error result for rejected promise

    const successResult = await getResult(Promise.resolve('foo'));
    successResult.unwrap(); // returns 'foo'

    const errorResult = await getResult(Promise.reject('bar'));
    errorResult.unwrapErr(); // returns 'bar'

Generated using TypeDoc