CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-babel-plugin-transform-es2015-sticky-regex

tessl install tessl/npm-babel-plugin-transform-es2015-sticky-regex@6.24.0

Babel plugin that transforms ES2015 sticky regex literals to ES5-compatible RegExp constructor calls

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.03x

Baseline

Agent success rate without this tile

97%

task.mdevals/scenario-2/

Sticky Regex Transpiler

Build a helper that emits source compatible with runtimes lacking sticky regex support by running a transform that rewrites sticky regex literals into RegExp constructor calls with string-literal pattern and flag arguments.

Capabilities

Converts sticky regex literals

  • Source const r = /foo/y; export default r.test("foofoo"); is transformed to code that uses new RegExp("foo", "y") in place of the literal while keeping surrounding code intact. @test

Preserves other flags on sticky regex

  • Source const r = /f.o/my; r.exec("f\no"); yields a constructor call whose flag string still includes both multiline and sticky semantics. @test

Leaves non-sticky regex unchanged

  • Source containing const plain = /bar/g; remains the same literal after transformation. @test

Implementation

@generates

API

export function transformStickyRegex(sourceCode: string): string;

The function accepts JavaScript source code and returns the transformed source text.

Dependencies { .dependencies }

@babel/core { .dependency }

Provides the transform pipeline used to run the plugin. @satisfied-by

@babel/plugin-transform-sticky-regex { .dependency }

Rewrites sticky regex literals into RegExp constructor calls using string-literal pattern and flags. @satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/babel-plugin-transform-es2015-sticky-regex@6.24.x
tile.json