Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE add includes Eel Helpers for String and Array #3359

Open
wants to merge 1 commit into
base: 8.4
Choose a base branch
from

Conversation

Kleisli
Copy link
Contributor

@Kleisli Kleisli commented Jun 1, 2024

resolved:#2967
Added two new EelHelpers following the interface of the JavaScript functions String.prototype.includes() and Array.prototype.includes()

Upgrade instructions

Review instructions

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

@github-actions github-actions bot added the 8.3 label Jun 1, 2024
@mhsdesign mhsdesign marked this pull request as draft June 2, 2024 19:59
@mhsdesign mhsdesign removed the 8.3 label Jun 2, 2024
@mhsdesign
Copy link
Member

mhsdesign commented Jun 2, 2024

FYI just made this wip because it has to land in 8.4 but were working on branching it of

@mhsdesign mhsdesign changed the base branch from 8.3 to 8.4 June 22, 2024 17:03
@github-actions github-actions bot added the 8.4 label Jun 22, 2024
Copy link
Member

@mhsdesign mhsdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!. I havent checked but the includes was just an example case.
Are there more helpful helpers that were missing?

Also i think we talked about that String.substr is deprecated in ecmascript and we should probably also add all deprecations like this here.

Or if you dont have the time for it we could of course only include those two helpers ... ^^

if ($array instanceof \Traversable) {
$array = iterator_to_array($array);
}
return in_array($searchElement, (array)array_slice($array, $fromIndex));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use the 3 param (strict) to true or is the proposed way closer to ECMASCRIPT?

... also the (array) casts looks a little weird and im wondering in general if we should optimize and early return for the fromIndex=0 case?

@mhsdesign mhsdesign marked this pull request as ready for review June 22, 2024 17:10
@kdambekalns kdambekalns changed the title FEATURE add includes Eel Helpers for String and Array FEATURE add includes Eel Helpers for String and Array Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants