Honestly, I'm not sure. Mainly it'll be allocating the string, so:
var evalneed='How much is needed for eval ?';
var cmd = `var x = E.toString(ST.read(".bootcde")); ST.eraseAll(); ST.write(".bootcde",x); console.log("survived");'
if (x===undefined) { throw new Error("Not enough RAM for .bootcde"); }
else {
evalneed=''; // Required for eval
// Ugly hack !
eval(cmd);
// Here i do a reset via my custom watchdog function.
}
would probably be pretty safe.
Or... you could just do:
eval('var x = E.toString(ST.read(".bootcde")); if (x===undefined) throw new Error("Not enough RAM for .bootcde"); ST.eraseAll(); ST.write(".bootcde",x); console.log("survived");');
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.
Honestly, I'm not sure. Mainly it'll be allocating the string, so:
would probably be pretty safe.
Or... you could just do:
Which might be tidier/safer?