Overview
Executes one of two functions depending on whether theResultAsync is Ok or Err. Always returns a Promise that resolves to the result of the executed function.
Signature
Function to execute if the ResultAsync is Ok
Function to execute if the ResultAsync is Err
Promise<A | B> - A Promise resolving to the result of the executed callback
Usage
HTTP response handling
Logging results
Converting to traditional error handling
Key characteristics
Unlike the sync
Result.match(), ResultAsync.match() always returns a Promise, even if both callbacks are synchronous.- Exhaustive: Forces you to handle both Ok and Err cases
- Type unwrapping: Extracts the value/error from the Result
- Returns Promise: Always async, requires await or .then()
Comparison with sync Result
Related
unwrapOr
Get value or default without error callback
Result.match
Synchronous version