-
• #2
Ok, just added a bug for those: https://github.com/espruino/Espruino/issues/522 and https://github.com/espruino/Espruino/issues/523
However, I've got to wonder what you're trying to do on Espruino where you need this? Unfortunately I think at the moment implementation of more JS language features has to take a back seat to fixing problems that users are encountering when they're trying to use it for controlling hardware.
As far as RegEx, I'd like to implement it, but it's a matter of finding a compact RegEx library that implements RegExes per the JS standard and also has a suitable license. I did have a quick look but didn't find one.
The small ones I did find managed to fit into maybe 5k - which would be ok on the Pico, but more of a struggle on the original board.
-
• #3
what you're trying to do on Espruino where you need this?
You have, as example, an opened bug about a comment weird behavior where the user coded via ES3 regular "classes" ... that code contains syntax usable since about ever and it would work everywhere.
I have a simple little module that brings better looking and more semantic classes in and when you deal with hardware you might want to use these patterns too (like the other user did).
Accordingly, having
instanceof
not working as expected is surprising and inconsistent, while I agreepropsrtyIsEnumerable
is a less common method that won't bring much in here.The missing RegExp should at least be mentioned on top of Espruino capabilities (if not already, couldn't find it) ... I often give them for granted, so I might lazily check
/something/.test(command)
instead ofcommand.indexOf(something) > 0
and for cross platform modules is very good to know limit.About that, I wonder what's the process to submit a module to the list of already available one in espruino, in case a working NPM solution would take long time.
Thank you
-
• #4
P.S. you've probably checked it already, but this would be already a great thing to have.
It's MIT Style License, it's deployed in micro controllers, and it's a subset for RegExp, a 1.5 subset.
It's called ure: http://docs.micropython.org/en/latest/library/ure.html#module-ure
Here the module used in micro python:
https://github.com/micropython/micropython/blob/a86d40ccd437fe0235c09426ef6d552b968d86e8/extmod/modure.cand here the folder with the lib:
https://github.com/micropython/micropython/tree/a86d40ccd437fe0235c09426ef6d552b968d86e8/extmod/re1.5 -
• #5
Definitely a bug in
instanceof
is something I want to get fixed quickly. The lack of RegEx is mentioned inhttp://www.espruino.com/FAQ
, but ideally Espruino would recognise them and report that they're not supported at the very least.Thanks for the pointer to URE - it looks good.
As far as submitting modules, there's a page on it here: http://www.espruino.com/Writing+Modules
Including a way of writing them that tends to minimize well and work efficiently with Espruino. You basically just issue a pull request - at the moment the volume of contributions is low enough that it actually works pretty well.
I wouldn't expect
toLocaleString
to be part of theObject.prototype
since there's no local in Espruino, but I found it weirdpropertyIsEnumerable
andisPrototypeOf
are not implemented.A quick and dirty solution would be the following:
However,
instanceof
is also broken in Espruino. Above code uses theconstructor
but a proper check would be the equivalent of the following:Latter check is false but it should be true. Ideally,
isPrototypeOf
andpropertyIsEnumerable
should be implemented natively.Last question for now, I'v enoticed that
RegExp
and in general regular expression /syntax/ is not implemented. Is that too big to bring in natively or it's something planned already?Thanks