Translate v0 #{} to v1 JS{{}}

Hi,

I use a lot of the following code to get address data and pass it to children widgets:

#{
  status = OSC{/@{parent.variables.root}/@{parent.variables.n}/feedback/status};
  extend(@{parent.variables}, {"status": status})
}

How would you do with v1 syntax ?

Hi,

  • the plain javascript equivalent for the former extend function is Object.assign (see here for the other functions that were added to the MathJs syntax in v0)
  • a return statement must be used to determine the returned value
  • variables must be declared with a var statement

Copy to clipboard

JS{{

  var status = OSC{/@{parent.variables.root}/@{parent.variables.n}/feedback/status};
  return Object.assign(@{parent.variables}, {"status": status})

}}
1 Like

Thank you! I figured out the rest, the link you gave me is gonna be extremely useful!