Skip to content

Commit b01fb9f

Browse files
committed
Use node-bignum instead of node-bigint
bignum is actively maintained and works with newer versions of Node.js
1 parent 7c29fe7 commit b01fb9f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/vm/js/nqp-runtime/bignum.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var reprs = require('./reprs.js');
22

3-
var bigint = require('bigint');
3+
var bignum = require('bignum');
44

55
var op = {};
66
exports.op = op;
@@ -31,7 +31,7 @@ function getBI(obj) {
3131
}
3232

3333
op.fromstr_I = function(str, type) {
34-
return makeBI(type,bigint(str));
34+
return makeBI(type,bignum(str));
3535
};
3636

3737
op.tostr_I = function(n) {
@@ -76,7 +76,7 @@ op.expmod_I = function(a, b, c, type) {
7676

7777
op.div_In = function(a, b) {
7878
var digits = 1e+20;
79-
return getBI(a).mul(bigint(digits)).div(getBI(b)).toNumber()/digits;
79+
return getBI(a).mul(bignum(digits)).div(getBI(b)).toNumber()/digits;
8080
};
8181

8282
op.rand_I = function(max, type) {
@@ -138,11 +138,11 @@ op.tonum_I = function(n) {
138138
};
139139

140140
op.fromnum_I = function(num, type) {
141-
// node-bigint bug workaround, when a negative number is too big it gets turned into 0
141+
// node-bignum bug workaround, when a negative number is too big it gets turned into 0
142142
if (num < 0) {
143-
return makeBI(type,bigint(-num).neg());
143+
return makeBI(type,bignum(-num).neg());
144144
} else {
145-
return makeBI(type,bigint(num));
145+
return makeBI(type,bignum(num));
146146
}
147147
};
148148

src/vm/js/nqp-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
"fallback-exec-sync": "*",
1414
"node-int64": "*",
1515
"sha1": "*",
16-
"bigint": "*"
16+
"bignum": "*"
1717
}
1818
}

src/vm/js/nqp-runtime/reprs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ VMIter.prototype.deserialize_finish = function(object, data) {
396396
VMIter.prototype.type_object_for = basic_type_object_for;
397397
exports.VMIter = VMIter;
398398

399-
var bigint = require('bigint');
399+
var bignum = require('bignum');
400400

401401
function P6bigint() {
402402
}
@@ -407,7 +407,7 @@ P6bigint.prototype.type_object_for = function(HOW) {
407407
var type_object = this.basic_type_object_for(HOW);
408408

409409
this._STable.addInternalMethod('$$set_int', function(value) {
410-
this.value = bigint(value);
410+
this.value = bignum(value);
411411
});
412412

413413
this._STable.addInternalMethod('$$get_int', function() {
@@ -427,7 +427,7 @@ P6bigint.prototype.type_object_for = function(HOW) {
427427

428428
P6bigint.prototype.generateBoxingMethods = function(repr, attr) {
429429
repr._STable.addInternalMethod('$$set_int', function(value) {
430-
this[attr.name] = bigint(value);
430+
this[attr.name] = bignum(value);
431431
});
432432

433433
repr._STable.addInternalMethod('$$get_int', function() {

0 commit comments

Comments
 (0)