Skip to content

Vizel API / core/src / shallowEqualArray

Function: shallowEqualArray()

ts
function shallowEqualArray<T>(a, b): boolean;

Defined in: packages/core/src/utils/equality.ts:33

Return true when two arrays carry identical references in the same order and the same length.

The comparison runs in O(n) on the shared length; selectors that return short arrays (typical in toolbar / bubble-menu state slices) stay cheap to compare.

Type Parameters

Type Parameter
T

Parameters

ParameterType
areadonly T[]
breadonly T[]

Returns

boolean

Example

ts
shallowEqualArray([a, b], [a, b]); // true
shallowEqualArray([a, b], [a, c]); // false

Released under the MIT License.