Interface: Err<T, E> 
An Err instance is the failure variant instance of the Result type, representing a failure outcome from an operation which may fail. For a full discussion, see the module docs.
Extends 
- Omit<- ResultImpl<- T,- E>,- "value"|- "cast">
Type Parameters 
T 
T
The type which would be wrapped in an Ok variant of Result.
E 
E
The type wrapped in this Err variant of Result.
Properties 
error 
error:
E
The wrapped error value.
Overrides 
Omit.error
isErr 
isErr:
true
Is the Result an Err?
Overrides 
Omit.isErr
isOk 
isOk:
false
Overrides 
Omit.isOk
variant 
readonlyvariant:"Err"
Err is always Variant.Err.
Overrides 
Omit.variant
Methods 
and() 
and<
U>(mAnd):Result<U,E>
Method variant for and
Type Parameters 
U 
U
Parameters 
mAnd 
Result<U, E>
Returns 
Result<U, E>
Inherited from 
Omit.and
andThen() 
Call Signature 
andThen<
U>(andThenFn):Result<U,E>
Method variant for andThen
Type Parameters 
U 
U
Parameters 
andThenFn 
(t) => Result<U, E>
Returns 
Result<U, E>
Inherited from 
Omit.andThen
Call Signature 
andThen<
R>(andThenFn):Result<OkFor<R>,E|ErrFor<R>>
Method variant for andThen
Type Parameters 
R 
R extends AnyResult
Parameters 
andThenFn 
(t) => R
Returns 
Result<OkFor<R>, E | ErrFor<R>>
Inherited from 
Omit.andThen
ap() 
ap<
A,B>(this,r):Result<B,E>
Method variant for ap
Type Parameters 
A 
A
B 
B
Parameters 
this 
Result<(a) => B, E>
r 
Result<A, E>
Returns 
Result<B, E>
Inherited from 
Omit.ap
cast() 
cast<
U>():Result<U,E>
Type Parameters 
U 
U
Returns 
Result<U, E>
equals() 
equals(
comparison):boolean
Method variant for equals
Parameters 
comparison 
Result<T, E>
Returns 
boolean
Inherited from 
Omit.equals
flatten() 
flatten<
A,F>(this):Result<A,E|F>
Given a nested Result, remove one layer of nesting.
For example, given a Result<Result<string, E2>, E1>, the resulting type after using this method will be Result<string, E1 | E2>.
Note 
This method only works when the value wrapped in Result is another Result. If you have a Result<string, E> or Result<number, E>, this method won't work. If you have a Result<Result<string, E2>, E1>, then you can call .flatten() to get back a Result<string, E1 | E2>.
Examples 
import * as result from 'true-myth/result';
const nested = result.ok(result.ok('hello'));
const flattened = nested.flatten(); // Result<string, never>
console.log(flattened); // Ok('hello')
const nestedError = result.ok(result.err('inner error'));
const flattenedError = nestedError.flatten(); // Result<never, string>
console.log(flattenedError); // Err('inner error')
const errorNested = result.err<Result<string, string>, string>('outer error');
const flattenedOuter = errorNested.flatten(); // Result<string, string>
console.log(flattenedOuter); // Err('outer error')Type Parameters 
A 
A
F 
F
Parameters 
this 
Returns 
Result<A, E | F>
Inherited from 
Omit.flatten
map() 
map<
U>(mapFn):Result<U,E>
Method variant for map
Type Parameters 
U 
U
Parameters 
mapFn 
(t) => U
Returns 
Result<U, E>
Inherited from 
Omit.map
mapErr() 
mapErr<
F>(mapErrFn):Result<T,F>
Method variant for mapErr
Type Parameters 
F 
F
Parameters 
mapErrFn 
(e) => F
Returns 
Result<T, F>
Inherited from 
Omit.mapErr
mapOr() 
mapOr<
U>(orU,mapFn):U
Method variant for mapOr
Type Parameters 
U 
U
Parameters 
orU 
U
mapFn 
(t) => U
Returns 
U
Inherited from 
Omit.mapOr
mapOrElse() 
mapOrElse<
U>(orElseFn,mapFn):U
Method variant for mapOrElse
Type Parameters 
U 
U
Parameters 
orElseFn 
(err) => U
mapFn 
(t) => U
Returns 
U
Inherited from 
Omit.mapOrElse
match() 
match<
A>(matcher):A
Method variant for match
Type Parameters 
A 
A
Parameters 
matcher 
Matcher<T, E, A>
Returns 
A
Inherited from 
Omit.match
or() 
or<
F>(orResult):Result<T,F>
Method variant for or
Type Parameters 
F 
F
Parameters 
orResult 
Result<T, F>
Returns 
Result<T, F>
Inherited from 
Omit.or
orElse() 
Call Signature 
orElse<
F>(orElseFn):Result<T,F>
Method variant for orElse
Type Parameters 
F 
F
Parameters 
orElseFn 
(err) => Result<T, F>
Returns 
Result<T, F>
Inherited from 
Omit.orElse
Call Signature 
orElse<
R>(orElseFn):Result<T|OkFor<R>,ErrFor<R>>
Method variant for orElse
Type Parameters 
R 
R extends AnyResult
Parameters 
orElseFn 
(err) => R
Returns 
Result<T | OkFor<R>, ErrFor<R>>
Inherited from 
Omit.orElse
toJSON() 
toJSON():
Serialized<T,E>
Method variant for toJSON
Returns 
Serialized<T, E>
Inherited from 
Omit.toJSON
toString() 
toString():
string
Method variant for toString
Returns 
string
Inherited from 
Omit.toString
unwrapOr() 
unwrapOr<
U>(defaultValue):T|U
Method variant for unwrapOr
Type Parameters 
U 
U = T
Parameters 
defaultValue 
U
Returns 
T | U
Inherited from 
Omit.unwrapOr
unwrapOrElse() 
unwrapOrElse<
U>(elseFn):T|U
Method variant for unwrapOrElse
Type Parameters 
U 
U
Parameters 
elseFn 
(error) => U
Returns 
T | U
Inherited from 
Omit.unwrapOrElse