Closed ppKrauss closed 5 years ago
At least, you can modify the prototype:
bigInt.prototype.test = function () {
console.log("Hello!");
};
Thanks @Yaffle , yes. Well... There are plans to rewrite all BigInter module for ES6, as lightweight package, a class for "only complementar methods to native BigInt"?
You could use bigInt(1).constructor
to get the constructor function and extend that, but I don't recommend it because behind the scenes there are three different constructors: BigInteger
, SmallInteger
, and NativeBigInt
, and the library chooses between them based on the size of the number and the environment's support for native big integers.
I don't know what your use-case is, but I can't think of any benefit of extending BigInt that you couldn't do with a simple wrapper.
There are no plans to rewrite BigInteger in ES6+ - I still plan to maintain backwards compatibility with ES5 environments.
See https://stackoverflow.com/q/54639345/287948