@rickosborne/rebound
Version:
Rick Osborne's utilities for working with bounded numbers
35 lines • 1.84 kB
TypeScript
import type { Comparator } from "@rickosborne/typical";
import type { Unbounded } from "./range-like.js";
export declare const BOUND_GT = ">";
export declare const BOUND_GTE = ">=";
export declare const BOUND_LT = "<";
export declare const BOUND_LTE = "<=";
export type BoundType = typeof BOUND_GT | typeof BOUND_GTE | typeof BOUND_LT | typeof BOUND_LTE;
export declare const BOUND_TYPES: Readonly<BoundType[]>;
export declare const boundTypeComparator: Comparator<BoundType>;
export declare const boundTypeComparisonIsValid: Readonly<Record<BoundType, (comparison: number) => boolean>>;
export declare const boundComparator: <T>(a: Bound<T> | Unbounded, b: Bound<T> | Unbounded) => number;
export declare class Bound<T> {
static gt<N extends number>(value: number): Bound<N>;
static gt<S extends string>(value: string): Bound<S>;
static gt<T>(value: T, comparator: Comparator<T>): Bound<T>;
static gte<N extends number>(value: number): Bound<N>;
static gte<S extends string>(value: string): Bound<S>;
static gte<T>(value: T, comparator: Comparator<T>): Bound<T>;
static lt<N extends number>(value: number): Bound<N>;
static lt<S extends string>(value: string): Bound<S>;
static lt<T>(value: T, comparator: Comparator<T>): Bound<T>;
static lte<N extends number>(value: number): Bound<N>;
static lte<S extends string>(value: string): Bound<S>;
static lte<T>(value: T, comparator: Comparator<T>): Bound<T>;
readonly boundType: BoundType;
readonly comparator: Comparator<T>;
readonly isInc: boolean;
private readonly validator;
readonly value: T;
protected constructor(value: T, boundType: BoundType, comparator: Comparator<T>);
compareTo(other: Bound<T> | Unbounded): number;
isValid(value: T): boolean;
toString(): string;
}
//# sourceMappingURL=bound.d.ts.map