node-bignum icon indicating copy to clipboard operation
node-bignum copied to clipboard

[Discussion] Any plans to support/fallback to native JavaScript BigInt?

Open jayands opened this issue 7 years ago • 1 comments

JS now has a BigInt syntax that's at stage 3. We might see it in ES2019 or 2020. Any plans to support the syntax for it, so as to provide a cross-platform (i.e., pre-Node 10.7) support for at least the string syntax so that people that have to develop for older stuff can take advantage of coming native support? it could even be a "future mode", a la python:

import BigInt from 'bignum/future';

const b = BigInt('782910138827292261791972728324982n')
    .sub('182373273283402171237474774728373n')
    .div('8n'); // or 8 the number

console.log(b); // '75067108192986261319312244199576n', as a string

jayands avatar Sep 03 '18 06:09 jayands

Should probably at least add a note towards the top of the README file that notes that one should favor BigInt if available (node 10.4+ etc), with a link to MDN.

  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility

tracker1 avatar Nov 15 '19 21:11 tracker1