function baggageHeaderToObject(baggageHeader) {
  return baggageHeader
    .split(',')
    .map(baggageEntry => baggageEntry.split('=').map(keyOrValue => decodeURIComponent(keyOrValue.trim())))
    .reduce((acc, [key, value]) => {
      acc[key] = value;
      return acc;
    }, {});
}
Will parse a baggage header, which is a simple key-value map, into a flat object.

@param baggageHeader The baggage header to parse.
@returns a flat object containing all the key-value pairs from `baggageHeader`.