function groupHeadersSameKey (headers) {
  let grouped = {},
    groupedList = [];
  headers.forEach((header) => {
    if (grouped.hasOwnProperty(header.key)) {
      grouped[header.key].push(header.value);
    }
    else {
      grouped[header.key] = [header.value];
    }
  });
  groupedList = Object.keys(grouped).map((key) => {
    return {
      key,
      value: grouped[key].join(', ')
    };
  });
  return groupedList;
}
/**
 * Groups the headers with the same key value
 *
 * @param {array} headers The array of headers
 * @returns {array} An array with grouped headers
 */
Groups the headers with the same key value
@param {array} headers The array of headers
@returns {array} An array with grouped headers
Groups the headers with the same key value @param { array } headers The array of headers @returns { array } An array with grouped headers
function groupHeadersSameKey (headers) {
  let grouped = {},
    groupedList = [];
  headers.forEach((header) => {
    if (grouped.hasOwnProperty(header.key)) {
      grouped[header.key].push(header.value);
    }
    else {
      grouped[header.key] = [header.value];
    }
  });
  groupedList = Object.keys(grouped).map((key) => {
    return {
      key,
      value: grouped[key].join(', ')
    };
  });
  return groupedList;
}
function groupHeadersSameKey ( headers ) { let grouped = { } , groupedList = [ ] ; headers . forEach ( ( header ) => { if ( grouped . hasOwnProperty ( header . key ) ) { grouped [ header . key ] . push ( header . value ) ; } else { grouped [ header . key ] = [ header . value ] ; } } ) ; groupedList = Object . keys ( grouped ) . map ( ( key ) => { return { key , value : grouped [ key ] . join ( ', ' ) } ; } ) ; return groupedList ; }
Groups the headers with the same key value
 @param {array} headers The array of headers
 @returns {array} An array with grouped headers
Groups the headers with the same key value @param { array } headers The array of headers @returns { array } An array with grouped headers