relay-runtime
Version:
A core runtime for building GraphQL-driven applications.
26 lines (22 loc) • 729 B
Flow
/**
* 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 strict
* @format
* @oncall relay
*/
;
/**
* A fast test to determine if two values are equal scalars:
* - compares scalars such as booleans, strings, numbers by value
* - compares functions by identity
* - returns false for complex values, since these cannot be cheaply tested for
* equality (use `areEquals` instead)
*/
function isScalarAndEqual(valueA: mixed, valueB: mixed): boolean {
return valueA === valueB && (valueA === null || typeof valueA !== 'object');
}
module.exports = isScalarAndEqual;