MCPcopy
hub / github.com/lebab/lebab / multiReplaceStatement

Function multiReplaceStatement

src/utils/multiReplaceStatement.js:19–28  ·  view source on GitHub ↗
({parent, node, replacements, preserveComments})

Source from the content-addressed store, hash-verified

17 * node to first replacement node
18 */
19export default function multiReplaceStatement({parent, node, replacements, preserveComments}) {
20 const body = getBody(parent);
21 const index = body.indexOf(node);
22 if (preserveComments && replacements[0]) {
23 copyComments({from: node, to: replacements[0]});
24 }
25 if (index !== -1) {
26 body.splice(index, 1, ...replacements);
27 }
28}
29
30function getBody(node) {
31 switch (node.type) {

Callers 6

splitDeclarationFunction · 0.85
enterFunction · 0.85
transformDefaultParamsFunction · 0.85
removeMethod · 0.85
transformMethod · 0.85

Calls 2

getBodyFunction · 0.85
copyCommentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…