peterolson / BigInteger.js

An arbitrary length integer library for Javascript
The Unlicense
1.12k stars 187 forks source link

Asynchronous Module Definition returns undefined #199

Open esfoden opened 4 years ago

esfoden commented 4 years ago

hi all, I love the BigInteger library, its fast and the BigInt polyfill mechanism is very useful.

Unfortunately it doesn't seem to work with AMD modules. Using require.js v 2.3.6:

requirejs(["./node_modules/big-integer/BigInteger"], function (big) {

the returned "big" variable is undefined. The problem seems to be at line 1450 of BigInteger.js:

define("big-integer", [], function () {

there are two problems here. Firstly it is the user of the module that names it (I named it "big" above) not the module itself and secondly "big-integer" is not a valid javascript identifier.

The solution is easy: change 1450 to:

define( function () {

and it all works beautifully. I thought I would post the issue here for verification and discussion before submitting a pull request.

peterolson commented 4 years ago

Thanks, feel free to submit a pull request.