Open DmitrySoshnikov opened 7 years ago
Is this still the latest on this issue? Named capture groups would be a game changer for me, and I can try to find time to work on this if it's still the preferred strategy.
@mike-marcacci, yes, would be great to add this, and I agree, actual usage of the groups is a game changer. We can discuss any strategy here, those described above are just an example, I'm happy to consider any alternatives you have. And of course I'll appreciate a PR.
CC @nicolo-ribaudo who was trying to add a PR to Babel, but the https://github.com/babel/babel/pull/7105 PR itself seems stuck there forever, so we can add it here.
Yeah sorry, currently I'm working on decorators which are a more requested feature. I will revisit that PR after them.
As the comments says, a transform can accept
includeRuntime
option (which is currently disabled).If the option is passed, regexes are wrapped into
RegExpTree
wrapper, and provide extra functionality at runtime (e.g. accessing captured named groups on matched result).The runtime implementation already exists, we need to pull it into a separate package, which can be auto-required by the transform.
Is translated into: