import { err, ok } from '@hollowdark/utils/result/constructors' import type { Result } from '@hollowdark/utils/result/types' /** Map the value of an ok result; pass errors through unchanged. */ export function mapResult(r: Result, f: (value: T) => U): Result { return r.ok ? ok(f(r.value)) : r } /** Map the error of a failed result; pass values through unchanged. */ export function mapErr(r: Result, f: (error: E) => F): Result { return r.ok ? r : err(f(r.error)) }