unacy / UnitMetadata
Interface: UnitMetadata
Defined in: packages/core/src/types.ts:508
Display and descriptive metadata that can be attached to units in the registry.
Supports common properties like abbreviation, format template, description, and symbol, plus an index signature for arbitrary custom fields.
Remarks
UnitMetadata is the internal store type used by ConverterRegistryImpl. Access registered metadata via the unit accessor: registry.Celsius.symbol, registry.Celsius.abbreviation, etc.
Example
typescript
const registry = createRegistry()
.register({
name: 'Celsius' as const,
symbol: '°C',
abbreviation: '°C',
description: 'Degrees Celsius',
});
registry.Celsius.symbol; // '°C'
registry.Celsius.description; // 'Degrees Celsius'Config
symbol— SI / conventional symbol (e.g.,'°C','m','kg')abbreviation— short display abbreviationformat— optional format template stringdescription— human-readable description[key: string]— any additional custom fields
Use When
You want to attach human-readable labels or display hints to a unit so consumers can render values without hard-coding strings.
Indexable
ts
[key: string]: unknownAllow arbitrary custom metadata properties
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
abbreviation? | string | Short abbreviation for the unit (e.g., "°C", "m", "kg") | packages/core/src/types.ts:510 |
description? | string | Human-readable description of the unit | packages/core/src/types.ts:514 |
format? | string | Format string for displaying values (e.g., "${value}°C") | packages/core/src/types.ts:512 |
symbol? | string | Symbol representation of the unit | packages/core/src/types.ts:516 |