MCPcopy Index your code
hub / github.com/nodejs/node / createSettersArray

Function createSettersArray

test/fixtures/snapshot/typescript.js:106141–106213  ·  view source on GitHub ↗

* Creates an array setter callbacks for each dependency group. * * @param exportStarFunction A reference to an exportStarFunction for the file. * @param dependencyGroups An array of grouped dependencies.

(exportStarFunction, dependencyGroups)

Source from the content-addressed store, hash-verified

106139 * @param dependencyGroups An array of grouped dependencies.
106140 */
106141 function createSettersArray(exportStarFunction, dependencyGroups) {
106142 var setters = [];
106143 for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
106144 var group_2 = dependencyGroups_1[_i];
106145 // derive a unique name for parameter from the first named entry in the group
106146 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(factory, i, currentSourceFile); });
106147 var parameterName = localName ? factory.getGeneratedNameForNode(localName) : factory.createUniqueName("");
106148 var statements = [];
106149 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
106150 var entry = _b[_a];
106151 var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217
106152 switch (entry.kind) {
106153 case 266 /* SyntaxKind.ImportDeclaration */:
106154 if (!entry.importClause) {
106155 // 'import "..."' case
106156 // module is imported only for side-effects, no emit required
106157 break;
106158 }
106159 // falls through
106160 case 265 /* SyntaxKind.ImportEqualsDeclaration */:
106161 ts.Debug.assert(importVariableName !== undefined);
106162 // save import into the local
106163 statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
106164 break;
106165 case 272 /* SyntaxKind.ExportDeclaration */:
106166 ts.Debug.assert(importVariableName !== undefined);
106167 if (entry.exportClause) {
106168 if (ts.isNamedExports(entry.exportClause)) {
106169 // export {a, b as c} from 'foo'
106170 //
106171 // emit as:
106172 //
106173 // exports_({
106174 // "a": _["a"],
106175 // "c": _["b"]
106176 // });
106177 var properties = [];
106178 for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
106179 var e = _d[_c];
106180 properties.push(factory.createPropertyAssignment(factory.createStringLiteral(ts.idText(e.name)), factory.createElementAccessExpression(parameterName, factory.createStringLiteral(ts.idText(e.propertyName || e.name)))));
106181 }
106182 statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
106183 /*typeArguments*/ undefined, [factory.createObjectLiteralExpression(properties, /*multiline*/ true)])));
106184 }
106185 else {
106186 statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction,
106187 /*typeArguments*/ undefined, [
106188 factory.createStringLiteral(ts.idText(entry.exportClause.name)),
106189 parameterName
106190 ])));
106191 }
106192 }
106193 else {
106194 // export * from 'foo'
106195 //
106196 // emit as:
106197 //
106198 // exportStar(foo_1_1);

Callers 1

createSystemModuleBodyFunction · 0.85

Calls 3

assertMethod · 0.80
forEachMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected