/** * A type used for returning and propagating errors. The first element of the union * represents success and contains a value, and the second represents an error and * contains an error value. * @private */ export type Result = { result: 'success'; value: T; } | { result: 'error'; value: E; }; export function success(value: T): Result { return {result: 'success', value}; } export function error(value: E): Result { return {result: 'error', value}; }