sizeof icon indicating copy to clipboard operation
sizeof copied to clipboard

bigint support ?

Open Truth1984 opened this issue 4 years ago • 1 comments

var sizeof = require('object-sizeof');
sizeof(10n) == 0; //true

Truth1984 avatar Oct 31 '20 06:10 Truth1984

Technically, your calculation is wrong.

const v8 = require("v8");
const so = require("object-sizeof");

so(2147483647) // 8
so(2147483648) // 8, wrong
so(21474836480) // 8, wrong
so("") // 0, wrong
so("A") // 2, wrong

v8.serialize("").byteLength // 4
v8.serialize(2147483647).byteLength // 8
v8.serialize(2147483648).byteLength // 11

v8.serialize(0).byteLength // 4
v8.serialize("A").byteLength // 5 ascii 4 + 1
v8.serialize("中").byteLength // 6 unicode 4 + 2

Truth1984 avatar Oct 31 '20 07:10 Truth1984

Here is what ChatGPT suggests regarding the calculating of bigint size in bytes

bigint

miktam avatar Jan 28 '23 20:01 miktam