Creates a Success result from a given value. Automatically wraps the value in a Promise if it is asynchronous.
Promise
The type of the value to wrap.
A Result or ResultAsync depending on whether the input is a promise.
import { Result } from '@praha/byethrow';const result = Result.succeed(42);// Result.Result<number, never> Copy
import { Result } from '@praha/byethrow';const result = Result.succeed(42);// Result.Result<number, never>
import { Result } from '@praha/byethrow';const result = Result.succeed(Promise.resolve(42));// Result.ResultAsync<number, never> Copy
import { Result } from '@praha/byethrow';const result = Result.succeed(Promise.resolve(42));// Result.ResultAsync<number, never>
import { Result } from '@praha/byethrow';const result = Result.succeed();// Result.Result<void, never> Copy
import { Result } from '@praha/byethrow';const result = Result.succeed();// Result.Result<void, never>
combine - For combining multiple Results into a single Result.
Creates a Success result from a given value. Automatically wraps the value in a
Promise
if it is asynchronous.Type Param: T
The type of the value to wrap.
Returns
A Result or ResultAsync depending on whether the input is a promise.
Example: Synchronous Usage
Example: Asynchronous Usage
Example: With No Value
See
combine - For combining multiple Results into a single Result.