Typings — Number
Package:
@litert/utils-numberSource: packages/partials/number/src/Classes/UnitConverter.ts
Import
ts
import type { Units } from '@litert/utils-number';IUnit<T>
Describes a single unit with a name and a conversion factor relative to the base unit of a UnitConverter.
ts
interface IUnit<T extends string | number> {
name: T;
factor: number;
}| Property | Type | Description |
|---|---|---|
name | T | The name or symbol of the unit (e.g., 'km', 'gb') |
factor | number | Conversion factor relative to the base unit — how many base units equal 1 of this unit |
IUnitConverterOptions<T>
Constructor options for UnitConverter<T>.
ts
interface IUnitConverterOptions<T extends string | number> {
baseUnit: T;
units: Array<IUnit<T>>;
}| Property | Type | Description |
|---|---|---|
baseUnit | T | The reference unit; all other unit factors are relative to this |
units | Array<IUnit<T>> | Derived units, each with an absolute factor relative to baseUnit. Use UnitConverter.makeUnitsByFactor to generate geometric series |