diff --git a/src/generate.js b/src/generate.js index e6f6a7b..008906c 100644 --- a/src/generate.js +++ b/src/generate.js @@ -404,7 +404,8 @@ function genRecursion({ref}, state) { Given a `CharacterClassRange` node, returns an array of chars that are a case variant of a char in the range, and aren't already in the range. */ -function getCasesOutsideCharClassRange(node, {firstOnly} = {}) { +function getCasesOutsideCharClassRange(node, options) { + const firstOnly = !!options?.firstOnly; const min = node.min.value; const max = node.max.value; const found = []; diff --git a/src/parse.js b/src/parse.js index d14f848..001bb25 100644 --- a/src/parse.js +++ b/src/parse.js @@ -457,7 +457,8 @@ function createAssertionFromToken({type, kind, negate}) { return node; } -function createBackreference(ref, {orphan} = {}) { +function createBackreference(ref, options) { + const orphan = !!options?.orphan; return { type: AstTypes.Backreference, ...(orphan && {orphan}), @@ -556,7 +557,9 @@ function createFlags({ignoreCase, dotAll, extended}) { }; } -function createGroup({atomic, flags} = {}) { +function createGroup(options) { + const atomic = options?.atomic; + const flags = options?.flags; return { type: AstTypes.Group, ...(atomic && {atomic}), @@ -565,11 +568,16 @@ function createGroup({atomic, flags} = {}) { }; } -function createLookaround({behind = false, negate = false} = {}) { +function createLookaround(options) { + const opts = { + behind: false, + negate: false, + ...options, + }; return { type: AstTypes.Assertion, - kind: behind ? AstAssertionKinds.lookbehind : AstAssertionKinds.lookahead, - negate, + kind: opts.behind ? AstAssertionKinds.lookbehind : AstAssertionKinds.lookahead, + negate: opts.negate, alternatives: [createAlternative()], }; } diff --git a/src/transform.js b/src/transform.js index f2a38e2..472051a 100644 --- a/src/transform.js +++ b/src/transform.js @@ -763,7 +763,8 @@ function isValidGroupNameJs(name) { } // Returns a single node, either the given node or all nodes wrapped in a noncapturing group -function parseFragment(pattern, {skipPropertyNameValidation} = {}) { +function parseFragment(pattern, options) { + const skipPropertyNameValidation = !!options?.skipPropertyNameValidation; const ast = parse(tokenize(pattern), {skipPropertyNameValidation}); const alts = ast.pattern.alternatives; if (alts.length > 1 || alts[0].elements.length > 1) {