MCPcopy
hub / github.com/evanw/esbuild / regExpFeatures

Function regExpFeatures

scripts/js-api-tests.js:7468–7505  ·  view source on GitHub ↗
({ esbuild })

Source from the content-addressed store, hash-verified

7466 },
7467
7468 async regExpFeatures({ esbuild }) {
7469 const check = async (target, input, expected) =>
7470 assert.strictEqual((await esbuild.transform(input, { target })).code, expected)
7471
7472 await Promise.all([
7473 // RegExpStickyAndUnicodeFlags
7474 check('es6', `x1 = /./y`, `x1 = /./y;\n`),
7475 check('es6', `x2 = /./u`, `x2 = /./u;\n`),
7476 check('es5', `x3 = /./y`, `x3 = new RegExp(".", "y");\n`),
7477 check('es5', `x4 = /./u`, `x4 = new RegExp(".", "u");\n`),
7478
7479 // RegExpDotAllFlag
7480 check('es2018', `x1 = /a.b/s`, `x1 = /a.b/s;\n`),
7481 check('es2017', `x2 = /a.b/s`, `x2 = new RegExp("a.b", "s");\n`),
7482
7483 // RegExpLookbehindAssertions
7484 check('es2018', `x1 = /(?<=x)/`, `x1 = /(?<=x)/;\n`),
7485 check('es2018', `x2 = /(?<!x)/`, `x2 = /(?<!x)/;\n`),
7486 check('es2017', `x3 = /(?<=x)/`, `x3 = new RegExp("(?<=x)");\n`),
7487 check('es2017', `x4 = /(?<!x)/`, `x4 = new RegExp("(?<!x)");\n`),
7488
7489 // RegExpNamedCaptureGroups
7490 check('es2018', `x1 = /(?<a>b)/`, `x1 = /(?<a>b)/;\n`),
7491 check('es2017', `x2 = /(?<a>b)/`, `x2 = new RegExp("(?<a>b)");\n`),
7492
7493 // RegExpUnicodePropertyEscapes
7494 check('es2018', `x1 = /\\p{Emoji}/u`, `x1 = /\\p{Emoji}/u;\n`),
7495 check('es2017', `x2 = /\\p{Emoji}/u`, `x2 = new RegExp("\\\\p{Emoji}", "u");\n`),
7496
7497 // RegExpMatchIndices
7498 check('es2022', `x1 = /y/d`, `x1 = /y/d;\n`),
7499 check('es2021', `x2 = /y/d`, `x2 = new RegExp("y", "d");\n`),
7500
7501 // RegExpSetNotation
7502 check('es2024', `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v;\n`),
7503 check('es2022', `x2 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x2 = new RegExp("[\\\\p{White_Space}&&\\\\p{ASCII}]", "v");\n`),
7504 ])
7505 },
7506
7507 // Future syntax
7508 nonIdArrayRest: ({ esbuild }) => futureSyntax(esbuild, 'let [...[x]] = y', 'es2015', 'es2016'),

Callers

nothing calls this directly

Calls 1

checkFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…