Closed wanghm25 closed 1 year ago
I found a problem with code like this (typescript):
import sizeof from "object-sizeof"; const obj = { num: BigInt(123123123123123123), } console.log(sizeof(obj));
And get error:
Error detected, return -1 TypeError: Do not know how to serialize a BigInt at JSON.stringify (<anonymous>) at objectSizeComplex (/Users/bytedance/node/node_modules/object-sizeof/indexv2.js:62:33) ...
The reason is, there is a JSON.stringify in objectSizeComplex: const objectToString = JSON.stringify(potentialConversion)
JSON.stringify
objectSizeComplex
I think,there should be a recursive call in objectSizeComplex
Ye, same issue
JSON.stringify( Object, (key, value) => (typeof value === 'bigint' ? value.toString() : value) // return everything else unchanged )
just add this
I found a problem with code like this (typescript):
And get error:
The reason is, there is a
JSON.stringify
inobjectSizeComplex
: const objectToString = JSON.stringify(potentialConversion)I think,there should be a recursive call in
objectSizeComplex