Promisable trait - supports conversion to Promise
Represents containers or values that can be converted to Promise form. This enables integration with async/await patterns and Promise-based APIs while maintaining functional programming principles.
const either: Either<string, number> = Right(42)const promise: Promise<number> = either.toPromise()// Promise resolves with 42const leftEither: Either<string, number> = Left("error")const failedPromise: Promise<number> = leftEither.toPromise()// Promise rejects with "error" Copy
const either: Either<string, number> = Right(42)const promise: Promise<number> = either.toPromise()// Promise resolves with 42const leftEither: Either<string, number> = Left("error")const failedPromise: Promise<number> = leftEither.toPromise()// Promise rejects with "error"
The type of value contained within the Promise
Converts this container to a Promise
The behavior depends on the implementing container:
A Promise that resolves or rejects based on the container's state
Promisable trait - supports conversion to Promise
Represents containers or values that can be converted to Promise form. This enables integration with async/await patterns and Promise-based APIs while maintaining functional programming principles.
Example