dump() with return possible?

Posted 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():

    >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...

  • E.dumpStr() - dump() was a very early addition, and later things went in the E Object to try not to crowd the global namespace any more :)

  • Oh. Ahem. Yes. Thank you.
    (Why didn't I see this one?)
    Sorry for bothering.

  • neatly spreading code through the puck.js field of mine...

    literally... or envisonally:

    ...neatly spreading code through the puck.js mine field (without getting blown up)?

  • Yeah.
    Already missed a little piezo speaker on the pucks.
    Could do a little rattling sound every time something goes wrong...

    By the way - this is the code: http://forum.espruino.com/conversations/­297473/

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

dump() with return possible?

Posted by Avatar for ChristianW @ChristianW

Actions