declare const symErr: unique symbol; export type Err = { [symErr]: true; error: T; }; export type Result = T | Err; export declare function Err(error: T): Err; /** * Typeguard for Err. Allows the pattern * ```ts * function getNumSquare(): Result { * const value = getNum(); * if (isErr(value)) { * return value; // return as error * } * return value ** 2; * } * function getNum(): Result * ``` * Since the non-error is not wrapped, it uses a symbol to prevent collisions */ export declare function isErr(result: Result): result is Err; /** * Given an array of results, run a function only on an array of ok results. * Returns a new array of results with same length as `results` where the ok * value may be Err or T2. */ export declare function mapOkResults(results: Result[], fn: (items: T1[]) => Result[]): Result[]; /** * See {@link mapOkResults} but `fn` is async */ export declare function mapOkResultsAsync(results: Result[], fn: (items: T1[]) => Promise[]>): Promise[]>; export {}; //# sourceMappingURL=err.d.ts.map