I've just dropped some RegExp check and polyfilled internally what was missing in Espruino, in case you'd like to have ES6 alike syntax for classes, with ES7 ability to compose through mixins/traits, I'd like to link you at this project of mine, called es-class
The minified version is not hand crafted/compacted explicitly for Espruino, but with plain 3.5kB (1.6kB gzipped) you get granted cross platform compatibility, including the MIPS node version of Arduino Yun, and basically all other JS engines out there I could verify.
Key features are:
semantic Class({..}) declaration
extends and handy this.super(...) ability
static properties definitions
bonus for mixins/traits via with: [ ... ] plus implements for light checks on expected interfaces
As Gordon asked me in another thread, you ain't gonna need probably all these features, but maybe you'd like to write some code that looks like modern JS without breaking your Espruino.
Performance are also as good as vanilla JS, only light overhead is classes definitions, luckily this happens only once at bootstrap so you won't probably notice that.
All tests are green except those based on ES3 non standard get/set literal objects syntax which is not implemented here, and some tiny instanceof gotcha that will hopefully be solved soon since Gordon has already a bug to work on.
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.
I've just dropped some RegExp check and polyfilled internally what was missing in Espruino, in case you'd like to have ES6 alike syntax for classes, with ES7 ability to compose through mixins/traits, I'd like to link you at this project of mine, called es-class
The minified version is not hand crafted/compacted explicitly for Espruino, but with plain 3.5kB (1.6kB gzipped) you get granted cross platform compatibility, including the MIPS node version of Arduino Yun, and basically all other JS engines out there I could verify.
Key features are:
Class({..})
declarationextends
and handythis.super(...)
abilitystatic
properties definitionswith: [ ... ]
plusimplements
for light checks on expected interfacesAs Gordon asked me in another thread, you ain't gonna need probably all these features, but maybe you'd like to write some code that looks like modern JS without breaking your Espruino.
Performance are also as good as vanilla JS, only light overhead is classes definitions, luckily this happens only once at bootstrap so you won't probably notice that.
All tests are green except those based on ES3 non standard get/set literal objects syntax which is not implemented here, and some tiny
instanceof
gotcha that will hopefully be solved soon since Gordon has already a bug to work on.I hope someone will find it handy.
Best Regards