15 lines
668 B
TypeScript
15 lines
668 B
TypeScript
export type UnitType = 'weight' | 'volume' | 'cooking' | 'piece' | 'other';
|
|
export interface UnitDefinition {
|
|
value: string;
|
|
labelSv: string;
|
|
type: UnitType;
|
|
toBaseFactor: number;
|
|
aliases: string[];
|
|
}
|
|
export declare const UNIT_DEFINITIONS: UnitDefinition[];
|
|
export declare function normalizeUnit(unit: string): string;
|
|
export declare function getUnitDefinition(unit: string): UnitDefinition | undefined;
|
|
export declare function getUnitType(unit: string): UnitType | null;
|
|
export declare function canConvert(fromUnit: string, toUnit: string): boolean;
|
|
export declare function convertUnit(quantity: number, fromUnit: string, toUnit: string): number;
|