MCPcopy Create free account
hub / github.com/nodejs/node / mergeChildren

Function mergeChildren

test/fixtures/snapshot/typescript.js:141129–141162  ·  view source on GitHub ↗

Merge declarations of the same kind.

(children, node)

Source from the content-addressed store, hash-verified

141127 }
141128 /** Merge declarations of the same kind. */
141129 function mergeChildren(children, node) {
141130 var nameToItems = new ts.Map();
141131 ts.filterMutate(children, function (child, index) {
141132 var declName = child.name || ts.getNameOfDeclaration(child.node);
141133 var name = declName && nodeText(declName);
141134 if (!name) {
141135 // Anonymous items are never merged.
141136 return true;
141137 }
141138 var itemsWithSameName = nameToItems.get(name);
141139 if (!itemsWithSameName) {
141140 nameToItems.set(name, child);
141141 return true;
141142 }
141143 if (itemsWithSameName instanceof Array) {
141144 for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) {
141145 var itemWithSameName = itemsWithSameName_1[_i];
141146 if (tryMerge(itemWithSameName, child, index, node)) {
141147 return false;
141148 }
141149 }
141150 itemsWithSameName.push(child);
141151 return true;
141152 }
141153 else {
141154 var itemWithSameName = itemsWithSameName;
141155 if (tryMerge(itemWithSameName, child, index, node)) {
141156 return false;
141157 }
141158 nameToItems.set(name, [itemWithSameName, child]);
141159 return true;
141160 }
141161 });
141162 }
141163 var isEs5ClassMember = (_a = {},
141164 _a[5 /* AssignmentDeclarationKind.Property */] = true,
141165 _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true,

Callers 3

endNodeFunction · 0.85
tryMergeEs5ClassFunction · 0.85
mergeFunction · 0.85

Calls 5

nodeTextFunction · 0.85
tryMergeFunction · 0.85
getMethod · 0.65
setMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected