long.js icon indicating copy to clipboard operation
long.js copied to clipboard

Add support for BigInt (closes #82)

Open trevorah opened this issue 3 years ago • 0 comments

There isn't much logic here as BigInt's conversions are being done using its string representations, but I've got tests anyways.

On environments that don't support BigInt, everything else works fine except toBigInt().

Node.js v16.13.1 repl:

> const Long = require('.');
undefined
> Long.fromValue(0).toInt()
0
> Long.fromValue(0).toBigInt()
0n

Node.js v8.17.0 repl:

> const Long = require('.');
undefined
> Long.fromValue(0).toInt()
0
> Long.fromValue(0).toBigInt()
ReferenceError: BigInt is not defined
    at Long.toBigInt (/Users/trevorah/Development/long.js/umd/index.js:514:5)

trevorah avatar Jan 07 '22 17:01 trevorah