flow-development-collection icon indicating copy to clipboard operation
flow-development-collection copied to clipboard

Feature: Add more useful/modern eel helper methods (see es2020)

Open mhsdesign opened this issue 3 years ago • 4 comments

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.

mhsdesign avatar Feb 24 '23 22:02 mhsdesign

Do you know if it is still relevant? Can I prepare PR for that?

NamioL avatar Sep 30 '23 19:09 NamioL

oh yes very much :D id love to see a pr @NamioL ❤️

mhsdesign avatar Oct 09 '23 07:10 mhsdesign

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() and String.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.

Kleisli avatar Jun 01 '24 13:06 Kleisli

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 ;)

mhsdesign avatar Jun 02 '24 10:06 mhsdesign