bn.js
bn.js copied to clipboard
BigInt support?
I was wondering if there was any plan to support BigInt when available in the environment?
https://developers.google.com/web/updates/2018/05/bigint
Edit (08-2023): I made this library which I now use for dapps: https://github.com/bpierre/dnum
Really important!
What you like to see as BigInt support? Accept BigInt in constructor/methods?
Basically that or something similar. BigInt is becoming popular. A library I am writing I would like to support it for public methods as a dataype. Internally we use your library and it would be nice if it was super easy to convert between the two so supporting it in the constructor would be useful, or some static method to construct a BN from a BigInt would be great. To BigInt methods would also be very useful.
What about duplicate the library API with BigInt, there is no need to have all the code for operations if you can use native JS operators like add can be just +. It would be awesome to import this thinner library if BigInt have native support.
@jcubic I reimplemented all the methods using BigInt keeping the same API https://github.com/alexandrius/bn.js-bigint
Major benefits are creating instances and stringifying them, other than that I wouldn't suggest migrating. Here's the benchmark results: https://github.com/alexandrius/bn.js-bigint/blob/master/bench.txt