Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigint support ? #54

Closed
Truth1984 opened this issue Oct 31, 2020 · 2 comments · Fixed by #75
Closed

bigint support ? #54

Truth1984 opened this issue Oct 31, 2020 · 2 comments · Fixed by #75
Labels

Comments

@Truth1984
Copy link

var sizeof = require('object-sizeof');
sizeof(10n) == 0; //true
@Truth1984
Copy link
Author

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

@miktam miktam added the bug label Oct 31, 2020
daneren2005 added a commit to daneren2005/sizeof that referenced this issue Jan 26, 2022
This is to handle issues miktam#53, miktam#54, miktam#55.  It keeps the questionable decision to count an objects/maps/etc as 0 bytes when realistically they should count as at least one byte.
@miktam
Copy link
Owner

miktam commented Jan 28, 2023

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

bigint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants