UNPKG

758 BTypeScriptView Raw
1import type { Fn2 } from "./fn.js";
2/**
3 * Generic 2-element comparator function type alias.
4 *
5 * @remarks
6 * Must follow this contract and return:
7 *
8 * - negative if `a < b`
9 * - zero if `a == b`
10 * - positive if `a > b`
11 */
12export declare type Comparator<T> = Fn2<T, T, number>;
13/**
14 * Generic interface to compare value types.
15 */
16export interface ICompare<T> {
17 /**
18 * Compares this value with given value `x`. MUST follow same
19 * contract as {@link Comparator}.
20 *
21 * @remarks
22 * MUST return 0 if the type also implements `IEquiv` and `equiv`
23 * returns true for same `x`.
24 *
25 * Also see {@link IHash}.
26 *
27 * @param x - compare value
28 */
29 compare(x: T): number;
30}
31//# sourceMappingURL=compare.d.ts.map
\No newline at end of file