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

Function getExpandoInitializer

test/fixtures/snapshot/typescript.js:16465–16478  ·  view source on GitHub ↗

* Recognized expando initializers are: * 1. (function() {})() -- IIFEs * 2. function() { } -- Function expressions * 3. class { } -- Class expressions * 4. {} -- Empty object literals * 5. { ... } -- Non-empty object literals, when used to initialize a prototype, like `C.pro

(initializer, isPrototypeAssignment)

Source from the content-addressed store, hash-verified

16463 * This function returns the provided initializer, or undefined if it is not valid.
16464 */
16465 function getExpandoInitializer(initializer, isPrototypeAssignment) {
16466 if (ts.isCallExpression(initializer)) {
16467 var e = skipParentheses(initializer.expression);
16468 return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined;
16469 }
16470 if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ ||
16471 initializer.kind === 226 /* SyntaxKind.ClassExpression */ ||
16472 initializer.kind === 214 /* SyntaxKind.ArrowFunction */) {
16473 return initializer;
16474 }
16475 if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
16476 return initializer;
16477 }
16478 }
16479 ts.getExpandoInitializer = getExpandoInitializer;
16480 /**
16481 * A defaulted expando initializer matches the pattern

Calls 1

skipParenthesesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…