Possible to enumerate ALL 'properties' of a JS Global()?

tyler mazaika's icon

tyler mazaika

10月 19 2022 | 11:10 午後

I'm using a JS Global() object to share some data between different Max for Live devices (each of which add some of their own data/properties to the Global.)

For debugging purposes I'd like to be able to print out the entire contents of the Global (much like you might when printing a dictionary). I thought I might be able to do it kinda like this:

var GLBL = new Global( "mynamespace" )
post(GLBL.constructor.name, "\n")
post( Object.getOwnPropertyNames(GLBL), "\n" )
post( Object.keys(GLBL), "\n" )
post( JSON.stringify( GLBL ), "\n" )

However, in any particular device where I run this, it only prints out properties assigned in that same device (assign in that particular instance of the JS file). Is there some magic way to dump the entire contents of a Global?

It's not M4L specific... it seems multiple instances of the same JS script referencing the same Global inside the same .maxpat file not show up either. There's no issue with accessing values assuming I know what properties to look for, but I just can't seem to look up a list of available properties.

Cheers,
Tyler

---------------------------
Also I realize that a Dict() could work for most things I'd want in a Global(), but the syntax is uber-headachy when dealing with hierarchy.

tyler mazaika's icon

tyler mazaika

11月 02 2022 | 11:08 午後

bump? anybody?