import { ErrType, Result } from "./types"; /** * @method Ok - Returns a value with a type `T` of `Result` signifying success of an operation. If the `T` type is `void` or `undefined` can be used without a value. * @returns `{ok: true, data: T}` result object. * @example * ```ts * function toNumber(str: string): Result { * const parseResult = Number(str); * * if (isNaN(parseResult)) { * return Err(new Error(`Couldn't convert ${str} to number`)); * } * * return Ok(parseResult); * } * * function testFileRead(path: string): Result { * const data = fs.readFile(path); * * if (!data.length) { * return Err(); * } * * return Ok(); * } * ``` * */ export declare function Ok(): Result; export declare function Ok(data: T): Result; /** * @method Err - Returns a value with a type `E` of `Result` signifying fail of an operation. If the `E` type is `void` or `undefined` can be used without a value. * * *Note:* `E` type is constrained by `undefined | void | string | Error`, custom error type that extends native `Error` also satisfies type boundaries * @returns `{ok: false, error: E}` result object. * @example * ```ts * function toNumber(str: string): Result { * const parseResult = Number(str); * * if (isNaN(parseResult)) { * return Err(new Error(`Couldn't convert ${str} to number`)); * } * * return Ok(parseResult); * } * * function testFileRead(path: string): Result { * const data = fs.readFile(path); * * if (!data.length) { * return Err(); * } * * return Ok(); * } * ``` * */ export declare function Err(): Result; export declare function Err(error: E): Result;