⚠️ This is pre-release documentation for v3. For stable docs, visit v2.
Skip to content

@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?

optional fractions: UnitFractionConfig

Fraction display configuration


integerProtected?

optional integerProtected: 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

Unit.integerProtected


isBestUnit?

optional isBestUnit: boolean

Whether this unit is a candidate for "best unit" selection (default: true)


maxValue?

optional maxValue: number

Maximum value before upgrading to a larger unit (default: 999)


name

name: string

Inherited from

Unit.name


system

system: UnitSystem


toBase

toBase: number

Conversion factor to the base unit of its type (uses default system for ambiguous units)


toBaseBySystem?

optional toBaseBySystem: Partial<Record<SpecificUnitSystem, number>>

For ambiguous units: conversion factors for each possible system


type

type: UnitType