andyperlitch / jsbn

The jsbn library is a fast, portable implementation of large-number math in pure JavaScript, enabling public-key crypto and other applications on desktop and mobile browsers.
Other
167 stars 41 forks source link

Implement automatic type conversion #13

Open kripod opened 8 years ago

kripod commented 8 years ago

As operator overloading is not allowed in javascript, it would be a logical step to allow more method argument types instead of sticking with BigInteger instances.

For example, it would be great if all the syntax below were valid:

const BIG_THREE = new BigInteger(3); // 3 is NOT a string
const BIG_SEVEN = BIG_THREE.add(4); // 4 is NOT a BigInteger
const BIG_ELEVEN = BIG_SEVEN.add('4') // '4' is NOT a BigInteger
const BIG_64 = BIG_ELEVEN.add('0x3f').subtract(10); // Parse HEX