Result <T, E>
Index
Constructors
constructor
Create a new Result representing the status of a failable operation
Type parameters
- T
- E: Error = Error
Parameters
value: T
optionalerror: E = null
Returns Result<T, E>
Properties
error
value
Accessors
err
Returns whether the operation was a failure
Returns boolean
ok
Returns whether the operation was a success
Returns boolean
Methods
unwrap
Unwrap the result This either returns the successful return of the operation, or throws the error it reported
Returns T
staticfailure
Build a Result for a failed operation
Parameters
error: Error
Returns Result<any, Error>
staticsuccess
Build a Result for a successful operation
Type parameters
- T
Parameters
value: T
Returns Result<T, any>
A class representing the result of a failable operation