1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00

refactor(fetch/response): inline defaultInnerResponse (#12235)

Not useful to have the defaults externally defined when they're only used in `newInnerResponse()`. Also match order in `newInnerResponse()` and `cloneInnerResponse`
This commit is contained in:
Aaron O'Mullan 2021-09-26 23:46:56 +02:00 committed by GitHub
parent 5788f2e082
commit 34a15545c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,37 +101,33 @@
type: response.type,
body,
headerList,
url() {
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
urlList,
status: response.status,
statusMessage: response.statusMessage,
aborted: response.aborted,
url() {
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
};
}
const defaultInnerResponse = {
type: "default",
body: null,
aborted: false,
url() {
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
};
/**
* @returns {InnerResponse}
*/
function newInnerResponse(status = 200, statusMessage = "") {
return {
type: "default",
body: null,
headerList: [],
urlList: [],
status,
statusMessage,
...defaultInnerResponse,
aborted: false,
url() {
if (this.urlList.length == 0) return null;
return this.urlList[this.urlList.length - 1];
},
};
}