@dillonkearns/elm-graphql
Version:
<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">
21 lines (14 loc) • 571 B
Flow
// @flow
import {curry} from "flow-static-land/lib/Fun";
import haveSameProps from "./haveSameProps";
import type {Composite} from "./types";
// eslint-disable-next-line no-bitwise
const xor = (cond1, cond2) => Boolean(Number(cond1) ^ Number(cond2));
/**
* Returns true if both composites are of the same type (Array or Object) and
* their properties are strictly equal.
*/
const shallowEqual = (c1: Composite, c2: Composite): boolean =>
c1 === c2 ||
(!xor(Array.isArray(c1), Array.isArray(c2)) && haveSameProps(c1, c2));
export default curry(shallowEqual);