export declare namespace Sync { type Happy = T; type Sad = Error; type Outcome = Happy | Sad; /** * @class An implementation of the result monad, utilizing Happy/Sad path terminiology. */ class Path { /** *@description a discriminated union that holds the value or error of the `Path`. */ readonly outcome: Outcome; private constructor(); /** * Factory method for creating an instance of the `Path` class with a value. * @param value is the success value of the happy path. */ static happy(value: T): Path; /** * @description A happy path continuation. * @param callback a function that is executed only when the `outcome` of `Path` is happy. * @returns an instance of `Path` where `TNewValue` is the return type of `continuation`. */ onHappyPath(callback: (value: T) => TNewValue): Path; /** * A helper function for type-checking an `Outcome`. * @param outcome the `outcome` of a `Path`. * @remark an alternative to using continuations. */ isHappy(outcome: Happy | Sad): outcome is Happy; /** * A Factory method for creating an instance of the `Path` class with an error. * @param error is the error of the sad path. */ static sad(error: Error): Path; /** * @param callbackWithParam a function that is executed only when the `outcome` of `Path` is sad. */ onSadPath(callbackWithParam: (error: Error) => void): Path; /** * @param callback a function that is executed only when the `outcome` of `Path` is sad. */ onSadPath(callback: () => void): Path; /** * A helper function for type-checking an `Outcome`. * @param outcome the `outcome` of a `Path`. * @remark an alternative to using continuations. */ isSad(outcome: Sad | Happy): outcome is Sad; } } /** * @description A Wrapper around path, so that happy paths can be created more fluent. * @example Happy.path(); */ export declare const Happy: { path: typeof Sync.Path.happy; }; /** * @description A Wrapper around path, so that sad paths can be created more fluent. * @example Sad.path(); */ export declare const Sad: { path: typeof Sync.Path.sad; }; export declare namespace Async { /** * @description Wrapper around `Promise` */ class Path { private readonly promise; private constructor(); static fromPromise(promise: Promise): Path; onHappyPath(callback: (value: T) => TNewValue): Path; onSadPath(callbackWithParam: (error: Error) => void): Path; onSadPath(callback: () => void): Path; } }