Proposal: `is.create(URLSearchParams)`
const isSearchParams = is.create(URLSearchParams);
is.any([is.string, isSearchParams]);
Can you describe how exactly it should behave? Because you're passing in the constructor, which would mean you want a instanceof check internally, but that's not a good or portable way to check.
that's not a good or portable way to check.
Is there a better choice? We could compare the names but that's not good either - e.g. there are many FormData implementations but they differ.
The create function returns another function. But it can have an extra feature: if used with any it will display that class name: E.g. Expected string or URLSearchParams instance, got ...
Pass in a string and use https://github.com/sindresorhus/is/blob/238e8c80c7de926f62d3d0e903a257bf32667d0d/source/index.ts#L100
That's how most of the testing is done here.
Yes, we could read the name from the passed in constructor. I just fear that it will make people assume it does instance checking, which it does not.