Describe the bug
isJSONSerializable correctly excludes FormData and URLSearchParams instances (which aren't JSON serializable). However, it also returns false for EMPTY FormData and URLSearchParams instances, which could arguably be treated as serializable (they'd serialize to {}).
More critically, the check value.buffer on line 31 can throw for certain edge cases before reaching the instanceof checks.
Suggested improvement
Move the instanceof checks before the value.buffer check to ensure safer type discrimination.
Environment
Describe the bug
isJSONSerializablecorrectly excludesFormDataandURLSearchParamsinstances (which aren't JSON serializable). However, it also returnsfalsefor EMPTYFormDataandURLSearchParamsinstances, which could arguably be treated as serializable (they'd serialize to{}).More critically, the check
value.bufferon line 31 can throw for certain edge cases before reaching theinstanceofchecks.Suggested improvement
Move the
instanceofchecks before thevalue.buffercheck to ensure safer type discrimination.Environment