data_is-mergeable-object.js

const canUseSymbol = typeof Symbol === 'function' && Symbol.for;
const REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for( 'react.element' ) : 0xeac7;

const isReactElement = ( value ) => value.$$typeof === REACT_ELEMENT_TYPE;

const isNonNullObject = ( value ) => !! value && typeof value === 'object';

const isSpecial = ( value ) => {
	const stringValue = Object.prototype.toString.call( value );
	return stringValue === '[object RegExp]' ||
		stringValue === '[object Date]' ||
		isReactElement( value );
};

/**
 * @module isMergeableObject
 * @description Determines if a value of any type is a mergeable object. Used by deep-merge.
 *
 * @since 1.0.0
 *
 * @param {*} value The value to be tested.
 *
 * @return {boolean} Returns true if the specified value is a mergeable object. Returns false otherwise.
 *
 * @example
 * import { isMergeableObject } from "@gravityforms/utils";
 *
 * function Example() {
 *   const someObject = { 'prop' : 'val' };
 * 	 const isMergeable = isMergeableObject( someObject );
 * }
 *
 */
export default function isMergeableObject( value ) {
	return isNonNullObject( value ) &&
		! isSpecial( value );
}