import { AllowedExponents , DivideUnits , DivisorUnit , ExponentiateUnit , MultiplicandUnit , MultiplyUnits , Unit , UnitWithSymbols , } from "./unitTypeArithmetic" ; export interface MeasureFormatter < N > { formatValue ? : ( value : N ) => string ; formatUnit ? : ( unit : UnitWithSymbols ) => string ; } /** The set of numeric operations required to fully represent a `GenericMeasure` for a given numeric type */ export interface NumericOperations < N > { /** Returns the multiplicative identity for numbers of type N */ one ( ) : N ; /** Returns the negative of a number of type N */ neg ( value ) : N ; /** Returns the sum of two numbers of type N */ add ( left , right ) : N ; /** Returns the difference of two numbers of type N */ sub ( left , right ) : N ; /** Returns the product of two numbers of type N */ mult ( left , right ) : N ; /** Returns the quotient of two numbers of type N */ div ( left , right ) : N ; /** Returns the base raised to the exponent for numbers of type N */ pow ( base , exponent ) : N ; /** Compares two numbers returning a negative, zero, or positive value. */ compare ( left , right ) : number ; /** Formats a number for display */ format ( value ) : string ; } /** A numeric value with a corresponding unit of measurement. */ export interface GenericMeasure < N , U extends Unit > { /** The numeric value of this measure */ readonly value : N ; /** The unit of this measure */ readonly unit : UnitWithSymbols < U > ; /** The symbol of the unit this measure represents (e.g. 0.3048 m = 1 ft) */ readonly symbol : string | undefined ; returns squared : "2" extends AllowedExponents < U > ? ( ) => GenericMeasure < N , ExponentiateUnit < U , "2" > > : never ; returns cubed : "3" extends AllowedExponents < U > ? ( ) => GenericMeasure < N , ExponentiateUnit < U , "3" > > : never ; param exponent returns toThe < E extends AllowedExponents < U > > ( exponent ) : GenericMeasure < N , ExponentiateUnit < U , E > > ; param other returns plus ( other ) : GenericMeasure < N , U > ; param other returns minus ( other ) : GenericMeasure < N , U > ; returns negate ( ) : GenericMeasure < N , U > ; param value returns scale ( value ) : GenericMeasure < N , U > ; param other returns times < V extends MultiplicandUnit < U > > ( other ) : GenericMeasure < N , MultiplyUnits < U , V > > ; param other returns over < V extends DivisorUnit < U > > ( other ) : GenericMeasure < N , DivideUnits < U , V > > ; param other returns per < V extends DivisorUnit < U > > ( other ) : GenericMeasure < N , DivideUnits < U , V > > ; param other returns div < V extends DivisorUnit < U > > ( other ) : GenericMeasure < N , DivideUnits < U , V > > ; returns inverse ( ) : GenericMeasure < N , ExponentiateUnit < U , "-1" > > ; returns reciprocal ( ) : GenericMeasure < N , ExponentiateUnit < U , "-1" > > ; param valueMap param unitMap returns unsafeMap ( fn ) : GenericMeasure < N , U > ; unsafeMap < V extends Unit > ( valueMap , unitMap ) : GenericMeasure < N , V > ; param another returns compare ( other ) : number ; param another returns lt ( other ) : boolean ; param another returns lte ( other ) : boolean ; param another returns eq ( other ) : boolean ; param another returns neq ( other ) : boolean ; param another returns gte ( other ) : boolean ; param another returns gt ( other ) : boolean ; returns toString ( formatter ? ) : string ; param a returns in ( unit , formatter ? ) : string ; param symbol withSymbol ( symbol ) : GenericMeasure < N , U > ; /** Shallow copies this measure instance. */ clone ( ) : GenericMeasure < N , U > ; } example export type LiftMeasure < M extends GenericMeasure < any , any > , N > = M extends GenericMeasure < any , infer U > ? GenericMeasure < N , U > : never ;