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

Method replace

src/MagicString.ts:1207–1213  ·  view source on GitHub ↗

* String replacement with RegExp or string.

(searchValue: string | RegExp, replacement: string | ReplacementFunction)

Source from the content-addressed store, hash-verified

1205 * String replacement with RegExp or string.
1206 */
1207 replace(searchValue: string | RegExp, replacement: string | ReplacementFunction): this {
1208 if (typeof searchValue === 'string') {
1209 return this._replaceString(searchValue, replacement)
1210 }
1211
1212 return this._replaceRegexp(searchValue, replacement)
1213 }
1214
1215 /** @internal */
1216 _replaceAllString(string: string, replacement: string | ReplacementFunction): this {

Callers 9

indentMethod · 0.45
trimStartMethod · 0.45
trimEndMethod · 0.45
indentMethod · 0.45
trimEndAbortedMethod · 0.45
trimStartAbortedMethod · 0.45
getReplacementMethod · 0.45
trimEndMethod · 0.45
trimStartMethod · 0.45

Calls 2

_replaceStringMethod · 0.95
_replaceRegexpMethod · 0.95

Tested by

no test coverage detected