@internal
(string: string, replacement: string | ReplacementFunction)
| 1212 | |
| 1213 | /** @internal */ |
| 1214 | _replaceString(string: string, replacement: string | ReplacementFunction): this { |
| 1215 | const { original } = this |
| 1216 | const index = original.indexOf(string) |
| 1217 | |
| 1218 | if (index !== -1) { |
| 1219 | if (typeof replacement === 'function') { |
| 1220 | replacement = replacement(string, index, original) |
| 1221 | } |
| 1222 | if (string !== replacement) { |
| 1223 | this.overwrite(index, index + string.length, replacement) |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | return this |
| 1228 | } |
| 1229 | |
| 1230 | /** |
| 1231 | * String replacement with RegExp or string. |