Files
30-seconds-of-code/node_modules/relay-runtime/lib/isScalarAndEqual.js
2019-08-20 15:52:05 +02:00

23 lines
680 B
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* strict
* @format
*/
'use strict';
/**
* 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, valueB) {
return valueA === valueB && (valueA === null || typeof valueA !== 'object');
}
module.exports = isScalarAndEqual;