[x] I have ensured my pull request is not behind the main or master branch of the original repository.
[x] I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
[x] I have written a commit message that passes commitlint linting.
[x] I have ensured that my code changes pass linting tests.
[x] I have ensured that my code changes pass unit tests.
[x] I have described my pull request and the reasons for code changes along with context if necessary.
Problem
The recent changes introduced in https://github.com/ladjs/superagent/pull/1773 restricts the usage of BigInt with the .send() method, even if the BigInt object has a .toJSON method. In scenarios where developers want to serialize BigInt properties to JSON, this becomes a limitation.
Change
This pull request modifies the existing checks on BigInt values passed to the .send() method. With this change, if a BigInt property has a .toJSON method, it will not throw the "Cannot serialize BigInt value to json" error.
Checklist
Problem
The recent changes introduced in https://github.com/ladjs/superagent/pull/1773 restricts the usage of
BigInt
with the.send()
method, even if theBigInt
object has a.toJSON
method. In scenarios where developers want to serializeBigInt
properties to JSON, this becomes a limitation.Change
This pull request modifies the existing checks on
BigInt
values passed to the.send()
method. With this change, if aBigInt
property has a.toJSON
method, it will not throw the "Cannot serialize BigInt value to json" error.