Skip to content
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

Add support for passing a function to ky.extend() #611

Merged

Conversation

mfulton26
Copy link
Contributor

callback function receives parent's default options to allow extended instance to refer to modify parent options

Closes #586

callback function receives parent's default options to allow extended instance to refer to modify parent options

Closes sindresorhus#586
@sholladay
Copy link
Collaborator

Thanks for working on this, looking good.

Can you add a few more permutations to the tests? In particular, I want to make sure we cover:

  1. What happens when the extend function ignores the parent options, i.e. is the prefixUrl still set if extend doesn't set it?
  2. The behavior of setting nested options, such as hooks. Does setting a hook add to or replace the parent's hooks?

@mfulton26
Copy link
Contributor Author

@sholladay I've added some more test cases. I believe I've captured what you were targeting.

@sholladay
Copy link
Collaborator

Such a simple change, yet I think this will be a popular feature and cleanly solve a lot of use cases. Thanks again!

@sholladay sholladay changed the title feat(extend): support function options Add support for passing a function to ky.extend() Jul 19, 2024
@sholladay sholladay merged commit 9587c9d into sindresorhus:main Jul 19, 2024
1 check passed
@mfulton26 mfulton26 deleted the feat(extend)--support-function-options branch July 19, 2024 18:30
@mfulton26
Copy link
Contributor Author

Such a simple change, yet I think this will be a popular feature and cleanly solve a lot of use cases. Thanks again!

I agree. Thank you for helping me add this change. I look forward to using it in my own projects!

@joshgummersall
Copy link

Will this be published soon? Doesn't look like this landed in 1.4.0.

@sindresorhus
Copy link
Owner

@joshgummersall
Copy link

Ah wow, thanks so much for getting to this to fast! Appreciate it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow extend() to append to prefixUrl
4 participants