MCPcopy
hub / github.com/di-sukharev/opencommit / constructor

Method constructor

out/cli.cjs:6431–6473  ·  view source on GitHub ↗

* Headers class * * @param Object headers Response headers * @return Void

()

Source from the content-addressed store, hash-verified

6429 * @return Void
6430 */
6431 constructor() {
6432 let init = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : void 0;
6433 this[MAP] = /* @__PURE__ */ Object.create(null);
6434 if (init instanceof _Headers) {
6435 const rawHeaders = init.raw();
6436 const headerNames = Object.keys(rawHeaders);
6437 for (const headerName of headerNames) {
6438 for (const value of rawHeaders[headerName]) {
6439 this.append(headerName, value);
6440 }
6441 }
6442 return;
6443 }
6444 if (init == null) ;
6445 else if (typeof init === "object") {
6446 const method = init[Symbol.iterator];
6447 if (method != null) {
6448 if (typeof method !== "function") {
6449 throw new TypeError("Header pairs must be iterable");
6450 }
6451 const pairs = [];
6452 for (const pair of init) {
6453 if (typeof pair !== "object" || typeof pair[Symbol.iterator] !== "function") {
6454 throw new TypeError("Each header pair must be iterable");
6455 }
6456 pairs.push(Array.from(pair));
6457 }
6458 for (const pair of pairs) {
6459 if (pair.length !== 2) {
6460 throw new TypeError("Each header pair must be a name/value tuple");
6461 }
6462 this.append(pair[0], pair[1]);
6463 }
6464 } else {
6465 for (const key of Object.keys(init)) {
6466 const value = init[key];
6467 this.append(key, value);
6468 }
6469 }
6470 } else {
6471 throw new TypeError("Provided initializer must be an object");
6472 }
6473 }
6474 /**
6475 * Return combined header value given name
6476 *

Callers

nothing calls this directly

Calls 7

appendMethod · 0.95
fillFunction · 0.85
rawMethod · 0.80
createMethod · 0.45
keysMethod · 0.45
pushMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected