@internal
(string: string, replacement: string | ReplacementFunction)
| 1197 | |
| 1198 | /** @internal */ |
| 1199 | _replaceAllString(string: string, replacement: string | ReplacementFunction): this { |
| 1200 | const { original } = this |
| 1201 | const stringLength = string.length |
| 1202 | for ( |
| 1203 | let index = original.indexOf(string); |
| 1204 | index !== -1; |
| 1205 | index = original.indexOf(string, index + stringLength) |
| 1206 | ) { |
| 1207 | const previous = original.slice(index, index + stringLength) |
| 1208 | const _replacement |
| 1209 | = typeof replacement === 'function' ? replacement(previous, index, original) : replacement |
| 1210 | if (previous !== _replacement) |
| 1211 | this.overwrite(index, index + stringLength, _replacement) |
| 1212 | } |
| 1213 | |
| 1214 | return this |
| 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * Same as `s.replace`, but replace all matched strings instead of just one. |
no test coverage detected