import { DataUtility } from './data.utility' ; /**
 * Wrapper methods for native js Object
 * Just to make sure not to inject native js functions into the API
 * This increases to support older versions that dont support the latest Object api
 */ export abstract class ObjectUtility { private static _replaceObjectReferences ( obj , objToReplace , className ) { ObjectUtility . keys ( obj ) . forEach ( key => { if ( obj [ key ] instanceof className ) { obj [ key ] = objToReplace ; } else if ( typeof obj [ key ] === 'object' && obj [ key ] !== null ) { ObjectUtility . _replaceObjectReferences ( obj [ key ] , objToReplace , className ) ; } } ) ; } /**
     * Works exactly => Object.create(obj)
     */ static create ( obj ) { return Object . create ( obj ) ; } /**
     * Works exactly => Object.keys(obj)
     */ static keys ( obj ) { return Object . keys ( obj ) ; } /**
     * Works exactly => Object.getPrototypeOf(obj)
     */ static getPrototypeOf ( obj ) { return Object . getPrototypeOf ( obj ) ; } /**
     * Works exactly => Object.getOwnPropertyNames(obj)
     */ static getOwnPropertyNames ( obj ) { return Object . getOwnPropertyNames ( obj ) ; } static replaceObjectReferences ( obj , objToReplace , className ) { if ( DataUtility . isUndefinedOrNull ( obj ) || DataUtility . isString ( obj ) ) return obj ; if ( ! DataUtility . isFunction ( className ) ) return obj ; ObjectUtility . _replaceObjectReferences ( obj , objToReplace , className ) ; return obj ; } }