• Hi,
    I would like to share this as I had some difficulties some weeks ago and got out of trouble using this:

    Here is a recipe to extract the class definition of an object in the console pane.

    I used it on a running Espruino Pico which had an objet stopwatch.runningOnStats saved but could not get its source defintion from dump().
    It was no more available in the WebIde editor pane because I had wiped it and saved without seeing this before... So I had lost all of the source code for the class runningOnStats property of stopwatch

    In the following case, stopwatch.runningOnStats is the object which we want to get the defintion on the console.
    We will have to copy/paste/edit the result from the console to get it in a source form

    
    var rs=Object.getPrototypeOf(stopwatch.runni­ngOnStats);
    for (var p of Object.getOwnPropertyNames(rs)) {
      console.log(p);
      console.log(Object.getOwnPropertyDescrip­tor(Object.getPrototypeOf(stopwatch.runn­ingOnStats), p));
    }
    
    

    The attached file is a more explicit result and execution trace of what this gave to me.


    1 Attachment

About

Avatar for asez73 @asez73 started