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

Move to options object APIs #109

Open
slevithan opened this issue Sep 27, 2015 · 0 comments
Open

Move to options object APIs #109

slevithan opened this issue Sep 27, 2015 · 0 comments

Comments

@slevithan
Copy link
Owner

slevithan commented Sep 27, 2015

  • Allow an options object as the first optional argument for XRegExp.exec/test/replace/match/forEach, and allow an options object for each XRegExp.replaceEach replacement array.
    • This will replace or overload/supersede the following optional arguments: pos and sticky of XRegExp.exec/test, scope of XRegExp.replace/match, and the third value (scope) of each XRegExp.replaceEach replacement array.
    • Since XRegExp.replace's current scope argument is infrequently used (it's more common to set scope via flag g on the provided regex), it might make sense to not overload the scope argument but instead just replace it. Same for XRegExp.replaceEach arrays.

New features planned after and enabled by moving to options object APIs:

  • To enable common lookbehind tasks (where lookbehind is used at the start of the pattern), add follows and doesNotFollow (or precededBy and notPrecededBy) to the options objects of XRegExp.exec/test/match/forEach. These would expect regex objects. follows would be used like positive lookbehind, and doesNotFollow like negative lookbehind.
  • Add support for pos and sticky to XRegExp.match/forEach, via their options objects.
    • Cleanup: After adding pos and sticky to XRegExp.match, search for XRegExp.exec(…, …, pos, 'sticky')[0] and replace with XRegExp.match(…, …, {pos: pos, sticky: true, scope: 'one'}).
  • Add support for pos, sticky, and scope to XRegExp.matchRecursive, via its existing options object.
    • Note that matchRecursive already supports the handling of scope via flag g, and sticky via flag y. These flags should be superseded by pos and sticky, the same way that scope supersedes flag g with XRegExp.replace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant