···3737 <div id="tree"></div>
3838 </div>
3939 <form>
4040- <textarea id="area" rows="8"></textarea>
4040+ <textarea id="area" rows="8" placeholder="Paste hex or base64 or PEM encoded ASN.1 BER or DER structures here, or load a file."></textarea>
4141 <br>
4242 <br>
4343 <label title="can be slow with big files"><input type="checkbox" id="wantHex" checked="checked"> with hex dump</label>
+13-7
int10.js
···1313// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1414// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15151616-let max = 10000000000000; // biggest 10^n integer that can still fit 2^53 when multiplied by 256
1616+/** Biggest 10^n integer that can still fit 2^53 when multiplied by 256. */
1717+const max = 10000000000000;
17181819export class Int10 {
1920 /**
···26272728 /**
2829 * Multiply value by m and add c.
2929- * @param {number} m - multiplier, must be < =256
3030- * @param {number} c - value to add
3030+ * @param {number} m - multiplier, must be 0<m<=256
3131+ * @param {number} c - value to add, must be c>=0
3132 */
3233 mulAdd(m, c) {
3434+ // assert(m > 0)
3335 // assert(m <= 256)
3636+ // assert(c >= 0)
3437 let b = this.buf,
3538 l = b.length,
3639 i, t;
···71747275 /**
7376 * Convert to decimal string representation.
7474- * @param {*} base - optional value, only value accepted is 10
7777+ * @param {number} [base=10] - optional value, only value accepted is 10
7878+ * @returns {string} The decimal string representation.
7579 */
7676- toString(base) {
7777- if ((base || 10) != 10)
7878- throw 'only base 10 is supported';
8080+ toString(base = 10) {
8181+ if (base != 10)
8282+ throw new Error('only base 10 is supported');
7983 let b = this.buf,
8084 s = b[b.length - 1].toString();
8185 for (let i = b.length - 2; i >= 0; --i)
···8690 /**
8791 * Convert to Number value representation.
8892 * Will probably overflow 2^53 and thus become approximate.
9393+ * @returns {number} The numeric value.
8994 */
9095 valueOf() {
9196 let b = this.buf,
···9710298103 /**
99104 * Return value as a simple Number (if it is <= 10000000000000), or return this.
105105+ * @returns {number | Int10} The simplified value.
100106 */
101107 simplify() {
102108 let b = this.buf;