import { isClassInstance , isEmpty , isObject } from './shared-utils' ; export function deepClone < T extends string | number | any [ ] | Object > ( input ) { if ( ! isObject ( input ) || isEmpty ( input ) ) { return input ; } let output ; let i ; if ( input instanceof Array ) { let l ; output = [ ] as any [ ] ; for ( i = 0 , l = input . length ; i < l ; i ++ ) { output [ i ] = deepClone ( input [ i ] ) ; } return output ; } if ( isClassInstance ( input ) ) { return input ; } output = { } ; if ( input instanceof Object ) { for ( i in input ) { if ( input . hasOwnProperty ( i ) ) { output [ i ] = deepClone ( ( input as any ) [ i ] ) ; } } return output ; } }