import Immutable from "immutable" ; param { Map } defaultVersion param { Map } currentVersion return { Map } function reducedObject ( defaultVersion , currentVersion ) { if ( defaultVersion === undefined ) { return currentVersion ; } return currentVersion . reduce ( ( result , value , key ) => { const defaultValue = defaultVersion . get ( key ) ; if ( Immutable . Map . isMap ( value ) ) { const diffs = reducedObject ( defaultValue , value ) ; if ( diffs . size > 0 ) { return result . set ( key , diffs ) ; } } if ( Immutable . is ( defaultValue , value ) ) { return result ; } return result . set ( key , value ) ; } , Immutable . Map ( ) ) ; } export default reducedObject ;