Yes @juntiedt has explained, slightly differently, how to call such a function from a function node.
What I asked though was if there is a way to call it from a change node.
(eg using the "global...." output type)
Perhaps I should explain why I ask.
There has been some discussion around formatting numbers for Dashboard 2, equivalent to the mustache feature of Dashboard 1 {{ payload | number:2 }} °C
The "approved" way to format like that is to use a (not ui_) template node, but it cannot achieve the rounding to 2 places. The work-around is Jsonata in a change node.
You can define a function
context.global.formatnumber = function runtime_str(number, dp, prefix, suffix)
{
return (prefix + number.toFixed(dp) + suffix);
}
and call it from a function node as
msg.payload = context.global.formatnumber(input, 2, "£ ", " million");
If this global function could be accessed from a change node, or even a template, it would permit the value formatting without Jsonata.