import type { NodeDef } from '../../NodeRegistry'; import { asNumber } from '../../values'; import { any, num, str } from '../shared'; export const ToText: NodeDef = { type: 'ToText', label: 'To text', category: 'data', description: 'Turns a number into text with a fixed number of decimals.', inputs: [any('value'), num('decimals')], outputs: [str('text')], params: [], run: (_ctx, inputs) => { const value = inputs.value; const decimals = Math.max(0, Math.min(10, Math.floor(asNumber(inputs.decimals)))); return { outputs: { text: typeof value === 'string' ? value : asNumber(value).toFixed(decimals) } }; }, };