aboutsummaryrefslogtreecommitdiff
path: root/src/helpers.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 01:10:54 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 13:46:36 +0200
commit08bd3dc0e8a3c2370e4e8abbaa241eaafc144f4c (patch)
tree9a55a5734718e7c278ccb24733425184fb8cea34 /src/helpers.ts
parent7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (diff)
add linting rules and fix them
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/helpers.ts b/src/helpers.ts
index 5e3ef06d5..e5eb40211 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -30,7 +30,7 @@ import URI = require("urijs");
* settings such as significant digits or currency symbols.
*/
export function amountToPretty(amount: AmountJson): string {
- let x = amount.value + amount.fraction / Amounts.fractionalBase;
+ const x = amount.value + amount.fraction / Amounts.fractionalBase;
return `${x} ${amount.currency}`;
}
@@ -41,14 +41,14 @@ export function amountToPretty(amount: AmountJson): string {
* See http://api.taler.net/wallet.html#general
*/
export function canonicalizeBaseUrl(url: string) {
- let x = new URI(url);
+ const x = new URI(url);
if (!x.protocol()) {
x.protocol("https");
}
x.path(x.path() + "/").normalizePath();
x.fragment("");
x.query();
- return x.href()
+ return x.href();
}
@@ -59,23 +59,23 @@ export function canonicalizeBaseUrl(url: string) {
export function canonicalJson(obj: any): string {
// Check for cycles, etc.
JSON.stringify(obj);
- if (typeof obj == "string" || typeof obj == "number" || obj === null) {
- return JSON.stringify(obj)
+ if (typeof obj === "string" || typeof obj === "number" || obj === null) {
+ return JSON.stringify(obj);
}
if (Array.isArray(obj)) {
- let objs: string[] = obj.map((e) => canonicalJson(e));
- return `[${objs.join(',')}]`;
+ const objs: string[] = obj.map((e) => canonicalJson(e));
+ return `[${objs.join(",")}]`;
}
- let keys: string[] = [];
- for (let key in obj) {
+ const keys: string[] = [];
+ for (const key in obj) {
keys.push(key);
}
keys.sort();
let s = "{";
for (let i = 0; i < keys.length; i++) {
- let key = keys[i];
+ const key = keys[i];
s += JSON.stringify(key) + ":" + canonicalJson(obj[key]);
- if (i != keys.length - 1) {
+ if (i !== keys.length - 1) {
s += ",";
}
}
@@ -92,7 +92,7 @@ export function deepEquals(x: any, y: any): boolean {
return false;
}
- var p = Object.keys(x);
+ const p = Object.keys(x);
return Object.keys(y).every((i) => p.indexOf(i) !== -1) &&
p.every((i) => deepEquals(x[i], y[i]));
}
@@ -112,7 +112,7 @@ export function getTalerStampSec(stamp: string): number | null {
if (!m) {
return null;
}
- return parseInt(m[1]);
+ return parseInt(m[1], 10);
}
@@ -121,7 +121,7 @@ export function getTalerStampSec(stamp: string): number | null {
* Returns null if input is not in the right format.
*/
export function getTalerStampDate(stamp: string): Date | null {
- let sec = getTalerStampSec(stamp);
+ const sec = getTalerStampSec(stamp);
if (sec == null) {
return null;
}