-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
Allow explicitly unsetting hooks on .extend()
#599
Allow explicitly unsetting hooks on .extend()
#599
Conversation
The implementation here is pretty simple: just give hook merging some custom logic so it either merges OR resets to an empty array. Matches what was discussed in the related ticket. Documentation has been updated to describe this behavior as well. The dedicated test is just a modified copy of the existing `ky.extend()` one. Admittedly, I did modify a couple of other tests to cover the edge cases instead of building brand new tests. No reason other than noticing they were already close to what I needed and I'm being lazy. Closes #408
I left my thoughts on this approach here: #408 (comment) TL;DR: I don't like it. It continues down a path that is too convoluted and magical for my taste. That aside, the implementation in this PR looks good to me. |
…le-retry-after-statuses into kesills-better-extend-hooks Manual resolutions required: - Conflicts between my updated `extend()` tests in `test/main.ts` and the tests added with the new function form of `extend()`. Resolved by accepting their modified base test and just adding my changes, then putting my new `extend()` test below all their new cases. - Trivial resolution for import formatting in `source/core/Ky.ts`. - A change to `newHookValue` in `source/utils/merge.ts`, using `Object.hasOwn` per the linter's suggestion.
@sholladay This should be ready for re-review, following your latest comment in the related ticket. Conflict resolutions described in the merge commit. Thanks! |
.extend()
.extend()
LGTM. Thanks for the great discussion about how to incrementally improve the extend/merge logic. |
* feat: allow explicitly unsetting hooks on `.extend()` The implementation here is pretty simple: just give hook merging some custom logic so it either merges OR resets to an empty array. Matches what was discussed in the related ticket. Documentation has been updated to describe this behavior as well. The dedicated test is just a modified copy of the existing `ky.extend()` one. Admittedly, I did modify a couple of other tests to cover the edge cases instead of building brand new tests. No reason other than noticing they were already close to what I needed and I'm being lazy. Closes sindresorhus#408 * chore: remove unused import
Ref: #408
The implementation here is pretty simple: just give hook merging some custom logic, so it either merges OR resets to an empty array. Matches what was discussed in the related ticket.
Documentation has been updated to describe this behavior as well.
The dedicated test is just a modified copy of the existing
ky.extend()
one. Admittedly, I did modify a couple of other tests to cover the edge cases instead of building brand-new tests. No reason other than noticing they were already close to what I needed.. and I'm being lazy. 😅