[proposal] Enhanced the ability for multiple same-name-parameters to the URLSearchParams: .has() and .delete()
The proposal is fully compatible with the existing scheme. There has a similar idea https://github.com/whatwg/url/issues/335, but not exactly same.
.has()
Syntax
URLSearchParams.has(name, [value])
The changes
- Added optional second parameter
.delete()
Syntax
URLSearchParams.delete(name, [value])
Return value Number of parameters deleted, greater than or equal to 0.
The changes
- Added optional second parameter
- Added return value, this is very useful
https://github.com/whatwg/url/issues/335#issuecomment-623477090 applies here as well:
What would help in driving this forward is some indication that this is a common need (e.g., StackOverflow questions) and is being addressed in libraries (with the proposed semantics). That might make this a more compelling case to implementers.
Not sure if we need a .has(key, value), since it's equivalent to .getAll(key).include(value). The possibility of adding a return value to delete is interesting though, since Map.prototype.delete returns a boolean for whether an entry was deleted.
@LIXiangChen can you elaborate on when you would use the return value?