/** * Transform the value if not an error. * If the value is an error, returns it unchanged. * * @example * const result = map(user, u => u.name) * // If user is User, result is string * // If user is NotFoundError, result is NotFoundError */ export declare function map(value: V, fn: (v: Exclude) => U): Extract | U; /** * Transform the error if it is an error. * If the value is not an error, returns it unchanged. * * @example * const result = mapError(fetchResult, e => new AppError({ cause: e })) * // Converts any error type to AppError */ export declare function mapError(value: V, fn: (e: Extract) => E2): E2 | Exclude; /** * Chain another errore-returning function. * If the value is an error, returns it unchanged. * If successful, runs fn and returns its result. * * @example * const result = andThen(userId, id => fetchUser(id)) * // If userId is ValidationError, result is ValidationError * // If userId is string, result is whatever fetchUser returns */ export declare function andThen(value: V, fn: (v: Exclude) => R): Extract | R; /** * Async version of andThen. * * @example * const result = await andThenAsync(userId, async id => { * const user = await fetchUser(id) * return user * }) */ export declare function andThenAsync(value: V, fn: (v: Exclude) => Promise): Promise | R>; /** * Run a side effect if the value is not an error. * Returns the original value unchanged. * * @example * const result = tap(user, u => console.log('Got user:', u.name)) */ export declare function tap(value: V, fn: (v: Exclude) => void): V; /** * Async version of tap. * * @example * const result = await tapAsync(user, async u => { * await logToService(u) * }) */ export declare function tapAsync(value: V, fn: (v: Exclude) => Promise): Promise; //# sourceMappingURL=transform.d.ts.map