UNPKG

messageformat

Version:

Intl.MessageFormat / Unicode MessageFormat 2 parser, runtime and polyfill

18 lines (17 loc) 645 B
import { resolveFunctionRef } from "./resolve-function-ref.js"; import { resolveLiteral } from "./resolve-literal.js"; import { resolveVariableRef } from "./resolve-variable.js"; export function resolveExpression(ctx, { arg, functionRef }) { if (functionRef) { return resolveFunctionRef(ctx, arg, functionRef); } switch (arg?.type) { case 'literal': return resolveLiteral(ctx, arg); case 'variable': return resolveVariableRef(ctx, arg); default: // @ts-expect-error - should never happen throw new Error(`Unsupported expression: ${arg?.type}`); } }