mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 00:54:02 -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,
|
type: response.type,
|
||||||
body,
|
body,
|
||||||
headerList,
|
headerList,
|
||||||
url() {
|
|
||||||
if (this.urlList.length == 0) return null;
|
|
||||||
return this.urlList[this.urlList.length - 1];
|
|
||||||
},
|
|
||||||
urlList,
|
urlList,
|
||||||
status: response.status,
|
status: response.status,
|
||||||
statusMessage: response.statusMessage,
|
statusMessage: response.statusMessage,
|
||||||
aborted: response.aborted,
|
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}
|
* @returns {InnerResponse}
|
||||||
*/
|
*/
|
||||||
function newInnerResponse(status = 200, statusMessage = "") {
|
function newInnerResponse(status = 200, statusMessage = "") {
|
||||||
return {
|
return {
|
||||||
|
type: "default",
|
||||||
|
body: null,
|
||||||
headerList: [],
|
headerList: [],
|
||||||
urlList: [],
|
urlList: [],
|
||||||
status,
|
status,
|
||||||
statusMessage,
|
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