MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / matchHeaders

Function matchHeaders

out/cli.cjs:57193–57213  ·  view source on GitHub ↗
(mockDispatch2, headers)

Source from the content-addressed store, hash-verified

57191 function buildHeadersFromArray(headers) {
57192 const clone = headers.slice();
57193 const entries = [];
57194 for (let index = 0; index < clone.length; index += 2) {
57195 entries.push([clone[index], clone[index + 1]]);
57196 }
57197 return Object.fromEntries(entries);
57198 }
57199 function matchHeaders(mockDispatch2, headers) {
57200 if (typeof mockDispatch2.headers === "function") {
57201 if (Array.isArray(headers)) {
57202 headers = buildHeadersFromArray(headers);
57203 }
57204 return mockDispatch2.headers(headers ? lowerCaseEntries(headers) : {});
57205 }
57206 if (typeof mockDispatch2.headers === "undefined") {
57207 return true;
57208 }
57209 if (typeof headers !== "object" || typeof mockDispatch2.headers !== "object") {
57210 return false;
57211 }
57212 for (const [matchHeaderName, matchHeaderValue2] of Object.entries(mockDispatch2.headers)) {
57213 const headerValue = getHeaderByName(headers, matchHeaderName);
57214 if (!matchValue(matchHeaderValue2, headerValue)) {
57215 return false;
57216 }

Callers 2

matchKeyFunction · 0.85
getMockDispatchFunction · 0.85

Calls 6

buildHeadersFromArrayFunction · 0.85
lowerCaseEntriesFunction · 0.85
getHeaderByNameFunction · 0.85
matchValueFunction · 0.85
headersMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…