Skip to content

Commit

Permalink
replace makeFilteredResponse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed Mar 22, 2022
1 parent a3f121e commit 7137e03
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions lib/fetch/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,14 @@ function makeNetworkError (reason) {
}

function makeFilteredResponse (response, state) {
state = {
internalResponse: response,
...state
}

return new Proxy(response, {
get (target, p) {
return p in state ? state[p] : target[p]
},
set (target, p, value) {
assert(!(p in state))
target[p] = value
return true
}
})
// https://fetch.spec.whatwg.org/#concept-filtered-response
// A filtered response has a corresponding internalResponse, which is its
// response. However, a key accessed in the response object must also be
// available in its internal response (and vice versa).
const cloned = cloneResponse(response)
Object.assign(response, { internalResponse: cloned }, state)

return response
}

// https://fetch.spec.whatwg.org/#concept-filtered-response
Expand Down

0 comments on commit 7137e03

Please sign in to comment.