@hiki9/rich-domain
Version:
Rich Domain is a library that provides a set of tools to help you build complex business logic in NodeJS using Domain Driven Design principles.
23 lines • 1.03 kB
TypeScript
export type ResultError = {
message: string;
};
export type Either<Error extends ResultError, Result> = Fail<Error, Result> | Ok<Error, Result>;
export type PromiseEither<Error extends ResultError, Result> = Promise<Either<Error, Result>>;
export declare class Fail<Error extends ResultError, Result> {
readonly _value: Error;
constructor(value: Error);
getValue(): Error;
isFail(): this is Fail<Error, Result>;
isSuccess(): this is Ok<Error, Result>;
}
export declare class Ok<Error extends ResultError, Result> {
private readonly _value;
constructor(value: Result);
getValue(): Result;
isFail(): this is Fail<Error, Result>;
isSuccess(): this is Ok<Error, Result>;
}
export declare const fail: <Error extends ResultError, Result>(l: Error) => Either<Error, Result>;
export declare const ok: <Error extends ResultError, Result>(a?: Result) => Either<Error, Result>;
export declare const combine: (results: Either<any, any>[]) => Either<any, any[]>;
//# sourceMappingURL=result.d.ts.map