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

Method addAll

github-actions/browserstack/set-browserstack-env.js:15841–15947  ·  view source on GitHub ↗
(_0)

Source from the content-addressed store, hash-verified

15839 });
15840 }
15841 addAll(_0) {
15842 return __async(this, arguments, function* (requests) {
15843 webidl.brandCheck(this, _Cache);
15844 const prefix = "Cache.addAll";
15845 webidl.argumentLengthCheck(arguments, 1, prefix);
15846 const responsePromises = [];
15847 const requestList = [];
15848 for (let request of requests) {
15849 if (request === void 0) {
15850 throw webidl.errors.conversionFailed({
15851 prefix,
15852 argument: "Argument 1",
15853 types: ["undefined is not allowed"]
15854 });
15855 }
15856 request = webidl.converters.RequestInfo(request);
15857 if (typeof request === "string") {
15858 continue;
15859 }
15860 const r = request[kState];
15861 if (!urlIsHttpHttpsScheme(r.url) || r.method !== "GET") {
15862 throw webidl.errors.exception({
15863 header: prefix,
15864 message: "Expected http/s scheme when method is not GET."
15865 });
15866 }
15867 }
15868 const fetchControllers = [];
15869 for (const request of requests) {
15870 const r = new Request(request)[kState];
15871 if (!urlIsHttpHttpsScheme(r.url)) {
15872 throw webidl.errors.exception({
15873 header: prefix,
15874 message: "Expected http/s scheme."
15875 });
15876 }
15877 r.initiator = "fetch";
15878 r.destination = "subresource";
15879 requestList.push(r);
15880 const responsePromise = createDeferredPromise();
15881 fetchControllers.push(fetching({
15882 request: r,
15883 processResponse(response) {
15884 if (response.type === "error" || response.status === 206 || response.status < 200 || response.status > 299) {
15885 responsePromise.reject(webidl.errors.exception({
15886 header: "Cache.addAll",
15887 message: "Received an invalid status code or the request failed."
15888 }));
15889 } else if (response.headersList.contains("vary")) {
15890 const fieldValues = getFieldValues(response.headersList.get("vary"));
15891 for (const fieldValue of fieldValues) {
15892 if (fieldValue === "*") {
15893 responsePromise.reject(webidl.errors.exception({
15894 header: "Cache.addAll",
15895 message: "invalid vary field value"
15896 }));
15897 for (const controller of fetchControllers) {
15898 controller.abort();

Callers 1

addMethod · 0.95

Calls 6

__asyncFunction · 0.70
urlIsHttpHttpsSchemeFunction · 0.70
createDeferredPromiseFunction · 0.70
fetchingFunction · 0.70
__privateMethodFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected