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:
parent
5788f2e082
commit
34a15545c9
1 changed files with 11 additions and 15 deletions
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
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];
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue