(match: RegExpMatchArray)
| 1457 | // Returns true once a surviving match has been handled, so a non-global |
| 1458 | // search can stop at the first match still present in the output. |
| 1459 | const replaceMatch = (match: RegExpMatchArray): boolean => { |
| 1460 | /* v8 ignore next 2 -- `match.index` is always defined for matches from `matchAll` */ |
| 1461 | if (match.index == null) |
| 1462 | return false |
| 1463 | |
| 1464 | if (this._hasRemovedContent(match.index, match.index + match[0].length)) |
| 1465 | return false |
| 1466 | |
| 1467 | const replacement = getReplacement(match, this.original) |
| 1468 | if (replacement === match[0]) |
| 1469 | return true |
| 1470 | |
| 1471 | if (match[0].length === 0) { |
| 1472 | // a zero-length match spans no characters, so there is no range to |
| 1473 | // overwrite - the replacement is an insertion at the matched position, |
| 1474 | // which is what `String.prototype.replace` does for an empty match |
| 1475 | this.appendRight(match.index, replacement) |
| 1476 | } |
| 1477 | else { |
| 1478 | this.overwrite(match.index, match.index + match[0].length, replacement) |
| 1479 | } |
| 1480 | return true |
| 1481 | } |
| 1482 | |
| 1483 | if (searchValue.global) { |
| 1484 | // `String.prototype.replace` starts a global regexp from the beginning of |
nothing calls this directly
no test coverage detected