New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch: replace Proxy
objects
#1299
Conversation
@@ -149,6 +150,60 @@ class HeadersList extends Array { | |||
} | |||
} | |||
|
|||
class FilteredHeadersList extends HeadersList { | |||
/** @type {(name: string) => boolean} */ | |||
filter = () => true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed babel-eslint
for standard because it couldn't parse this properly. There's an issue on github with this solution I can pull up if you need.
Codecov Report
@@ Coverage Diff @@
## main #1299 +/- ##
==========================================
- Coverage 94.18% 94.14% -0.05%
==========================================
Files 44 44
Lines 4145 4148 +3
==========================================
+ Hits 3904 3905 +1
- Misses 241 243 +2
Continue to review full report at Codecov.
|
*/ | ||
constructor (headersList, filter) { | ||
super() | ||
this.push(...headersList) // copy values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can’t copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A filtered object is a view on the internal object. It’s not enough to have a copy.
So what you need to do here is: Implement a Implement a |
That makes sense and I definitely see why you chose proxies. I don't think a filtered response view is possible without Proxy, unless we know which keys will be set (in doing so we can then define getters or setters for each property... which might just be as slow). Headers should be possible, but I'd rather get both of these together rather than separately. |
@ronag I've thought about this quite a bit and came up with a possibly acceptable solution (I know this is an old issue...); I think However, I don't think server-environments (deno, cf) even do this filtering in the first place and I don't see the benefit of keeping it in. |
Should alleviate most perf regressions in #1295, I still have no idea what a filtered response is and it's most likely wrong, but all of the tests pass.
I'll add tests later... it's late here