Skip to content

Commit

Permalink
Capture transfer uses from array
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Jan 31, 2025
1 parent 2958ed8 commit 96a17d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/atomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ function atomic(expression, data) {
incrementIfAtLeast(hiddenCaptures, addedCaptureNum);
if (captureTransfers.size) {
const newCaptureTransfers = new Map();
captureTransfers.forEach((/** @type {number} */ from, /** @type {number | string} */ to) => {
captureTransfers.forEach((from, to) => {
newCaptureTransfers.set(
// `to` can be a group number or name
to >= addedCaptureNum ? to + 1 : to,
from + (from >= addedCaptureNum ? 1 : 0)
from.map(f => f >= addedCaptureNum ? f + 1 : f)
);
});
captureTransfers = newCaptureTransfers;
Expand Down
4 changes: 2 additions & 2 deletions src/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {Context, hasUnescaped, replaceUnescaped} from 'regex-utilities';
@typedef {string | RegExp | Pattern | number} InterpolatedValue
@typedef {{
flags?: string;
captureTransfers?: Map<number | string, number>;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
}} PluginData
@typedef {{
pattern: string;
captureTransfers?: Map<number | string, number>;
captureTransfers?: Map<number, Array<number>>;
hiddenCaptures?: Array<number>;
}} PluginResult
@typedef {TemplateStringsArray | {raw: Array<string>}} RawTemplate
Expand Down

0 comments on commit 96a17d4

Please sign in to comment.