Skip to content

Commit

Permalink
feat(langs-precompiled): mark EmulatedRegExp as pure
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 15, 2025
1 parent d82af15 commit 11ef0cd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1,325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ exports[`precompile 1`] = `
],
},
},
end: new EmulatedRegExp("(?<=^|\\\\n(?!$))(?=\\\\P{space})|(?!^)", "dgv", {
strategy: "search_start_clip",
}),
end: /*@__PURE__*/ new EmulatedRegExp(
"(?<=^|\\\\n(?!$))(?=\\\\P{space})|(?!^)",
"dgv",
{ strategy: "search_start_clip" },
),
patterns: [
{
begin: /(?<=^|\\n(?!$))([ ]+)(?! )/dgv,
Expand All @@ -112,7 +114,7 @@ exports[`precompile 1`] = `
beginCaptures: {
"1": { name: "punctuation.whitespace.comment.leading.yaml" },
},
end: new EmulatedRegExp("(?!^)", "dgv", {
end: /*@__PURE__*/ new EmulatedRegExp("(?!^)", "dgv", {
strategy: "search_start_clip",
}),
patterns: [
Expand Down Expand Up @@ -377,7 +379,7 @@ exports[`precompile 1`] = `
node: { patterns: [{ include: "#block-node" }] },
property: {
begin: /(?=!|&)/dgv,
end: new EmulatedRegExp("(?!^)", "dgv", {
end: /*@__PURE__*/ new EmulatedRegExp("(?!^)", "dgv", {
strategy: "search_start_clip",
}),
name: "meta.property.yaml",
Expand Down
2 changes: 1 addition & 1 deletion packages/langs-precompiled/scripts/langs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function toJsLiteral(value: any, seen = new Set()): string {
}

if (value instanceof EmulatedRegExp) {
return `new EmulatedRegExp(${JSON.stringify(value.rawArgs.pattern)},${JSON.stringify(value.rawArgs.flags)},${JSON.stringify(value.rawArgs.options)})`
return `/*@__PURE__*/ new EmulatedRegExp(${JSON.stringify(value.rawArgs.pattern)},${JSON.stringify(value.rawArgs.flags)},${JSON.stringify(value.rawArgs.options)})`
}

// RegExp
Expand Down
Loading

0 comments on commit 11ef0cd

Please sign in to comment.