diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-21 19:56:14 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-21 19:56:14 +0800 |
commit | 40a7be0690c81d2e42543aa075ef8da6606e7b7e (patch) | |
tree | 73231f3671133364b53d55074f27e03bd61a1d38 /src/utils/assert.ts | |
parent | 096d3bdb26921cb3e7d05e65dc286ddf49f98a8a (diff) | |
download | dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.gz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.bz2 dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.lz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.xz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.zst dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.zip |
Use different lodash import syntax which allows to include only used functions
Diffstat (limited to 'src/utils/assert.ts')
-rw-r--r-- | src/utils/assert.ts | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/utils/assert.ts b/src/utils/assert.ts index 94b119d5a..c4f1915e7 100644 --- a/src/utils/assert.ts +++ b/src/utils/assert.ts @@ -1,4 +1,10 @@ -import * as _ from 'lodash'; +import uniq from 'lodash/uniq'; +import isEmpty from 'lodash/isEmpty'; +import isObject from 'lodash/isObject'; +import isFinite from 'lodash/isFinite'; +import isString from 'lodash/isString'; +import isBoolean from 'lodash/isBoolean'; +import isUndefined from 'lodash/isUndefined'; import * as BigNumber from 'bignumber.js'; import * as Web3 from 'web3'; import {Web3Wrapper} from '../web3_wrapper'; @@ -9,17 +15,17 @@ const HEX_REGEX = /^0x[0-9A-F]*$/i; export const assert = { isBigNumber(variableName: string, value: BigNumber.BigNumber): void { - const isBigNumber = _.isObject(value) && value.isBigNumber; + const isBigNumber = isObject(value) && value.isBigNumber; this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value)); }, isUndefined(value: any, variableName?: string): void { - this.assert(_.isUndefined(value), this.typeAssertionMessage(variableName, 'undefined', value)); + this.assert(isUndefined(value), this.typeAssertionMessage(variableName, 'undefined', value)); }, isString(variableName: string, value: string): void { - this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value)); + this.assert(isString(value), this.typeAssertionMessage(variableName, 'string', value)); }, isHexString(variableName: string, value: string): void { - this.assert(_.isString(value) && HEX_REGEX.test(value), + this.assert(isString(value) && HEX_REGEX.test(value), this.typeAssertionMessage(variableName, 'HexString', value)); }, isETHAddressHex(variableName: string, value: string): void { @@ -36,19 +42,19 @@ export const assert = { }, async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> { const availableAddresses = await web3Wrapper.getAvailableAddressesAsync(); - this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 instance'); + this.assert(!isEmpty(availableAddresses), 'No addresses were available on the provided web3 instance'); }, hasAtMostOneUniqueValue(value: any[], errMsg: string): void { - this.assert(_.uniq(value).length <= 1, errMsg); + this.assert(uniq(value).length <= 1, errMsg); }, isNumber(variableName: string, value: number): void { - this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value)); + this.assert(isFinite(value), this.typeAssertionMessage(variableName, 'number', value)); }, isValidOrderHash(variableName: string, value: string): void { this.assert(utils.isValidOrderHash(value), this.typeAssertionMessage(variableName, 'orderHash', value)); }, isBoolean(variableName: string, value: boolean): void { - this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value)); + this.assert(isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value)); }, doesConformToSchema(variableName: string, value: object, schema: Schema): void { const schemaValidator = new SchemaValidator(); |