import { Fraction } from 'fraction.js'; import { UnitSystem } from './UnitSystem.ts'; import { BaseUnitDefinition, DerivedUnitDefinition, FactorDefinition, UnitFormatOptions, UnitFormatPart } from './types.ts'; import { ApproximateEqualityThreshold } from './float.ts'; export declare const UnityFactor: FactorDefinition; export declare class Unit, F extends Record, D extends Record> { readonly unitSystem: UnitSystem; readonly factor: FactorDefinition; readonly baseUnits: Partial>; constructor(unitSystem: UnitSystem, factor: FactorDefinition, baseUnits: Partial>); clone(): Unit; exponentOf(baseUnit: keyof U): Fraction; get isZero(): boolean; get isUnitless(): boolean; inverse(): Unit; isEqual(rhs: Unit): boolean; isApproxEqual(rhs: Unit, thresholds?: ApproximateEqualityThreshold): boolean; /** Compatible units are such that can be added together, i.e. 1 kg + 1 g */ isCompatible(rhs: Unit): boolean; pow(num: Fraction): Unit; multiply(rhs: Unit | number): Unit; divide(rhs: Unit): Unit; withFactor(factor: Partial): Unit; /** * Find a more suitable factor for a `value` in the unit this instance represents. * * This method keeps the same base units, but adjusts the factor to represent the value * with the least amount of digits in the non-fractional part. * * @param value A quantity expressed in the unit this instance represents. * @param options Rules for determining the best factor. * @returns A unit with the same baseUnits as `this` but with a more suitable factor for `value` */ withBestFactorFor(value: number, opts?: { allowDifferentBase?: boolean; }): Unit; /** * Takes a dimensionless value and multiplies it by this unit's factor. * Assuming the value is expressed in this unit, the method converts it * to the base unit. * @example * const unit = SI.parseUnit('km'); * unit.multiplyValueByFactor(2) // 2_000 * // because 2 km = 2 000 m */ multiplyValueByFactor(value: number): number; /** * Takes a dimensionless value and divides it by this unit's factor. * Assuming the value is expressed in the base unit, the method converts * it to this unit. * @example * const unit = SI.parseUnit('km'); * unit.divideValueByFactor(2_000) // 2 * // because 2 000 m = 2 km */ divideValueByFactor(value: number): number; /** * Takes another unit, which is compatible with this one, and returns * a number such that if you take a quantity expressed in this unit * and multiply it by the number, you will have computed the quantity * expressed in the provided unit. */ conversionFactorTo(targetUnit: Unit): number; /** * Takes another unit, which is compatible with this one, and returns * a number such that if you take a quantity expressed in the provided * unit and multiply it by the number, you will have computed the quantity * expressed in this unit. */ conversionFactorFrom(sourceUnit: Unit): number; toString(opts?: UnitFormatOptions): string; toParts(opts?: UnitFormatOptions): UnitFormatPart[]; }