@tmlmt/cooklang-parser / UnitDefinition
Interface: UnitDefinition
Represents a fully defined unit with conversion and alias information
Extends
Properties
aliases
aliases:
string[]
e.g. ['gram', 'grams']
fractions?
optionalfractions:UnitFractionConfig
Fraction display configuration
integerProtected?
optionalintegerProtected:boolean
This property is set to true when the unit is prefixed by an = sign in the cooklang file, e.g. =g Indicates that quantities with this unit should be treated as integers only (no decimal/fractional values).
Inherited from
isBestUnit?
optionalisBestUnit:boolean
Whether this unit is a candidate for "best unit" selection (default: true)
maxValue?
optionalmaxValue:number
Maximum value before upgrading to a larger unit (default: 999)
name
name:
string
Inherited from
system
system:
UnitSystem
toBase
toBase:
number
Conversion factor to the base unit of its type (uses default system for ambiguous units)
toBaseBySystem?
optionaltoBaseBySystem:Partial<Record<SpecificUnitSystem,number>>
For ambiguous units: conversion factors for each possible system
type
type:
UnitType