import * as Json from "../language/json/JSON" ; /**
 * Calls a function on each property of a Json.ObjectValue and replaces that property
 * with the new one returned.
 * Does not traverse deeply into the object
 */ export function mapJsonObjectValue ( objectValue , map ) { let changed = false ; const modifiedProps = [ ] ; for ( let prop of objectValue . properties ) { const newProp = map ( prop ) ; if ( newProp instanceof Json . Property ) { modifiedProps . push ( newProp ) ; if ( newProp !== prop ) { changed = true ; } } else { const newProperties = newProp ; for ( let propElement of newProperties ) { modifiedProps . push ( propElement ) ; } changed = true ; } } if ( changed ) { const modifiedObject = new Json . ObjectValue ( objectValue . span , modifiedProps ) ; return modifiedObject ; } else { return objectValue ; } }