Result <T, E>
Index
Constructors
constructor
Create a new Result representing the status of a failable operation
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
errorAsDOM
Convert the Result.Error message into a list of DOM elements as usable by the likes of ElementDOMScreen.setStatus).
Always returns an empty list for nullish errors
Parameters
customMessage: string | Element | readonly (string | Element)[] = null
A custom message to be used as prefix
Returns (string | Element)[]
The list of DOM elements
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
Parameters
value: T
Returns Result<T, any>
A class representing the result of a failable operation