Re: [whatwg/url] URLSearchParams delete all vs delete one (#335)

I like the idea of overloading `has()` at the same time. (`set()` would be more complicated given `FormData`. Separate issue if you want to pursue that please.)

It sounds like there's three different use cases for deleting by key and value:

* Remove all. This would be `while(sp.has(key, value)) sp.delete(key, value)` under delete one semantics. Not great in my opinion.
* Remove duplicates. I think this is already covered through `sp.set(key, value)`. Potentially with a `sp.has(key, value)` conditional, depending on what local knowledge you have.
* Remove one. This is the use case that is a bit unclear to me. Giving it the most straightforward API seems rather suspect.

My inclination based on this analysis would be to go with removal all semantics for `delete(key, value)` and maybe offer `delete(key, value, { onlyFirst:true })` if someone comes up with a great use case.

(HTTP headers are represented by [`Headers`](https://fetch.spec.whatwg.org/#headers) and while that used to be more similar (it had `getAll()`), it was simplified to more closely match the actual HTTP semantics and as such it's no longer a good match for a multimap.)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/335#issuecomment-1326235988
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/335/1326235988@github.com>

Received on Thursday, 24 November 2022 10:15:15 UTC