Check for invalid strings in BigNumber constructor. (#219)

This commit is contained in:
Richard Moore 2018-07-03 14:58:24 -04:00
parent b1d026b800
commit 8e83ceaedc
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

@ -45,6 +45,9 @@ export class BigNumber {
} else if (value.match(/^-?[0-9]*$/)) { } else if (value.match(/^-?[0-9]*$/)) {
if (value == '') { value = '0'; } if (value == '') { value = '0'; }
defineReadOnly(this, '_bn', new BN.BN(value)); defineReadOnly(this, '_bn', new BN.BN(value));
} else {
errors.throwError('invalid BigNumber string value', errors.INVALID_ARGUMENT, { arg: 'value', value: value });
} }
} else if (typeof(value) === 'number') { } else if (typeof(value) === 'number') {