@internal
(string: string, replacement: string | ReplacementFunction)
| 1169 | |
| 1170 | /** @internal */ |
| 1171 | _replaceString(string: string, replacement: string | ReplacementFunction): this { |
| 1172 | const { original } = this |
| 1173 | const index = original.indexOf(string) |
| 1174 | |
| 1175 | if (index !== -1) { |
| 1176 | if (typeof replacement === 'function') { |
| 1177 | replacement = replacement(string, index, original) |
| 1178 | } |
| 1179 | if (string !== replacement) { |
| 1180 | this.overwrite(index, index + string.length, replacement) |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | return this |
| 1185 | } |
| 1186 | |
| 1187 | /** |
| 1188 | * String replacement with RegExp or string. |