iden3 / ffjavascript

Finite Field Library in Javascript
GNU General Public License v3.0
52 stars 56 forks source link

stringify null object #125

Open krlosMata opened 1 year ago

krlosMata commented 1 year ago
krlosMata commented 11 months ago

The aim of the PR is not to protect against an invalid input, but to handle correctly the null in JS. JS interprets null as an object:

> typeof null
`object`

Therefore, the stringifyBigInts makes another recursion to call itself with null and the function breaks. Hence, null needs to be handle differently.

I understand the stringifyBigInts as an utility to convert any object that contains bigInts into the same object, but the bigInts converted as strings, an object ready to be converted to a JSON file via JSON.stringify(). In the current approachm if that input object a null, the function breaks. While the JSON.stringify() works well with null