Sha256: 4d5588be36ad2c732d35a088c7bc3155d2b1414dad05c1fed67bdc69feeead02

Contents?: true

Size: 1.23 KB

Versions: 26

Compression:

Stored size: 1.23 KB

Contents

import statuses from "@bundled-es-modules/statuses";
import { Headers as HeadersPolyfill } from "headers-polyfill";
const { message } = statuses;
const kSetCookie = Symbol("kSetCookie");
function normalizeResponseInit(init = {}) {
  const status = init?.status || 200;
  const statusText = init?.statusText || message[status] || "";
  const headers = new Headers(init?.headers);
  return {
    ...init,
    headers,
    status,
    statusText
  };
}
function decorateResponse(response, init) {
  if (init.type) {
    Object.defineProperty(response, "type", {
      value: init.type,
      enumerable: true,
      writable: false
    });
  }
  const responseCookies = init.headers.get("set-cookie");
  if (responseCookies) {
    Object.defineProperty(response, kSetCookie, {
      value: responseCookies,
      enumerable: false,
      writable: false
    });
    if (typeof document !== "undefined") {
      const responseCookiePairs = HeadersPolyfill.prototype.getSetCookie.call(
        init.headers
      );
      for (const cookieString of responseCookiePairs) {
        document.cookie = cookieString;
      }
    }
  }
  return response;
}
export {
  decorateResponse,
  kSetCookie,
  normalizeResponseInit
};
//# sourceMappingURL=decorators.mjs.map

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.25 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.24 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.23 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.22 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.21 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.20 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.19 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.18 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.17 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.16 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.15 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.14 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.13 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.12 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.11 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.10 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.9 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.8 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
clapton-0.0.7 lib/clapton/javascripts/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs