Skip to content

formatValue

function formatValue(value, settings?): string;

Defined in: packages/engine/src/format/FormatEngine.ts:267

Render an evaluated Value as a display string, dispatching on value.type to the type-specific formatter (number, hex, datetime, unit of measurement, matrix, range, percentage, …).

Most branches produce a "= "-prefixed result string (matching the plugin’s inline-result convention); ValueType.Error is the one exception, it returns the human-readable error message directly (stored in value.unit), not an "= "-prefixed string.

ParameterTypeDescription
valueValueThe evaluated value to format.
settings?FormattingSettingsLocale/precision/separator options; defaults to DEFAULT_FORMATTING_SETTINGS when omitted.

string

const [value] = engine.evaluateExpression("10 USD to GBP");
formatValue(value); // "= £7.85" (exact output depends on live exchange rates)