@tempots/std
Result variable
Utility functions for working with Result
types.
Signature:
Result: {
success<V>(value: V): Result<V, any>;
failure<E>(error: E): Result<any, E>;
map: <V1, V2, E>(r: Result<V1, E>, f: (value: V1) => V2) => Result<V2, E>;
flatMap: <V1, V2, E>(r: Result<V1, E>, f: (value: V1) => Result<V2, E>) => Result<V2, E>;
toAsync<V, E>(r: Result<V, E>): AsyncResult<V, E>;
toValidation<V, E>(r: Result<V, E>): Validation<E>;
isSuccess<V, E>(r: Result<V, E>): r is Success<V>;
isFailure<V, E>(r: Result<V, E>): r is Failure<E>;
getOrElse<V, E>(r: Result<V, E>, alt: V): V;
getOrElseLazy<V, E>(r: Result<V, E>, altf: () => V): V;
getOrNull<V, E>(r: Result<V, E>): V | null;
getOrUndefined<V, E>(r: Result<V, E>): Maybe<V>;
getUnsafe: <V, E>(r: Result<V, E>) => V;
match: <V1, V2, E>(r: Result<V1, E>, success: (value: V1) => V2, failure: (error: E) => V2) => V2;
whenSuccess: <V, E>(r: Result<V, E>, apply: (v: V) => void) => Result<V, E>;
whenFailure: <V, E>(r: Result<V, E>, apply: (e: E) => void) => Result<V, E>;
combine: <V, E>(r1: Result<V, E>, r2: Result<V, E>, combineV: (v1: V, v2: V) => V, combineE: (e1: E, e2: E) => E) => Result<V, E>;
equals: <V, E>(r1: Result<V, E>, r2: Result<V, E>, options?: {
valueEquals: (v1: V, v2: V) => boolean;
errorEquals: (e1: E, e2: E) => boolean;
}) => boolean;
all: <V, E>(results: Result<V, E>[]) => Result<V[], E>;
}