Rich-Harris / magic-string

Manipulate strings like a wizard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`.replace` replacing removed code

fisker opened this issue · comments

> new (require('magic-string'))('00').remove(0, 1).replace('0', '1').toString()
'10'

Shouldn't the result be 1?

.replace matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.

I'm not sure exactly how it works, I generated a new MagicString before replacing for now. prettier/prettier@77ac062

.replace matches against the original string, which is a document caveat. I am not sure if there is a way to improve that, if so I am open for PR.

Is it problematic to get as parameter if the user wants to perform the search on the original string or not?