MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / _replaceString

Method _replaceString

src/MagicString.js:862–876  ·  view source on GitHub ↗
(string, replacement)

Source from the content-addressed store, hash-verified

860 }
861
862 _replaceString(string, replacement) {
863 const { original } = this;
864 const index = original.indexOf(string);
865
866 if (index !== -1) {
867 if (typeof replacement === 'function') {
868 replacement = replacement(string, index, original);
869 }
870 if (string !== replacement) {
871 this.overwrite(index, index + string.length, replacement);
872 }
873 }
874
875 return this;
876 }
877
878 replace(searchValue, replacement) {
879 if (typeof searchValue === 'string') {

Callers 1

replaceMethod · 0.95

Calls 1

overwriteMethod · 0.95

Tested by

no test coverage detected