simplifySingleElementArrays() — react Function Reference
Architecture documentation for the simplifySingleElementArrays() function in minimize.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 871b0e95_67b4_96c3_fab7_fa7db0ca6929["simplifySingleElementArrays()"] 9c061da8_dbf8_4168_823d_991654a3c55d["minimize.ts"] 871b0e95_67b4_96c3_fab7_fa7db0ca6929 -->|defined in| 9c061da8_dbf8_4168_823d_991654a3c55d 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3["cloneAst()"] 871b0e95_67b4_96c3_fab7_fa7db0ca6929 -->|calls| 7a9af496_ef6a_d9e8_8eaf_1f386f49e4b3 style 871b0e95_67b4_96c3_fab7_fa7db0ca6929 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/snap/src/minimize.ts lines 1473–1505
function* simplifySingleElementArrays(ast: t.File): Generator<t.File> {
// Count single-element arrays
let arrayCount = 0;
t.traverseFast(ast, node => {
if (t.isArrayExpression(node) && node.elements.length === 1) {
arrayCount++;
}
});
for (let targetIdx = 0; targetIdx < arrayCount; targetIdx++) {
const cloned = cloneAst(ast);
let idx = 0;
let modified = false;
traverse(cloned, {
ArrayExpression(path) {
if (modified) return;
if (path.node.elements.length === 1 && idx === targetIdx) {
const elem = path.node.elements[0];
if (t.isExpression(elem)) {
path.replaceWith(elem);
modified = true;
}
}
idx++;
},
});
if (modified) {
yield cloned;
}
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does simplifySingleElementArrays() do?
simplifySingleElementArrays() is a function in the react codebase, defined in compiler/packages/snap/src/minimize.ts.
Where is simplifySingleElementArrays() defined?
simplifySingleElementArrays() is defined in compiler/packages/snap/src/minimize.ts at line 1473.
What does simplifySingleElementArrays() call?
simplifySingleElementArrays() calls 1 function(s): cloneAst.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free