Skip to content

Commit

Permalink
refactor(fetch/response): inline defaultInnerResponse (#12235)
Browse files Browse the repository at this point in the history
Not useful to have the defaults externally defined when they're only used in `newInnerResponse()`. Also match order in `newInnerResponse()` and `cloneInnerResponse`
  • Loading branch information
AaronO authored Sep 26, 2021
1 parent 5788f2e commit 34a1554
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions ext/fetch/23_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
},
};
}

Expand Down

0 comments on commit 34a1554

Please sign in to comment.