/** * The string representation of a measurement. */ type Measurement$4 = `${Value}${Unit}`; /** * Create a new measurement string. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param value The value of the measurement. * @param unit The unit of the measurement. * @returns A new measurement string. */ declare const measurement$4: (value: Value, unit: Unit) => Measurement$4; /** * Type predicate that checks if a string is a valid measurement. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param candidate The value to check. * @param unit The unit of the measurement. * @param value The value of the measurement. * @returns The result of the check. */ declare const isMeasurement$4: (candidate: any, unit?: Unit, value?: Value) => candidate is Measurement$4; /** * Returns the value of a measurement with a fixed number of decimal places. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement to get the value of. * @param fractionDigits The number of decimal places to return. * @returns The value of the measurement with a fixed number of decimal places. */ declare const toFixed$4: (measurement: Measurement$4, fractionDigits?: number) => Measurement$4; /** * Returns the value of a measurement with a fixed number of decimal places. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement to get the value of. * @param fractionDigits The number of decimal places to return. * @returns The value of the measurement with a fixed number of decimal places. */ declare const toPrecision$4: (measurement: Measurement$4, precision?: number) => Measurement$4; /** * Returns the unit of a measurement. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement to get the unit of. * @returns The unit of the measurement. */ declare const unit$3: (measurement: Measurement$4) => Unit; /** * Returns the value of a measurement. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement to get the value of. * @returns The value of the measurement. */ declare const value$3: (measurement: Measurement$4) => Value; declare namespace index$3 { export { isMeasurement$4 as isMeasurement, measurement$4 as measurement, toFixed$4 as toFixed, toPrecision$4 as toPrecision, unit$3 as unit, value$3 as value }; export type { Measurement$4 as Measurement }; } /** * The tuple representation of a measurement. */ type Measurement$3 = readonly [value: Value, unit: Unit]; /** * Creates a new measurement tuple. * * @param value The value of the measurement. * @param unit The unit of the measurement. * @returns A new measurement tuple. */ declare const measurement$3: (value: Value, unit: Unit) => Measurement$3; /** * Type predicate that checks if a value is a measurement tuple. * * @param candidate The value to check. * @param unit The expected unit of the measurement. * @param value The expected value of the measurement. * @returns The candidate is a measurement tuple. */ declare const isMeasurement$3: (candidate: any, unit?: Unit, value?: Value) => candidate is Measurement$3; /** * Rounds the value of a measurement tuple to the specified number of decimal places. * * @param measurement The measurement tuple. * @param fractionDigits The number of decimal places. * @returns A new measurement tuple with the rounded value. */ declare const toFixed$3: ([value, unit]: Measurement$3, fractionDigits?: number) => Measurement$3; /** * Rounds the value of a measurement tuple to the specified precision. * * @param measurement The measurement tuple. * @param precision The number of significant digits. * @returns A new measurement tuple with the rounded value. */ declare const toPrecision$3: ([value, unit]: Measurement$3, precision?: number) => Measurement$3; /** * Extracts the unit from a measurement tuple. * * @param measurement The measurement tuple. * @returns The unit of the measurement. */ declare const unit$2: (measurement: Measurement$3) => Unit; /** * Extracts the value from a measurement tuple. * * @param measurement The measurement tuple. * @returns The value of the measurement. */ declare const value$2: (measurement: Measurement$3) => Value; declare namespace index$2 { export { isMeasurement$3 as isMeasurement, measurement$3 as measurement, toFixed$3 as toFixed, toPrecision$3 as toPrecision, unit$2 as unit, value$2 as value }; export type { Measurement$3 as Measurement }; } /** * The object representation of a measurement. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. */ type Measurement$2 = Number & { readonly value: Value; readonly unit: Unit; }; /** * Create a new measurement object. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param value The value of the measurement. * @param unit The unit of the measurement. * @returns A new measurement object. */ declare const measurement$2: (value: Value, unit: Unit) => Measurement$2; /** * Type predicate that checks if a value is a measurement object. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param candidate The value to check. * @param unit The unit of the measurement. * @param value The value of the measurement. * @returns true if the candidate is a measurement object, false otherwise. */ declare const isMeasurement$2: (candidate: any, unit?: Unit, value?: Value) => candidate is Measurement$2; /** * Returns the value of a measurement object, fixed to a * number of decimal places. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement object. * @returns The value of the measurement object. */ declare const toFixed$2: ({ value, unit }: Measurement$2, fractionDigits?: number) => Measurement$2; /** * Returns the value of a measurement object, rounded to * the specified precision. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement object. * @returns The value of the measurement object. */ declare const toPrecision$2: ({ value, unit }: Measurement$2, precision?: number) => Measurement$2; /** * Returns the unit of a measurement object. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement object. * @returns The value of the measurement object. */ declare const unit$1: (measurement: Measurement$2) => Unit; /** * Returns the value of a measurement object. * * @template Unit The type of the unit of measurement. * @template Value The type of the value of the measurement. * @param measurement The measurement object. * @returns The value of the measurement object. */ declare const value$1: (measurement: Measurement$2) => Value; declare namespace index$1 { export { isMeasurement$2 as isMeasurement, measurement$2 as measurement, toFixed$2 as toFixed, toPrecision$2 as toPrecision, unit$1 as unit, value$1 as value }; export type { Measurement$2 as Measurement }; } /** * A tuple of conversion functions to and from a base unit. */ type Conversion = readonly [ toBase: (value: number) => number, fromBase: (value: number) => number ]; /** * A record of conversion tuples for each unit. * The first conversion you provide is considered to be the * base unit. */ type Conversions = { readonly [unit in Unit]: Conversion; }; /** * Creates a linear conversion tuple, where: * - `base = value * coefficient + constant` * - `value = (base - constant) / coefficient` */ declare const linearConversion: (coefficient: number, constant?: number) => Conversion; /** * Represents a dimension measurement. * @template Units - The units of the dimension. */ type Measurement$1 = Measurement$2 & Alternatives; /** * Creates a dimension measurement governed by a set of conversions. * @param conversions - The conversions to use. * @param value - The value of the measurement. * @param unit - The unit of the measurement. * @returns A dimension measurement. * @template Units - The units of the dimension. * @template Unit - The unit of the measurement. * @template Value - The value of the measurement. */ declare function measurement$1(conversions: Conversions, value: Value, unit: Unit): Measurement$1; /** * Creates a dimension measurement governed by another * dimension measurement. * @param base - The base measurement. * @param value - The value of the measurement. * @param unit - The unit of the measurement. * @returns A dimension measurement of the same dimension as the base. * @template Units - The units of the dimension. * @template Unit - The unit of the measurement. * @template Value - The value of the measurement. */ declare function measurement$1(base: Measurement$1, value: Value, unit: Unit): Measurement$1; /** * Represents a collection of alternative measurements for different units. * * @template Units - The string literal type representing the available units. */ type Alternatives = { readonly [unit in Units]: Measurement$1; }; /** * A dimension is a map of units to creation functions. * Each function takes a number value and returns a * dimension measurement. * @template Units - The units of the dimension. */ type Dimension = { readonly [unit in Units]: (value: number) => Measurement$1; }; /** * Creates a dimension from a set of conversions. * @param conversions - The conversions for the dimension. * @returns The dimension. * @template Units - The units of the dimension. */ declare const dimension: (conversions: Conversions) => Dimension; /** * Type predicate, determining if a candidate is a dimension measurement. * @param candidate - The candidate to check. * @param units - The units of the dimension. * @param unit - The unit of the measurement. * @returns The predicate result. */ declare const isMeasurement$1: (candidate: any, units?: readonly Units[], unit?: Unit) => candidate is Measurement$1; /** * Rounds the value of a measurement to a specified number of decimal places. * * @param measurement - The measurement to round. * @param fractionDigits - The number of decimal places to round to. If not provided, the default value is used. * @returns A new measurement with the rounded value. */ declare const toFixed$1: (measurement: Measurement$1, fractionDigits?: number) => Measurement$1; /** * Returns a new measurement with the value rounded to the specified number of decimal places. * * @param measurement - The measurement to round. * @param fractionDigits - The number of decimal places to round to. If not provided, the default behavior is used. * @returns A new measurement with the rounded value. */ declare const toPrecision$1: (measurement: Measurement$1, fractionDigits?: number) => Measurement$1; /** * Returns the units of a given measurement. * * @template M - The measurement type. * @param {M} measurement - The measurement object. * @returns {Units} - The units of the measurement. */ type UnitsOf> = M extends Measurement$1 ? Units : never; /** * Retrieves the units of a given measurement. * * @param measurement - The measurement object. * @returns An array of units for the given measurement. */ declare const units: (measurement: Measurement$1) => U[]; type index_Alternatives = Alternatives; type index_Conversion = Conversion; type index_Conversions = Conversions; type index_Dimension = Dimension; type index_UnitsOf> = UnitsOf; declare const index_dimension: typeof dimension; declare const index_linearConversion: typeof linearConversion; declare const index_units: typeof units; declare namespace index { export { index_dimension as dimension, isMeasurement$1 as isMeasurement, index_linearConversion as linearConversion, measurement$1 as measurement, toFixed$1 as toFixed, toPrecision$1 as toPrecision, index_units as units }; export type { index_Alternatives as Alternatives, index_Conversion as Conversion, index_Conversions as Conversions, index_Dimension as Dimension, Measurement$1 as Measurement, index_UnitsOf as UnitsOf }; } /** * Represents a measurement with a specific unit and value. * * @template Unit - The type of unit for the measurement. * @template Value - The type of value for the measurement. */ type Measurement = Measurement$4 | Measurement$3 | Measurement$2 | Measurement$1; /** * Creates a measurement string based on the specified base * and value. * * @template Unit - The unit type of the measurement. * @template Value - The value type of the measurement. * * @param {string.Measurement} basedOn - The base measurement string. * @param {Value} value - The value of the measurement. * * @returns {string.Measurement} - The created measurement string. */ declare function measurement(basedOn: Measurement$4, value: Value): Measurement$4; /** * Creates a dimension measurement object matching the * provided dimension of the given value. * * @template Units - The units of the dimension. * @template Unit - The unit type of the measurement. * @template Value - The value type of the measurement. * * @param {dimension.Measurement} basedOn - The base dimension measurement. * @param {Value} value - The value of the measurement. * * @returns {Measurement} - The created measurement object. */ declare function measurement(basedOn: Measurement$1, value: Value): Measurement$1; /** * Creates a measurement tuple based on the specified base * and value. * * @template Unit - The unit type of the measurement. * @template Value - The value type of the measurement. * * @param {tuple.Measurement} basedOn - The base measurement tuple. * @param {Value} value - The value of the measurement. * * @returns {tuple.Measurement} - The created measurement tuple. */ declare function measurement(basedOn: Measurement$3, value: Value): Measurement$3; /** * Creates a measurement object based on the specified base * and value. * * @template Unit - The unit type of the measurement. * @template Value - The value type of the measurement. * * @param {object.Measurement} basedOn - The base measurement object. * @param {Value} value - The value of the measurement. * * @returns {object.Measurement} - The created measurement object. */ declare function measurement(basedOn: Measurement$2, value: Value): Measurement$2; /** * Creates a measurement object based on the specified base * and value. * * @template Unit - The unit type of the measurement. * @template Value - The value type of the measurement. * * @param {Measurement} basedOn - The base measurement object. * @param {Value} value - The value of the measurement. * * @returns {Measurement} - The created measurement object. */ declare function measurement(basedOn: Measurement, value: Value): Measurement; /** * Type predicate, determining if a candidate is a measurement. * * @template Units - The type of units. * @template Unit - The specific unit type. * @param candidate - The value to be checked. * @param unit - The specific unit to be checked against. * @param units - Additional units to be checked against. * @returns A boolean indicating whether the candidate is a valid measurement. */ declare const isMeasurement: (candidate: any, unit?: Unit, units?: readonly Units[]) => candidate is Measurement; /** * Converts a measurement value to a fixed number with a specified number of decimal places. * * @param measurement - The measurement value to convert. * @param fractionDigits - The number of decimal places to round to. If not provided, the default behavior is used. * @returns The converted measurement value with the specified number of decimal places. */ declare const toFixed: (measurement: Measurement, fractionDigits?: number) => Measurement; /** * Applies precision formatting to a measurement value. * * @param measurement - The measurement value to apply precision formatting to. * @param fractionDigits - The number of digits to appear after the decimal point. * @returns A new measurement value with precision formatting applied. */ declare const toPrecision: (measurement: Measurement, fractionDigits?: number) => Measurement; /** * Returns the unit of measurement for the given measurement. * * @template Unit - The type of unit. * @param measurement - The measurement value. * @returns The unit of measurement. */ declare function unit(measurement: Measurement): Unit; /** * Retrieves the value from a measurement object. * * @param measurement - The measurement object to retrieve the value from. * @returns The value of the measurement. */ declare function value(measurement: Measurement): Value; export { index as dimension, isMeasurement, measurement, index$1 as object, index$3 as string, toFixed, toPrecision, index$2 as tuple, unit, value }; export type { Measurement };