import { type IterableOrValue } from './../iterable/iterable'; import { type EqualityComparatorFunction } from './comparator'; /** * Used to check if the input object is considered equal to the current context. */ export type IsEqualContext = (x: T) => boolean; /** * Similar to IsEqualContext, but supports an array of objects. * * Used to check if the input object or array of objects are considered equal to the current context. */ export type AreEqualContext = (x: IterableOrValue) => boolean; /** * Creates an {@link IsEqualContext} that captures a reference value and uses the provided comparator * to check whether subsequent values are equal to it. * * @param contextValue - The reference value to compare against. * @param fn - The equality comparator. * @returns Checks whether a given value equals the captured reference. * * @dbxUtil * @dbxUtilCategory value * @dbxUtilKind factory * @dbxUtilTags equal, equality, compare, context, factory * @dbxUtilRelated are-equal-context, all-objects-are-equal * * @example * ```ts * const isEqual = (a: number, b: number) => a === b; * const context = isEqualContext(0, isEqual); * * context(0); // true * context(10); // false * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function isEqualContext(contextValue: T, fn: EqualityComparatorFunction): IsEqualContext; /** * Creates an {@link AreEqualContext} that checks whether a single value or all values in an iterable * are equal to the captured reference value. * * Returns `true` only if every value in the input matches the context value according to the comparator. * * @param contextValue - The reference value to compare against. * @param fn - The equality comparator. * @returns Checks whether all input values equal the captured reference. * * @dbxUtil * @dbxUtilCategory value * @dbxUtilKind factory * @dbxUtilTags equal, equality, compare, context, iterable, all, factory * @dbxUtilRelated is-equal-context, all-objects-are-equal * * @example * ```ts * const isEqual = (a: number, b: number) => a === b; * const context = areEqualContext(0, isEqual); * * context([0, 0, 0]); // true * context([0, 1, 2]); // false * ``` * * @__NO_SIDE_EFFECTS__ */ export declare function areEqualContext(contextValue: T, fn: EqualityComparatorFunction): AreEqualContext; /** * Returns `true` if all values in the input are equal according to the provided comparator. * * Empty iterables and single-value inputs return `true` by default, since there is nothing to contradict equality. * Uses the first value as the reference and checks all remaining values against it. * * @param values - The values to compare. * @param fn - The equality comparator. * @returns `true` if all values are equal to each other, or if fewer than two values are provided. * * @dbxUtil * @dbxUtilCategory value * @dbxUtilTags equal, equality, compare, all, iterable, every * @dbxUtilRelated is-equal-context, are-equal-context * * @example * ```ts * const isEqual = (a: unknown, b: unknown) => a === b; * * allObjectsAreEqual([undefined, undefined, undefined], isEqual); * // true * * allObjectsAreEqual([undefined, 'test', undefined], isEqual); * // false * ``` */ export declare function allObjectsAreEqual(values: IterableOrValue, fn: EqualityComparatorFunction): boolean;