Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor response create function outside of promise handler#132

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
kalisjoshua wants to merge6 commits intodevelopit:main
base:main
Choose a base branch
Loading
fromkalisjoshua:refactor-and-tests

Conversation

kalisjoshua
Copy link

not sure that this is favorable or not but thought that it might be and it allows
for easier testing of the creation of responses and their properties.

@developit
Copy link
Owner

This will depend on the size impact - I've updated the repo to include a size check, we'll see what it nets.

@developit
Copy link
Owner

Ah - it looks like this adds a named export to the actual unfetch package, which means it won't work - folks using CommonJS will have to doimport('unfetch').default which is a breaking change.

Instead, if we could retrofit your work here into proper support for theResponse interface, that would definitely be a justifiable export! It would be a nice step towards supportingHeaders,Request andResponse, something that's been on my todo list for ages.

kalisjoshua reacted with thumbs up emoji

@kalisjoshua
Copy link
Author

FilenameSizeChange
dist/unfetch.es.js553 B+47 B (8%)🔍
dist/unfetch.js548 B+43 B (7%)🔍
dist/unfetch.umd.js627 B+49 B (7%)🔍

@developit
Copy link
Owner

@kalisjoshua that'll be the added export. One quick solution to check this would be to move theresponse function into a separate file (src/lib/response.mjs) that is imported bysrc/index.mjs and tests, that way it's not exported asunfetch.response.

kalisjoshua reacted with thumbs up emoji

not sure that this is favorable or not but thought that it might be and it allowsfor easier testing of the creation of responses and their properties.
@kalisjoshua
Copy link
Author

This is done now.

@kalisjoshua that'll be the added export. One quick solution to check this would be to move theresponse function into a separate file (src/lib/response.mjs) that is imported bysrc/index.mjs and tests, that way it's not exported asunfetch.response.

I will look into theResponse interface compatibility.

@kalisjoshua
Copy link
Author

FilenameSizeChange
dist/unfetch.es.js544 B+38 B (6%)🔍
dist/unfetch.js543 B+38 B (6%)🔍
dist/unfetch.umd.js617 B+39 B (6%)🔍

@developit
Copy link
Owner

Interesting that the numbers are still so increased. My guess is that's because we're ending up with a closure around the two top-level functions, whereas currently there is no closure required since all functionality exists within the singleunfetch(){} function (as a sort of wrapper + implementation). Perhaps that's just something that we'll be giving up.

@kalisjoshua
Copy link
Author

It's interesting to look at the compiled output diff ofdist/unfetch.js between the master branch and my branch. On the master branch thefor loop is expanded a little but on my branch the loop is most of the body of the function. I'm still examining it to see if there is anything that can be done to bring the output sizes closer because there isn't an extra closure.

@kalisjoshua
Copy link
Author

I think the biggest contributor to the bloat that I created is because of the lifting of theresponse function out of the scope necessitating that arguments be passed in and that also results in a more complicatedclone attribute on the response object. I am able to slim the output size a slight bit; encapsulated in the most recent commit.

@kalisjoshua
Copy link
Author

FilenameSizeChange
dist/unfetch.es.js534 B+23 B (4%)
dist/unfetch.js534 B+24 B (4%)
dist/unfetch.umd.js605 B+23 B (3%)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@developitdevelopitAwaiting requested review from developit

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@kalisjoshua@developit@jkalis-rm

[8]ページ先頭

©2009-2025 Movatter.jp