"use strict" ; import map = require ( "lodash/map" ) ; export function equals ( one , other ) { if ( one === other ) { return true ; } if ( one === null || one === undefined || other === null || other === undefined ) { return false ; } if ( typeof one !== typeof other ) { return false ; } if ( typeof one !== "object" ) { return false ; } if ( Array . isArray ( one ) !== Array . isArray ( other ) ) { return false ; } if ( Array . isArray ( one ) ) { if ( one . length !== other . length ) { return false ; } for ( let i = 0 ; i < one . length ; i ++ ) { if ( ! equals ( one [ i ] , other [ i ] ) ) { return false ; } } } else { const oneKeys = map ( one , ( item , oneKey ) => oneKey ) ; oneKeys . sort ( ) ; const otherKeys = map ( other , ( item , otherKey ) => otherKey ) ; otherKeys . sort ( ) ; if ( ! equals ( oneKeys , otherKeys ) ) { return false ; } for ( let i = 0 ; i < oneKeys . length ; i ++ ) { if ( ! equals ( one [ oneKeys [ i ] ] , other [ oneKeys [ i ] ] ) ) { return false ; } } } return true ; } export const logObject = ( obj ) => { let cache = [ ] ; const res = JSON . stringify ( obj , ( key , value ) => { if ( typeof value === "object" && value !== null ) { if ( cache . indexOf ( value ) !== - 1 ) { try { return JSON . parse ( JSON . stringify ( value ) ) ; } catch ( error ) { return ; } } cache . push ( value ) ; } return value ; } , 2 ) ; cache = null ; console . log ( res ) ; } ;