-
Shouldn't be too hard to implement, should it? :)
Here you go https://github.com/espruino/Espruino :)
Now I regret saying that :) It came off wrong, sorry if it sounded like writing features for Espruino is easy! I'm sure it would take many hours to implement this, and I know you're not getting paid by the hour to work on Espruino. Instead I should thank you for making and continuously improving Espruino for free, and for providing such great support!
I looked around for JS polyfills for
Map
andSet
, and found one that was used by Firefox Nightly and Chrome Dev when the features were under the Enable Experimental JavaScript flag. It's also the smallest that I found (6KB, 2.77KB minified) and claims to have good performance.https://github.com/WebReflection/es6-collections
https://raw.githubusercontent.com/WebReflection/es6-collections/master/index.jsAs far as I can tell, it actually does roughly what your bodged up implementation does :)
I tested it on a Pico (had to move the exported functions to the bottom) and it seems to work fine, except for two issues:
- Although it shims iterators, Espruino doesn't support iterators or
for…of
(good point!) - The
.size
property is missing (requires support for getters inObject.defineProperty
)
https://gist.github.com/joakim/e70a8c1bb82b3cce32092cccfb99701d
Despite those issues, I'll give it a try on a project I'm working on later and see how it goes.
- Although it shims iterators, Espruino doesn't support iterators or
Here you go https://github.com/espruino/Espruino :)
Would it not be possible to write
Map
andSet
as a JavaScript module though? I'm not sure they actually require interpreter support.