Skip to content

Function: shallowEqualExcept()

API / @xmachines/core / utils / shallowEqualExcept

function shallowEqualExcept(a, b, except?): boolean;

Defined in: packages/core/src/utils/shallow-equal.ts:25

The shallow equality of the own keys, with Object.is. It can ignore one key on both sides.

The comparison reads the own enumerable string keys of each side, and a key that one side carries and the other lacks makes the two unequal, even when its value is undefined. A value compares by Object.is, so NaN equals NaN and 0 differs from -0.

The emission dedup of the Play packages reads it: the equality of a slice, the emit gate of the player, and the reuse of a composed state.

Parameters

ParameterTypeDescription
aobjectThe first object.
bobjectThe second object.
except?stringA key that the comparison ignores on both sides.

Returns

boolean

true when every other own key holds the same value on both sides.

Example

import { shallowEqualExcept } from "@xmachines/core/utils";
shallowEqualExcept({ a: 1, s: 1 }, { a: 1, s: 2 }, "s"); // true