peterolson / BigInteger.js

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

Improve the use of forced eval #165

Closed ty-everett closed 5 years ago

ty-everett commented 5 years ago

The library uses eval when using native implementation because ** is syntax error, but when we are forced to use eval the best way is to use it in a non-polluting way.

What I mean is that when this is used with rollup it makes it impossible to use some efficiencies

https://rollupjs.org/guide/en#avoiding-eval

Where eval is used, we should use this instead:

let globalEval = eval;
globalEval("(a,b)=>a**b");

Let me know any thoughts on this

peterolson commented 5 years ago

This should already be taken care of, since eval is only executed once to create the pow function.

See commit 2ca52567ae34e0f0d869cb10c78d234afa344cb5