MCPcopy Index your code
hub / github.com/simstudioai/sim / replaceUntilStable

Function replaceUntilStable

apps/sim/lib/mothership/inbox/format.ts:102–116  ·  view source on GitHub ↗
(
  input: string,
  pattern: RegExp,
  replacement: string,
  maxIterations = 100
)

Source from the content-addressed store, hash-verified

100 * like `<scr<script>ipt>`.
101 */
102export function replaceUntilStable(
103 input: string,
104 pattern: RegExp,
105 replacement: string,
106 maxIterations = 100
107): string {
108 let prev = input
109 let next = prev.replace(pattern, replacement)
110 let iterations = 0
111 while (next !== prev && iterations++ < maxIterations) {
112 prev = next
113 next = prev.replace(pattern, replacement)
114 }
115 return next
116}
117
118const HTML_ENTITY_MAP: Record<string, string> = {
119 '&nbsp;': ' ',

Callers 2

stripRawHtmlFunction · 0.90
extractTextFromHtmlFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected