MCPcopy Create free account
hub / github.com/angular/dev-infra / mockDispatch

Function mockDispatch

github-actions/browserstack/set-browserstack-env.js:11074–11117  ·  view source on GitHub ↗
(opts, handler)

Source from the content-addressed store, hash-verified

11072 return match.test(value);
11073 }
11074 if (typeof match === "function") {
11075 return match(value) === true;
11076 }
11077 return false;
11078 }
11079 function lowerCaseEntries(headers) {
11080 return Object.fromEntries(
11081 Object.entries(headers).map(([headerName, headerValue]) => {
11082 return [headerName.toLocaleLowerCase(), headerValue];
11083 })
11084 );
11085 }
11086 function getHeaderByName(headers, key) {
11087 if (Array.isArray(headers)) {
11088 for (let i = 0; i < headers.length; i += 2) {
11089 if (headers[i].toLocaleLowerCase() === key.toLocaleLowerCase()) {
11090 return headers[i + 1];
11091 }
11092 }
11093 return void 0;
11094 } else if (typeof headers.get === "function") {
11095 return headers.get(key);
11096 } else {
11097 return lowerCaseEntries(headers)[key.toLocaleLowerCase()];
11098 }
11099 }
11100 function buildHeadersFromArray(headers) {
11101 const clone = headers.slice();
11102 const entries = [];
11103 for (let index = 0; index < clone.length; index += 2) {
11104 entries.push([clone[index], clone[index + 1]]);
11105 }
11106 return Object.fromEntries(entries);
11107 }
11108 function matchHeaders(mockDispatch2, headers) {
11109 if (typeof mockDispatch2.headers === "function") {
11110 if (Array.isArray(headers)) {
11111 headers = buildHeadersFromArray(headers);
11112 }
11113 return mockDispatch2.headers(headers ? lowerCaseEntries(headers) : {});
11114 }
11115 if (typeof mockDispatch2.headers === "undefined") {
11116 return true;
11117 }
11118 if (typeof headers !== "object" || typeof mockDispatch2.headers !== "object") {
11119 return false;
11120 }

Callers

nothing calls this directly

Calls 8

buildKeyFunction · 0.70
getMockDispatchFunction · 0.70
__spreadValuesFunction · 0.70
deleteMockDispatchFunction · 0.70
setTimeoutFunction · 0.70
handleReplyFunction · 0.70
callbackMethod · 0.45
onErrorMethod · 0.45

Tested by

no test coverage detected