accumulateInto.js — react Source File
Architecture documentation for accumulateInto.js, a javascript file in the react codebase. 1 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR c55ef19d_ffff_0be0_ac25_e6d6c8520cd6["accumulateInto.js"] af78c51d_c7cb_3bf4_550f_f3fcc48f4f34["isArray"] c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 --> af78c51d_c7cb_3bf4_550f_f3fcc48f4f34 846f0667_39ae_eb6e_55fe_26d3acf81e44["ReactFabricEventEmitter.js"] 846f0667_39ae_eb6e_55fe_26d3acf81e44 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 577670f6_1f7f_5e0d_b9b6_894b69a76a73["ReactNativeBridgeEventPlugin.js"] 577670f6_1f7f_5e0d_b9b6_894b69a76a73 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 baab5855_112a_37e6_6ca7_0813fd6ae027["ReactNativeEventEmitter.js"] baab5855_112a_37e6_6ca7_0813fd6ae027 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 501868ac_ed82_decd_b0b4_e77c7390f910["EventBatching.js"] 501868ac_ed82_decd_b0b4_e77c7390f910 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 674c6180_b91e_e17d_fb2d_40a6a3631bb3["ResponderEventPlugin.js"] 674c6180_b91e_e17d_fb2d_40a6a3631bb3 --> c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 style c55ef19d_ffff_0be0_ac25_e6d6c8520cd6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import isArray from 'shared/isArray';
/**
* Accumulates items that must not be null or undefined into the first one. This
* is used to conserve memory by avoiding array allocations, and thus sacrifices
* API cleanness. Since `current` can be null before being passed in and not
* null after this function, make sure to assign it back to `current`:
*
* `a = accumulateInto(a, b);`
*
* This API should be sparingly used. Try `accumulate` for something cleaner.
*
* @return {*|array<*>} An accumulation of items.
*/
function accumulateInto<T>(
current: ?(Array<T> | T),
next: T | Array<T>,
): T | Array<T> {
if (next == null) {
throw new Error('Accumulated items must not be null or undefined.');
}
if (current == null) {
return next;
}
// Both are not empty. Warning: Never call x.concat(y) when you are not
// certain that x is an Array (x could be a string with concat method).
if (isArray(current)) {
if (isArray(next)) {
// $FlowFixMe[incompatible-use] `isArray` does not ensure array is mutable
// $FlowFixMe[method-unbinding]
current.push.apply(current, next);
return current;
}
// $FlowFixMe[incompatible-use] `isArray` does not ensure array is mutable
current.push(next);
return current;
}
if (isArray(next)) {
// A bit too dangerous to mutate `next`.
/* $FlowFixMe[incompatible-return] unsound if `next` is `T` and `T` an array,
* `isArray` might refine to the array element type of `T` */
return [current].concat(next);
}
return [current, next];
}
export default accumulateInto;
Domain
Dependencies
- isArray
Imported By
- packages/react-native-renderer/src/legacy-events/EventBatching.js
- packages/react-native-renderer/src/ReactFabricEventEmitter.js
- packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js
- packages/react-native-renderer/src/ReactNativeEventEmitter.js
- packages/react-native-renderer/src/legacy-events/ResponderEventPlugin.js
Source
Frequently Asked Questions
What does accumulateInto.js do?
accumulateInto.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does accumulateInto.js depend on?
accumulateInto.js imports 1 module(s): isArray.
What files import accumulateInto.js?
accumulateInto.js is imported by 5 file(s): EventBatching.js, ReactFabricEventEmitter.js, ReactNativeBridgeEventPlugin.js, ReactNativeEventEmitter.js, ResponderEventPlugin.js.
Where is accumulateInto.js in the architecture?
accumulateInto.js is located at packages/react-native-renderer/src/legacy-events/accumulateInto.js (domain: BabelCompiler, directory: packages/react-native-renderer/src/legacy-events).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free