@internal
(string: string, replacement: string | ReplacementFunction)
| 1186 | |
| 1187 | /** @internal */ |
| 1188 | _replaceString(string: string, replacement: string | ReplacementFunction): this { |
| 1189 | const { original } = this |
| 1190 | const index = original.indexOf(string) |
| 1191 | |
| 1192 | if (index !== -1) { |
| 1193 | if (typeof replacement === 'function') { |
| 1194 | replacement = replacement(string, index, original) |
| 1195 | } |
| 1196 | if (string !== replacement) { |
| 1197 | this.overwrite(index, index + string.length, replacement) |
| 1198 | } |
| 1199 | } |
| 1200 | |
| 1201 | return this |
| 1202 | } |
| 1203 | |
| 1204 | /** |
| 1205 | * String replacement with RegExp or string. |