import { Decimal } from 'decimal.js'; import { SymbolTable } from '../evaluator/symboltable'; declare type callbackFuncFmt = () => Decimal | number; /** * IUseUnit * Interface for UseUnit functions param */ interface IUseUnit { id: string; type: string; ratio: Decimal | number | string | callbackFuncFmt; bias?: Decimal | number | string | callbackFuncFmt; phrases: string[]; singular?: string; plural?: string; } declare class UnitMeta { id: string; r: Decimal | callbackFuncFmt; b: Decimal | callbackFuncFmt; unitType: string; singular: string; plural: string; constructor(id: string, ratio: Decimal | callbackFuncFmt, unitType: string); get ratio(): Decimal; get bias(): Decimal; setBias(value: Decimal | callbackFuncFmt): void; setPlural(value: string): void; setSingular(value: string): void; } /** * Represents unit with info */ declare class Unit { phrases: string[]; meta: UnitMeta; constructor(id: string, ratio: Decimal | number | string | callbackFuncFmt, unitType: string, phrases: string[]); setBias(value: Decimal | number | string | callbackFuncFmt): Unit; Plural(value: string): Unit; Singular(value: string): Unit; } declare namespace Unit { const LENGTH_ID = "LENGTH"; const SPEED_ID = "SPEED"; const TIME_ID = "TIME"; const TEMPERATURE_ID = "TEMPERATURE"; const MASS_ID = "MASS"; const DIGITAL_ID = "DIGITAL STORAGE"; /** * List of {Unit} sunits */ class List { symbolTable: SymbolTable; units: Map; constructor(symbolTable: SymbolTable); /** * Add a new unit * @param {Unit} unit * @throws {FcalError} Error if phrases already exists */ push(unit: Unit): void; /** * get the unit by its phrase * @param {string} phrase * @returns {UnitMeta | null } */ get(phrase: string): UnitMeta | null; } } export { Unit, UnitMeta, callbackFuncFmt, IUseUnit };