pinafore/routes/_utils/strings.js
Nolan Lawson 37e12e8d73
add option to remove emoji from user display names (#450)
* add option to remove emoji from user display names

fixes #449

* slight memory perf improvement
2018-08-19 18:03:26 -07:00

17 lines
399 B
JavaScript

export function replaceAll (string, replacee, replacement) {
if (!string.length || !replacee.length) {
return string
}
let idx
let pos = 0
while (true) {
idx = string.indexOf(replacee, pos)
if (idx === -1) {
break
}
string = string.substring(0, idx) + replacement + string.substring(idx + replacee.length)
pos = idx + replacement.length
}
return string
}