import { Dictionary } from 'lodash' ; import isEqual from 'lodash/isEqual' ; import transform from 'lodash/transform' ; export type RecursivePartial < T > = { [ P in keyof T ] ? : RecursivePartial < T [ P ] > ; } ; export const isDefined = < T extends unknown > ( val ) : val is T => val !== undefined && val !== null ; export const isReferrerFromBaseSite = ( ) : boolean => { let referrerUrl ; try { referrerUrl = new URL ( document . referrer ) ; } catch ( _ ) { return false ; } return referrerUrl . origin === 'https://reach4help.org' ; } ; /**
 * Return true if the webpage is currently within an iframe
 */ export const isInFrame = ( ) : boolean => { try { return window . self !== window . top ; } catch ( _ ) { return true ; } } ; param { Object } object param { Object } base return { Object } export const difference = < B extends Dictionary < unknown > , T extends RecursivePartial < B > > ( object , base ) : RecursivePartial < T > => transform ( object , ( result , value , key ) => { if ( ! isEqual ( value , base [ key ] ) ) { ( result as any ) [ key ] = typeof value === 'object' && typeof base [ key ] === 'object' ? difference < any , any > ( value , base [ key ] ) : value ; } } ) ;