1
1
mirror of https://github.com/primer/css.git synced 2024-09-21 05:39:15 +03:00

be smarter in replaceAll()

This commit is contained in:
Shawn Allen 2019-07-22 16:43:45 -07:00
parent 2a716f9912
commit d73daf52b3

View File

@ -49,8 +49,8 @@ function converter({converters = {}}) {
const parts = argString.split(/, */)
const args = []
const kwargs = {}
let match
for (const part of parts) {
let match
if ((match = part.match(/^:(.+) => (.+)$/))) {
kwargs[unquote(match[1])] = unquote(match[2])
} else if ((match = part.match(/^(.+): (.+)$/))) {
@ -73,11 +73,7 @@ function converter({converters = {}}) {
}
function replaceAll(str, input, output) {
let result = str
while (result.includes(input)) {
result = result.replace(input, output)
}
return result
return str.split(input).join(output)
}
function unquote(str) {