Applies a transformation function to the success value of a Result or ResultAsync. If the input is a Failure, it will be returned unchanged.
The input Result or ResultAsync.
The transformed success value type.
import { Result } from '@praha/byethrow';const result = Result.pipe( Result.succeed(2), Result.map((x) => x * 10),);// { type: 'Success', value: 20 } Copy
import { Result } from '@praha/byethrow';const result = Result.pipe( Result.succeed(2), Result.map((x) => x * 10),);// { type: 'Success', value: 20 }
import { Result } from '@praha/byethrow';const result = Result.pipe( Result.fail('error'), Result.map((x) => x * 10),);// { type: 'Failure', error: 'error' } Copy
import { Result } from '@praha/byethrow';const result = Result.pipe( Result.fail('error'), Result.map((x) => x * 10),);// { type: 'Failure', error: 'error' }
pipe - It is recommended to use this function with the pipe function for better readability and composability.
Applies a transformation function to the success value of a Result or ResultAsync. If the input is a Failure, it will be returned unchanged.
Type Param: R1
The input Result or ResultAsync.
Type Param: T2
The transformed success value type.
Example: Success Case
Example: Failure Case (unchanged)
See
pipe - It is recommended to use this function with the pipe function for better readability and composability.