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.runningOnStats);
for (var p of Object.getOwnPropertyNames(rs)) {
console.log(p);
console.log(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(stopwatch.runningOnStats), p));
}
The attached file is a more explicit result and execution trace of what this gave to me.
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.
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
The attached file is a more explicit result and execution trace of what this gave to me.
1 Attachment