@internal
(string: string, replacement: string | ReplacementFunction)
| 1278 | |
| 1279 | /** @internal */ |
| 1280 | _replaceAllString(string: string, replacement: string | ReplacementFunction): this { |
| 1281 | const { original } = this |
| 1282 | const stringLength = string.length |
| 1283 | for ( |
| 1284 | let index = original.indexOf(string); |
| 1285 | index !== -1; |
| 1286 | index = original.indexOf(string, index + stringLength) |
| 1287 | ) { |
| 1288 | const previous = original.slice(index, index + stringLength) |
| 1289 | const _replacement |
| 1290 | = typeof replacement === 'function' ? replacement(previous, index, original) : replacement |
| 1291 | if (previous !== _replacement) |
| 1292 | this.overwrite(index, index + stringLength, _replacement) |
| 1293 | } |
| 1294 | |
| 1295 | return this |
| 1296 | } |
| 1297 | |
| 1298 | /** |
| 1299 | * Same as `s.replace`, but replace all matched strings instead of just one. |
no test coverage detected