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

Use native RegExp Match indices #1652

Merged
merged 7 commits into from
Jul 12, 2021
Merged

Use native RegExp Match indices #1652

merged 7 commits into from
Jul 12, 2021

Conversation

aslakhellesoy
Copy link
Contributor

@aslakhellesoy aslakhellesoy commented Jul 10, 2021

Summary

Use RegExpExecArray#indices to get the position of capture groups.

Details

This PR removes the dependency on the becke-ch--regex--s0-0-v1--base--pl--lib library and uses RegExpExecArray#indices instead.

RegExp Match Indices were introduced in v8 v9.0.259. The first Node.js release to use a v8 newer than that is 16.4.0.

Since we cannot drop support for Node.js < 16.4.0 until 2023/2024, the implementation currently uses a polyfill.

Motivation and Context

The main motivation for this change is to stop depending on http://www--s0-v1.becke.ch/tool/becke-ch--regex--s0-v1/becke-ch--regex--s0-0-v1--homepage--pl--client/, which seems to be a liability to depend on because it doesn't seem to have a public Git repo, except for this fork.

I would also expect this to be slightly more performant since it's based on a native implementation, but I doubt it will be significant for end users.

Also see #300

How Has This Been Tested?

The tests pass on Node v16.4.2, but I doubt it will pass on Node < 16.4.0 as explained above.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • The change has been ported to Java.
  • The change has been ported to Ruby.
  • The change has been ported to JavaScript.
  • The change has been ported to Go.
  • The change has been ported to .NET.
  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have updated the CHANGELOG accordingly.

@aslakhellesoy aslakhellesoy added ⚡ enhancement Request for new functionality library: cucumber-expressions language: javascript 🧷 pinned Tells Stalebot not to close this issue labels Jul 10, 2021
@aslakhellesoy aslakhellesoy changed the title Use native RegExp#indices Use native RegExp Match indices Jul 10, 2021
@aslakhellesoy
Copy link
Contributor Author

Update: I added the polyfill so we don't have to wait until 2023/2024 to merge this.

@aslakhellesoy aslakhellesoy removed the 🧷 pinned Tells Stalebot not to close this issue label Jul 10, 2021
Copy link
Contributor

@aurelien-reeves aurelien-reeves left a comment

Choose a reason for hiding this comment

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

👍

@mattwynne
Copy link
Member

👍

If we're using the polyfill let's edit the text in the PR to reflect that and remove the warnings.

@aslakhellesoy
Copy link
Contributor Author

PR text updated

@aslakhellesoy aslakhellesoy merged commit 66f4e1a into main Jul 12, 2021
@aslakhellesoy aslakhellesoy deleted the native-regexp-indices branch July 12, 2021 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language: javascript ⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants