mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
* Expand static three.js workflows and host integration * Preserve JavaScript class state in static three.js workflows * Preserve inferred JavaScript behavior across static workflows * Preserve inferred callables and native compatibility boundaries * Retain annotated JavaScript factory exports and bootstrap-safe call spreads * Preserve Buffer and child callback identities in static packages * Clarify JavaScript symbol spread support
15 lines
727 B
TypeScript
15 lines
727 B
TypeScript
const expression = /^(a)?(b*)$/;
|
|
for (const input of ["", "b", "ab"]) {
|
|
const match = expression.exec(input);
|
|
if (match === null) throw new Error("missing match");
|
|
console.log(input, JSON.stringify(match), match[1] === undefined, match[2] === "", 1 in match);
|
|
const matched = input.match(expression);
|
|
console.log(JSON.stringify(matched));
|
|
}
|
|
for (const match of "b ab".matchAll(/(a)?(b)/g)) {
|
|
console.log(JSON.stringify(match), match[1] === undefined, 1 in match);
|
|
}
|
|
const named = /(?<prefix>a)?(?<empty>b*)/.exec("")!.groups!;
|
|
console.log(named.prefix === undefined, named.empty === "", JSON.stringify(named), Object.keys(named).join(","));
|
|
console.log(/(?<value>a*)x|(?<value>b)/.exec("x")!.groups!.value === "");
|