/**
 * Result type for functional error handling
 */
export const ok = (value) => ({
    ok: true,
    value,
});
export const error = (error) => ({
    ok: false,
    error,
});
export const map = (result, fn) => (result.ok ? ok(fn(result.value)) : result);
export const flatMap = (result, fn) => (result.ok ? fn(result.value) : result);
export const mapError = (result, fn) => (result.ok ? result : error(fn(result.error)));
export const unwrapOr = (result, defaultValue) => result.ok ? result.value : defaultValue;
export const unwrapOrElse = (result, fn) => (result.ok ? result.value : fn(result.error));
export const isOk = (result) => result.ok;
export const isError = (result) => !result.ok;
//# sourceMappingURL=result.js.map