diff options
author | Brandon Millman <brandon@0xproject.com> | 2018-10-30 01:58:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-30 01:58:11 +0800 |
commit | fdf9e860dedf5dbe7840951f304a33ac2d7b1b51 (patch) | |
tree | 2acfc843dce83d5f8643980f9c74af25d12a18df /packages/instant/src/util/big_number_input.ts | |
parent | 4e4291eccdd6c837bbec70603aa6eb64d3aa8d85 (diff) | |
parent | 3f35239b27653da898218e53909982203fad6d17 (diff) | |
download | dexon-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.ts | 19 |
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(); |