Feature: Add more useful/modern eel helper methods (see es2020)
This list can become endless but a good start would be to have these readily at hand:
String.includes()
Array.includes()
The spec of the to be added methods should be taken from MDN docs as usual.
Do you know if it is still relevant? Can I prepare PR for that?
oh yes very much :D id love to see a pr @NamioL ❤️
I still have an conceptual question here..
If we stick to the JS interfaces, as suggested, we are missing handy options like the $strict parameter of in_array()
- could we include the $strict parameter anyway, just after $fromIndex?
- we could also add another Helper
Array.includesStrict() - should we have two different versions, one according to the PHP interface and one according to the JS interface? I doubt that, but with
String.substring()andString.substr()we have exactly the same.
My opinion: If there are similar functions in PHP and JS, I would combine the parameters as in the first bullet. and if they are incompatible, like substring/substr I would keep or add both.
hmm regarding flags. I always dislike flags. Especially when designing an API or encapsulating lower level internals which we do here i think we should really have to expose a feature alternating flag. For most if not many cases it would be in my opinion much better to set a sane default which should be strict mode for array_includes by default.
About substr vs substring according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr both actually existed but substr is deprecated.
So we should definitely always check against https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array etc ;)