import { Result } from '@fgv/ts-utils'; /** * Represents a generic range of some comparable type ``. * @public */ export interface RangeOfProperties { readonly min?: T; readonly max?: T; } /** * Format strings (in mustache format) to * use for both open-ended and complete * {@link Experimental.RangeOf | RangeOf}. * @public */ export interface RangeOfFormats { minOnly: string; maxOnly: string; minMax: string; } /** * Default {@link Experimental.RangeOfFormats | formats} to use for both * open-ended and complete {@link Experimental.RangeOf | RangeOf}. * @public */ export declare const DEFAULT_RANGEOF_FORMATS: RangeOfFormats; /** * Simple implementation of a possibly open-ended range of some comparable * type `` with test and formatting. * @public */ export declare class RangeOf implements RangeOfProperties { /** * Minimum extent of the range. */ readonly min?: T; /** * Maximum extent of the range. */ readonly max?: T; /** * Creates a new {@link Experimental.RangeOf | RangeOf}. * @param min - Optional minimum extent of the range. * @param max - Optional maximum extent of the range. */ constructor(min?: T, max?: T); /** * Static constructor for a {@link Experimental.RangeOf | RangeOf}. * @param init - {@link Experimental.RangeOfProperties | Range initializer}. * @returns A new {@link Experimental.RangeOf | RangeOf}. */ static createRange(init?: RangeOfProperties): Result>; /** * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties} given an * optional set of formats and 'empty' value to use. * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties} to be formatted. * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}. * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`. * @returns A string representation of the range. */ static propertiesToString(range: RangeOfProperties, formats?: RangeOfFormats, emptyValue?: T): string | undefined; /** * Default comparison uses javascript built-in comparison. * @param t1 - First value to be compared. * @param t2 - Second value to be compared. * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger * and `'equal'` if `t1` and `t2` are equal. * @internal */ protected static _defaultCompare(t1: T, t2: T): 'less' | 'equal' | 'greater'; /** * Checks if a supplied value is within this range. * @param t - The value to be tested. * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls * below the minimum extent of the range and `'greater'` if `t` is above the * maximum extent. */ check(t: T): 'less' | 'included' | 'greater'; /** * Determines if a supplied value is within this range. * @param t - The value to be tested. * @returns Returns `true` if `t` falls within the range, `false` otherwise. */ includes(t: T): boolean; /** * Finds the transition value that would bring a supplied value `t` into * range. * @param t - The value to be tested. * @returns The minimum extent of the range if `t` is below the range or * the maximum extent of the range if `t` is above the range. Returns * `undefined` if `t` already falls within the range. */ findTransition(t: T): T | undefined; /** * Formats the minimum and maximum values of this range. * @param format - A format function used to format the values. * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties} containing the * formatted representation of the {@link Experimental.RangeOf.min | minimum} and * {@link Experimental.RangeOf.max | maximum} * extent of the range, or `undefined` for an extent that is not present. */ toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties; /** * Formats this range using the supplied format function. * @param format - Format function used to format minimum and maximum extent values. * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}). * @returns Returns a formatted representation of this range. */ format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined; /** * Inner compare method can be overridden by a derived class. * @param t1 - First value to compare. * @param t2 - Second value to compare. * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger * and `'equal'` if `t1` and `t2` are equal. * @internal */ protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater'; } //# sourceMappingURL=rangeOf.d.ts.map