import { getChangeValue , isChange } from '../-private/change' ; import isObject from './is-object' ; method param { Object } target return { Object } export default function normalizeObject < T extends { [ key ] : any ; } > ( target , isObj = isObject ) { if ( ! target || ! isObj ( target ) ) { return target ; } if ( isChange ( target ) ) { return getChangeValue ( target ) ; } let obj = { ... target } ; for ( let key in obj ) { const next = obj [ key ] ; if ( next && isObj ( next ) ) { if ( isChange ( next ) ) { obj [ key ] = getChangeValue ( next ) ; } else { try { JSON . stringify ( next ) ; } catch ( e ) { break ; } obj [ key ] = normalizeObject ( next ) ; } } } return obj ; }