retainWhere() — react Function Reference
Architecture documentation for the retainWhere() function in utils.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD c447b97e_0b8e_b187_e3a8_4be412d6f495["retainWhere()"] eb9d33f9_42c1_205c_93e6_8e1365a31839["utils.ts"] c447b97e_0b8e_b187_e3a8_4be412d6f495 -->|defined in| eb9d33f9_42c1_205c_93e6_8e1365a31839 d77babff_42d3_5fdf_4059_c0b9e7cfaeb0["inlineImmediatelyInvokedFunctionExpressions()"] d77babff_42d3_5fdf_4059_c0b9e7cfaeb0 -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 e6e7641a_0356_e256_1ee6_a60705f7edfe["deadCodeElimination()"] e6e7641a_0356_e256_1ee6_a60705f7edfe -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 93674d7a_a49c_dadd_0d67_6c5e98450587["optimizeForSSR()"] 93674d7a_a49c_dadd_0d67_6c5e98450587 -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca["flattenReactiveLoopsHIR()"] 034ea53e_cd8a_da9d_4b95_99b1f4b8a3ca -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 c58ff1cf_f3a5_ee82_aeb5_ba958870959d["flattenScopesWithHooksOrUseHIR()"] c58ff1cf_f3a5_ee82_aeb5_ba958870959d -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 6869984f_c56b_62c6_1328_06ff93395ab4["validateDependencies()"] 6869984f_c56b_62c6_1328_06ff93395ab4 -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 098764b0_1542_854b_0a71_e361ec33cef2["validateNoJSXInTryStatement()"] 098764b0_1542_854b_0a71_e361ec33cef2 -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 b2292640_a950_f66a_1a21_4fa1d74f094d["validateNoRefAccessInRenderImpl()"] b2292640_a950_f66a_1a21_4fa1d74f094d -->|calls| c447b97e_0b8e_b187_e3a8_4be412d6f495 style c447b97e_0b8e_b187_e3a8_4be412d6f495 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts lines 34–46
export function retainWhere<T>(
array: Array<T>,
predicate: (item: T, index: number) => boolean,
): void {
let writeIndex = 0;
for (let readIndex = 0; readIndex < array.length; readIndex++) {
const item = array[readIndex];
if (predicate(item, readIndex) === true) {
array[writeIndex++] = item;
}
}
array.length = writeIndex;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does retainWhere() do?
retainWhere() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts.
Where is retainWhere() defined?
retainWhere() is defined in compiler/packages/babel-plugin-react-compiler/src/Utils/utils.ts at line 34.
What calls retainWhere()?
retainWhere() is called by 8 function(s): deadCodeElimination, flattenReactiveLoopsHIR, flattenScopesWithHooksOrUseHIR, inlineImmediatelyInvokedFunctionExpressions, optimizeForSSR, validateDependencies, validateNoJSXInTryStatement, validateNoRefAccessInRenderImpl.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free