aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/utils/utils.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-11 23:38:51 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-14 16:35:13 +0800
commitb74957acdfc8d67d154bcb4698acd7575db7cc47 (patch)
tree3f33c2faac3b55e52098ab0b5b9883a9b62f5aee /packages/website/ts/utils/utils.ts
parent6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b (diff)
downloaddexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.gz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.bz2
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.lz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.xz
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.zst
dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.zip
Add missing type definitions
Diffstat (limited to 'packages/website/ts/utils/utils.ts')
-rw-r--r--packages/website/ts/utils/utils.ts28
1 files changed, 14 insertions, 14 deletions
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 472870f31..bf30f4e04 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -25,15 +25,15 @@ const LG_MIN_EM = 64;
const MD_MIN_EM = 52;
export const utils = {
- assert(condition: boolean, message: string) {
+ assert(condition: boolean, message: string): void {
if (!condition) {
throw new Error(message);
}
},
- spawnSwitchErr(name: string, value: any) {
+ spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
- isNumeric(n: string) {
+ isNumeric(n: string): boolean {
return !isNaN(parseFloat(n)) && isFinite(Number(n));
},
// This default unix timestamp is used for orders where the user does not specify an expiry date.
@@ -106,13 +106,13 @@ export const utils = {
};
return order;
},
- async sleepAsync(ms: number) {
- return new Promise(resolve => setTimeout(resolve, ms));
+ async sleepAsync(ms: number): Promise<NodeJS.Timer> {
+ return new Promise<NodeJS.Timer>(resolve => setTimeout(resolve, ms));
},
- deepEqual(actual: any, expected: any, opts?: { strict: boolean }) {
+ deepEqual(actual: any, expected: any, opts?: { strict: boolean }): boolean {
return deepEqual(actual, expected, opts);
},
- getColSize(items: number) {
+ getColSize(items: number): number {
const bassCssGridSize = 12; // Source: http://basscss.com/#basscss-grid
const colSize = bassCssGridSize / items;
if (!_.isInteger(colSize)) {
@@ -120,7 +120,7 @@ export const utils = {
}
return colSize;
},
- getScreenWidth() {
+ getScreenWidth(): ScreenWidths {
const documentEl = document.documentElement;
const body = document.getElementsByTagName('body')[0];
const widthInPx = window.innerWidth || documentEl.clientWidth || body.clientWidth;
@@ -162,7 +162,7 @@ export const utils = {
// This checks the error message returned from an injected Web3 instance on the page
// after a user was prompted to sign a message or send a transaction and decided to
// reject the request.
- didUserDenyWeb3Request(errMsg: string) {
+ didUserDenyWeb3Request(errMsg: string): boolean {
const metamaskDenialErrMsg = 'User denied';
const paritySignerDenialErrMsg = 'Request has been rejected';
const ledgerDenialErrMsg = 'Invalid status 6985';
@@ -172,7 +172,7 @@ export const utils = {
_.includes(errMsg, ledgerDenialErrMsg);
return isUserDeniedErrMsg;
},
- getCurrentEnvironment() {
+ getCurrentEnvironment(): string {
switch (location.host) {
case configs.DOMAIN_DEVELOPMENT:
return 'development';
@@ -188,7 +188,7 @@ export const utils = {
const truncatedAddress = `${address.substring(0, 6)}...${address.substr(-4)}`; // 0x3d5a...b287
return truncatedAddress;
},
- hasUniqueNameAndSymbol(tokens: Token[], token: Token) {
+ hasUniqueNameAndSymbol(tokens: Token[], token: Token): boolean {
if (token.isRegistered) {
return true; // Since it's registered, it is the canonical token
}
@@ -269,7 +269,7 @@ export const utils = {
);
return isTestNetwork;
},
- getCurrentBaseUrl() {
+ getCurrentBaseUrl(): string {
const port = window.location.port;
const hasPort = !_.isUndefined(port);
const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}`;
@@ -302,10 +302,10 @@ export const utils = {
}
return parsedProviderName;
},
- isDevelopment() {
+ isDevelopment(): boolean {
return configs.ENVIRONMENT === Environments.DEVELOPMENT;
},
- isStaging() {
+ isStaging(): boolean {
return _.includes(window.location.href, configs.DOMAIN_STAGING);
},
};