function xhrHeaderMapper(xhr) {
  return Object.fromEntries(
      xhr
      // Raw response headers
      .getAllResponseHeaders()
      .trim()
      // split by line
      .split(/\r?\n/)
      // split by colon and trim each part
      .map((h) => h.split(":").map(v => v.trim()))
      // ensure header exists
      .filter(([k, v]) => !!k)
  );
}
/**
 * Extracts headers from an XHR and converst it to an object with a key/value per header
 * @param {XMLHttpRequest} xhr
 * @returns Object representation of the xhr's headers
 */
Extracts headers from an XHR and converst it to an object with a key/value per header
@param {XMLHttpRequest} xhr
@returns Object representation of the xhr's headers
Extracts headers from an XHR and converst it to an object with a key / value per header @param { XMLHttpRequest } xhr @returns Object representation of the xhr ' s headers
function xhrHeaderMapper(xhr) {
  return Object.fromEntries(
      xhr
      .getAllResponseHeaders()
      .trim()
      .split(/\r?\n/)
      .map((h) => h.split(":").map(v => v.trim()))
      .filter(([k, v]) => !!k)
  );
}
function xhrHeaderMapper ( xhr ) { return Object . fromEntries ( xhr . getAllResponseHeaders ( ) . trim ( ) . split ( / \r?\n / ) . map ( ( h ) => h . split ( ":" ) . map ( v => v . trim ( ) ) ) . filter ( ( [ k , v ] ) => ! ! k ) ) ; }
Extracts headers from an XHR and converst it to an object with a key/value per header
 @param {XMLHttpRequest} xhr
 @returns Object representation of the xhr's headers
Extracts headers from an XHR and converst it to an object with a key / value per header @param { XMLHttpRequest } xhr @returns Object representation of the xhr ' s headers
// Raw response headers // split by line // split by colon and trim each part // ensure header exists