import { type FactoryWithRequiredInput } from '../getter/getter'; import { type MapFunction, type AsyncMapFunction } from './map'; import { type Maybe } from './maybe.type'; /** * A map function that derives a boolean decision from the input value. */ export type DecisionFunction = MapFunction; /** * Async variant of {@link DecisionFunction}. */ export type AsyncDecisionFunction = AsyncMapFunction>; /** * Factory that creates a {@link DecisionFunction} from a configuration value. */ export type DecisionFunctionFactory = FactoryWithRequiredInput, C>; /** * Creates a {@link DecisionFunction} that always returns the given boolean, regardless of input. * * Useful for providing a constant decision where a function is expected. * * @param decision - the constant boolean value to return * @returns a decision function that always returns the given boolean * * @example * ```ts * const alwaysTrue = decisionFunction(true); * alwaysTrue('anything'); // true * ``` */ export declare function decisionFunction(decision: boolean): DecisionFunction; /** * Inverts a decision function so it returns the opposite boolean value. * * When `invert` is false or omitted, the original function is returned unchanged. * * @param fn - the decision function to potentially invert * @param invert - whether to apply the inversion * * @example * ```ts * const isPositive: DecisionFunction = (x) => x > 0; * const isNotPositive = invertDecision(isPositive, true); * isNotPositive(5); // false * ``` */ export declare const invertDecision: >(fn: F, invert?: boolean) => F; /** * Normalizes a boolean value, a {@link DecisionFunction}, or undefined into a consistent {@link DecisionFunction}. * * If the input is undefined, falls back to a constant function returning `defaultIfUndefined`. * * @param valueOrFunction - a boolean, decision function, or undefined * @param defaultIfUndefined - fallback boolean when the input is nullish (defaults to true) * @returns a {@link DecisionFunction} derived from the input * * @example * ```ts * const fn = asDecisionFunction(true); * fn('anything'); // true * * const fn2 = asDecisionFunction(undefined, false); * fn2('anything'); // false * ``` */ export declare function asDecisionFunction(valueOrFunction: Maybe>, defaultIfUndefined?: boolean): DecisionFunction; /** * Creates a {@link DecisionFunction} that checks strict equality against the given value. * * If the input is already a function, it is returned as-is, allowing callers to pass either a * concrete value or a custom decision function interchangeably. * * @param equalityValue - the value to compare against, or an existing decision function * @returns a decision function that checks strict equality with the given value * * @example * ```ts * const isThree = isEqualToValueDecisionFunction(3); * isThree(3); // true * isThree(4); // false * ``` */ export declare function isEqualToValueDecisionFunction(equalityValue: T | DecisionFunction): T extends DecisionFunction ? T : DecisionFunction;