Using simpler globar variables `RED.f.myVar`

As Steve pointed out, typeof is not going to work due to the use of the node.js VM for the function node. Here is the code I was using to test the types:


const roundTrip = flow.get('complexObj')
// node.warn(JSON.serialize(Object.keys(roundTrip)))

node.warn(`bigint > max safe integer?: ${roundTrip.specials.bigint > Number.MAX_SAFE_INTEGER}`)
// Have to use constructor names not typeof because we are in a VM?
node.warn(`constructor of map?: ${roundTrip.specials.map.constructor.name}`)
node.warn(`constructor of set?: ${roundTrip.specials.set.constructor.name}`)
node.warn(`constructor of error?: ${roundTrip.specials.error.constructor.name}`)
node.warn(`constructor of arrayBuffer?: ${roundTrip.specials.arrayBuffer.constructor.name}`)
node.warn(`constructor of weakmap?: ${roundTrip.specials.weakmap?.constructor?.name}`)

return { payload: roundTrip }

The constructor name for Map is Map :smiley:

Node.js does also have a types function in its node:utils library which should identify Map's correctly. However, again, the VM gets in the way. Just to note that the saferSerialize function from uibuilder does use the utils library and it is working fine in function nodes because the function actually comes from the uibuilder plugin via the RED.util object.