(match: RegExpMatchArray, index: number, str: string)
| 1430 | /** @internal */ |
| 1431 | _replaceRegexp(searchValue: RegExp, replacement: string | ReplacementFunction): this { |
| 1432 | function getReplacement(match: RegExpMatchArray, index: number, str: string): string { |
| 1433 | if (typeof replacement === 'string') { |
| 1434 | return expandReplacement( |
| 1435 | replacement, |
| 1436 | match[0], |
| 1437 | index, |
| 1438 | str, |
| 1439 | match.slice(1), |
| 1440 | match.groups, |
| 1441 | ) |
| 1442 | } |
| 1443 | else { |
| 1444 | // `String.prototype.replace` only passes the named-capture-groups object |
| 1445 | // when the pattern actually has named groups - passing an `undefined` |
| 1446 | // there unconditionally shifts the last argument a replacer sees |
| 1447 | return match.groups === undefined |
| 1448 | ? replacement(match[0], ...match.slice(1), index, str) |
| 1449 | : replacement(match[0], ...match.slice(1), index, str, match.groups) |
| 1450 | } |
| 1451 | } |
| 1452 | // Returns true once a surviving match has been handled, so a non-global |
| 1453 | // search can stop at the first match still present in the output. |
| 1454 | const replaceMatch = (match: RegExpMatchArray): boolean => { |
nothing calls this directly
no test coverage detected