import { JSONPath } from 'jsonpath-plus' ; const mutateCallback = ( $ref ) => ( payload ) => { Object . assign ( payload , $ref [ payload . $ref ] ) ; delete payload . $ref ; } ; const replace = ( { $ref , content } ) => { JSONPath ( { path : '$..$ref^' , json : content , callback : mutateCallback ( $ref ) } ) ; return content ; } ; export const referencesReplacer = ( configuration ) => { const isReplaceable = configuration . $ref && configuration . content ; return isReplaceable ? replace ( configuration ) : configuration ; } ;