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

Function createExportStarFunction

test/fixtures/snapshot/typescript.js:106104–106134  ·  view source on GitHub ↗

* Creates an exportStar function for the file, with an optional set of excluded local * names. * * @param localNames An optional reference to an object containing a set of excluded local * names.

(localNames)

Source from the content-addressed store, hash-verified

106102 * names.
106103 */
106104 function createExportStarFunction(localNames) {
106105 var exportStarFunction = factory.createUniqueName("exportStar");
106106 var m = factory.createIdentifier("m");
106107 var n = factory.createIdentifier("n");
106108 var exports = factory.createIdentifier("exports");
106109 var condition = factory.createStrictInequality(n, factory.createStringLiteral("default"));
106110 if (localNames) {
106111 condition = factory.createLogicalAnd(condition, factory.createLogicalNot(factory.createCallExpression(factory.createPropertyAccessExpression(localNames, "hasOwnProperty"),
106112 /*typeArguments*/ undefined, [n])));
106113 }
106114 return factory.createFunctionDeclaration(
106115 /*decorators*/ undefined,
106116 /*modifiers*/ undefined,
106117 /*asteriskToken*/ undefined, exportStarFunction,
106118 /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, m)],
106119 /*type*/ undefined, factory.createBlock([
106120 factory.createVariableStatement(
106121 /*modifiers*/ undefined, factory.createVariableDeclarationList([
106122 factory.createVariableDeclaration(exports,
106123 /*exclamationToken*/ undefined,
106124 /*type*/ undefined, factory.createObjectLiteralExpression([]))
106125 ])),
106126 factory.createForInStatement(factory.createVariableDeclarationList([
106127 factory.createVariableDeclaration(n)
106128 ]), m, factory.createBlock([
106129 ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */)
106130 ])),
106131 factory.createExpressionStatement(factory.createCallExpression(exportFunction,
106132 /*typeArguments*/ undefined, [exports]))
106133 ], /*multiline*/ true));
106134 }
106135 /**
106136 * Creates an array setter callbacks for each dependency group.
106137 *

Callers 1

addExportStarIfNeededFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected