import _isEqualWith from 'lodash/isEqualWith' ; import { toBigIntOrThrow } from '.' ; import { isDataEntity } from './entities/utils' ; /**
 * Verify that two values are the same (uses a reference check).
 * Similar to === except two NaNs is considered the same
 * For deep equality use isDeepEqual
*/ export function isEqual < T > ( target , input ) ; export function isEqual < T > ( target , input ) ; export function isEqual < T > ( target , input ) { return input === target || ( Number . isNaN ( target ) && Number . isNaN ( input ) ) ; } /**
 * A functional version of isEqual
*/ export function isEqualFP < T > ( target ) ; export function isEqualFP < T > ( target ) ; export function isEqualFP < T > ( target ) { return isEqual . bind ( isEqual , target ) as ( input : T ) => input is T ; } example export function isDeepEqual < T > ( target , input ) ; export function isDeepEqual < T > ( target , input ) ; export function isDeepEqual < T > ( target , input ) { return _isEqualWith ( input , target , _isEqualCustomizer ) ; } function _isEqualCustomizer ( objValue , otherObject ) { const aIsEntity = isDataEntity ( objValue ) ; const bIsEntity = isDataEntity ( otherObject ) ; if ( aIsEntity && bIsEntity ) { return isDeepEqual ( Object . assign ( { } , objValue ) , Object . assign ( { } , otherObject ) ) ; } if ( aIsEntity && ! bIsEntity ) { return isDeepEqual ( Object . assign ( { } , objValue ) , otherObject ) ; } if ( ! aIsEntity && bIsEntity ) { return isDeepEqual ( Object . assign ( { } , objValue ) , otherObject ) ; } } /**
 * A functional version of isDeepEqual
*/ export function isDeepEqualFP < T > ( target ) ; export function isDeepEqualFP < T > ( target ) ; export function isDeepEqualFP < T > ( target ) { return isDeepEqual . bind ( isDeepEqual , target ) as ( input : T ) => input is T ; } deprecated export const isSame = isDeepEqual ; /**
 * This will get the same type of a which is useful for comparison
 * (but not equality since that is more strict)
 */ function getSameType ( value , other ) { const vType = typeof value ; const oType = typeof other ; if ( vType === 'object' || oType === 'object' ) return ; if ( vType === 'undefined' || oType === 'undefined' ) return ; if ( vType === oType ) return [ value , other ] ; if ( vType === 'bigint' || oType === 'bigint' ) { return [ toBigIntOrThrow ( value ) , toBigIntOrThrow ( other ) ] ; } return [ value , other ] ; } /**
 * Check if a value is greater than or equal to another
*/ export function isGreaterThanOrEqualTo ( value , other ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] >= res [ 1 ] ; } /**
 * Check if a value is greater than or equal to another
*/ export function isGreaterThanOrEqualToFP ( other ) { return function _isGreaterThanOrEqualTo ( value ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] >= res [ 1 ] ; } ; } /**
 * Check if a value is greater than another
*/ export function isGreaterThan ( value , other ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] > res [ 1 ] ; } /**
 * Check if a value is greater than or equal to another
*/ export function isGreaterThanFP ( other ) { return function _isGreaterThanTo ( value ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] > res [ 1 ] ; } ; } /**
 * Check if a value is less than or equal to another
*/ export function isLessThanOrEqualTo ( value , other ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] <= res [ 1 ] ; } /**
 * Check if a value is less than or equal to another
*/ export function isLessThanOrEqualToFP ( other ) { return function _isLessThanOrEqualTo ( value ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] <= res [ 1 ] ; } ; } /**
 * Check if a value is less than another
*/ export function isLessThan ( value , other ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] < res [ 1 ] ; } /**
 * Check if a value is greater than or equal to another
*/ export function isLessThanFP ( other ) { return function _isLessThan ( value ) { const res = getSameType ( value , other ) ; if ( res == null ) return false ; return res [ 0 ] < res [ 1 ] ; } ; }