Executing dump() logs the current interpreter state to the console.
Is there a way to get the same output in a variable?
I can do this for a single function via toString():
>function foo() {
: var bar = 123;
: return bar;
:}
=function () { ... }
=undefined
>var code = foo.toString();
="function () {\n v" ... ";\n return bar;\n}"
=undefined
>console.log( code );
function () {
var bar = 123;
return bar;
}
=undefined
How can I do the same with the whole interpreter state?
PS: Warning - this is the perfect foundation for writing the first puck.js worm - which I intend to do ;-)
PS2: ...not for harming anyone, but for neatly spreading code through the puck.js field of mine...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Executing
dump()
logs the current interpreter state to the console.Is there a way to get the same output in a variable?
I can do this for a single function via toString():
How can I do the same with the whole interpreter state?
PS: Warning - this is the perfect foundation for writing the first puck.js worm - which I intend to do ;-)
PS2: ...not for harming anyone, but for neatly spreading code through the puck.js field of mine...