aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/big_number_input.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-10-30 01:58:11 +0800
committerGitHub <noreply@github.com>2018-10-30 01:58:11 +0800
commitfdf9e860dedf5dbe7840951f304a33ac2d7b1b51 (patch)
tree2acfc843dce83d5f8643980f9c74af25d12a18df /packages/instant/src/util/big_number_input.ts
parent4e4291eccdd6c837bbec70603aa6eb64d3aa8d85 (diff)
parent3f35239b27653da898218e53909982203fad6d17 (diff)
downloaddexon-0x-contracts-fdf9e860dedf5dbe7840951f304a33ac2d7b1b51.tar.gz
dexon-0x-contracts-fdf9e860dedf5dbe7840951f304a33ac2d7b1b51.tar.zst
dexon-0x-contracts-fdf9e860dedf5dbe7840951f304a33ac2d7b1b51.zip
Merge pull request #1187 from 0xProject/feature/instant/fixed-orders-in-render-method
[instant] Add ability to toggle render settings through URL, flash error on incorrect network, provided liquidity
Diffstat (limited to 'packages/instant/src/util/big_number_input.ts')
-rw-r--r--packages/instant/src/util/big_number_input.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/packages/instant/src/util/big_number_input.ts b/packages/instant/src/util/big_number_input.ts
index d2a9a8dc5..370d91a0a 100644
--- a/packages/instant/src/util/big_number_input.ts
+++ b/packages/instant/src/util/big_number_input.ts
@@ -10,14 +10,19 @@ import * as _ from 'lodash';
*/
export class BigNumberInput extends BigNumber {
private readonly _isEndingWithDecimal: boolean;
- constructor(bigNumberString: string) {
- const hasDecimalPeriod = _.endsWith(bigNumberString, '.');
- let internalString = bigNumberString;
- if (hasDecimalPeriod) {
- internalString = bigNumberString.slice(0, -1);
+ constructor(numberOrString: string | number) {
+ if (_.isString(numberOrString)) {
+ const hasDecimalPeriod = _.endsWith(numberOrString, '.');
+ let internalString = numberOrString;
+ if (hasDecimalPeriod) {
+ internalString = numberOrString.slice(0, -1);
+ }
+ super(internalString);
+ this._isEndingWithDecimal = hasDecimalPeriod;
+ } else {
+ super(numberOrString);
+ this._isEndingWithDecimal = false;
}
- super(internalString);
- this._isEndingWithDecimal = hasDecimalPeriod;
}
public toDisplayString(): string {
const internalString = super.toString();