import Config from "../config" ; function mergeArray ( arr1 , arr2 ) { return [ ... ( arr1 || [ ] ) , ... ( arr2 || [ ] ) ] ; } function mergeObject ( obj1 , obj2 ) { return { ... obj1 , ... obj2 } ; } function merge ( src , dest ) { return { baseURL : dest . baseURL || src . baseURL , headers : mergeObject ( src . headers , dest . headers ) , transformData : mergeArray ( src . transformData , dest . transformData ) , transformResponse : mergeArray ( src . transformResponse , dest . transformResponse ) , before : mergeArray ( src . before , dest . before ) , after : mergeArray ( src . after , dest . after ) , responseValidations : mergeArray ( src . responseValidations , dest . responseValidations ) } ; } export function mergeConfigs ( ... configs ) { return configs . reduce ( ( acc , config ) => { return merge ( acc , config ) ; } , { } ) ; } export default merge ;