MCPcopy
hub / github.com/ccampbell/rainbow / replaceAtPosition

Function replaceAtPosition

src/util.js:142–152  ·  view source on GitHub ↗
(position, replace, replaceWith, code)

Source from the content-addressed store, hash-verified

140 * @return {string}
141 */
142export function replaceAtPosition(position, replace, replaceWith, code) {
143 const subString = code.substr(position);
144
145 // This is needed to fix an issue where $ signs do not render in the
146 // highlighted code
147 //
148 // @see https://github.com/ccampbell/rainbow/issues/208
149 replaceWith = replaceWith.replace(/\$/g, '$$$$');
150
151 return code.substr(0, position) + subString.replace(replace, replaceWith);
152}
153
154/**
155 * Creates a usable web worker from an anonymous function

Callers 2

_processReplacementsMethod · 0.90
_getReplacementMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected