Thank you very much for your quick response!
Documentation wants me to write a module to storage in the following way:
require('Storage').write('SmokeTest',` exports.getAnswer = function () { return 42; } `);
i.e., obviously un-minified and not pre-tokenized.
Could I use the following approach instead?
let exports = {}; exports.getAnswer = function () { for (let i = 0, j = 0; i < 1000; i++) { j++; // just consume some time... } return 42; }; let ModuleSource = ''; for (let Key in exports) { if (exports.hasOwnProperty(Key)) { ModuleSource += 'exports.' + Key + '=' + exports[Key] + ';'; } } require('Storage').write('SmokeTest',ModuleSource);
If I just print the contents of ModuleSource, I get
print
ModuleSource
exports.getAnswer=function () {for(let i=0,j=0;i<1000;i++){j++;}return 42;}
which looks quite promising (in terms of minification, at least)...
@Andreas_Rozek started
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.
Thank you very much for your quick response!
Documentation wants me to write a module to storage in the following way:
i.e., obviously un-minified and not pre-tokenized.
Could I use the following approach instead?
If I just
print
the contents ofModuleSource
, I getwhich looks quite promising (in terms of minification, at least)...