@internal
(string: string, replacement: string | ReplacementFunction)
| 1240 | |
| 1241 | /** @internal */ |
| 1242 | _replaceAllString(string: string, replacement: string | ReplacementFunction): this { |
| 1243 | const { original } = this |
| 1244 | const stringLength = string.length |
| 1245 | for ( |
| 1246 | let index = original.indexOf(string); |
| 1247 | index !== -1; |
| 1248 | index = original.indexOf(string, index + stringLength) |
| 1249 | ) { |
| 1250 | const previous = original.slice(index, index + stringLength) |
| 1251 | const _replacement |
| 1252 | = typeof replacement === 'function' ? replacement(previous, index, original) : replacement |
| 1253 | if (previous !== _replacement) |
| 1254 | this.overwrite(index, index + stringLength, _replacement) |
| 1255 | } |
| 1256 | |
| 1257 | return this |
| 1258 | } |
| 1259 | |
| 1260 | /** |
| 1261 | * Same as `s.replace`, but replace all matched strings instead of just one. |
no test coverage detected