aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/RequestThrottler.ts7
-rw-r--r--src/util/amounts.ts10
-rw-r--r--src/util/codec.ts2
-rw-r--r--src/util/helpers.ts12
-rw-r--r--src/util/http.ts14
-rw-r--r--src/util/query.ts6
-rw-r--r--src/util/talerconfig.ts2
-rw-r--r--src/util/taleruri-test.ts2
-rw-r--r--src/util/taleruri.ts2
-rw-r--r--src/util/timer.ts1
10 files changed, 26 insertions, 32 deletions
diff --git a/src/util/RequestThrottler.ts b/src/util/RequestThrottler.ts
index c99c7e949..d979fbfcf 100644
--- a/src/util/RequestThrottler.ts
+++ b/src/util/RequestThrottler.ts
@@ -21,12 +21,7 @@
/**
* Imports.
*/
-import {
- getTimestampNow,
- Timestamp,
- timestampSubtractDuraction,
- timestampDifference,
-} from "../util/time";
+import { getTimestampNow, timestampDifference } from "../util/time";
/**
* Maximum request per second, per origin.
diff --git a/src/util/amounts.ts b/src/util/amounts.ts
index da1c19233..5953f5130 100644
--- a/src/util/amounts.ts
+++ b/src/util/amounts.ts
@@ -67,11 +67,11 @@ export interface AmountJson {
}
export const codecForAmountJson = (): Codec<AmountJson> =>
- makeCodecForObject<AmountJson>()
- .property("currency", codecForString)
- .property("value", codecForNumber)
- .property("fraction", codecForNumber)
- .build("AmountJson");
+ makeCodecForObject<AmountJson>()
+ .property("currency", codecForString)
+ .property("value", codecForNumber)
+ .property("fraction", codecForNumber)
+ .build("AmountJson");
/**
* Result of a possibly overflowing operation.
diff --git a/src/util/codec.ts b/src/util/codec.ts
index 480e1eec7..136c5b053 100644
--- a/src/util/codec.ts
+++ b/src/util/codec.ts
@@ -346,4 +346,4 @@ export function makeCodecOptional<V>(
return innerCodec.decode(x, c);
},
};
-} \ No newline at end of file
+}
diff --git a/src/util/helpers.ts b/src/util/helpers.ts
index 0e19d7aba..7cd9e4234 100644
--- a/src/util/helpers.ts
+++ b/src/util/helpers.ts
@@ -39,7 +39,7 @@ export function amountToPretty(amount: AmountJson): string {
*
* See http://api.taler.net/wallet.html#general
*/
-export function canonicalizeBaseUrl(url: string) {
+export function canonicalizeBaseUrl(url: string): string {
if (!url.startsWith("http") && !url.startsWith("https")) {
url = "https://" + url;
}
@@ -145,13 +145,3 @@ export function strcmp(s1: string, s2: string): number {
}
return 0;
}
-
-/**
- * Run a function and return its result.
- *
- * Used as a nicer-looking way to do immediately invoked function
- * expressions (IFFEs).
- */
-export function runBlock<T>(f: () => T) {
- return f();
-}
diff --git a/src/util/http.ts b/src/util/http.ts
index 3842347dc..0ac989a17 100644
--- a/src/util/http.ts
+++ b/src/util/http.ts
@@ -136,9 +136,13 @@ export class BrowserHttpLib implements HttpRequestLibrary {
const headerMap = new Headers();
arr.forEach(function (line) {
const parts = line.split(": ");
- const header = parts.shift();
+ const headerName = parts.shift();
+ if (!headerName) {
+ console.error("invalid header");
+ return;
+ }
const value = parts.join(": ");
- headerMap.set(header!, value);
+ headerMap.set(headerName, value);
});
const resp: HttpResponse = {
status: myRequest.status,
@@ -156,7 +160,11 @@ export class BrowserHttpLib implements HttpRequestLibrary {
return this.req("get", url, undefined, opt);
}
- postJson(url: string, body: any, opt?: HttpRequestOptions): Promise<HttpResponse> {
+ postJson(
+ url: string,
+ body: any,
+ opt?: HttpRequestOptions,
+ ): Promise<HttpResponse> {
return this.req("post", url, JSON.stringify(body), opt);
}
diff --git a/src/util/query.ts b/src/util/query.ts
index 256395d42..8dd3ff1e2 100644
--- a/src/util/query.ts
+++ b/src/util/query.ts
@@ -292,7 +292,11 @@ export class TransactionHandle {
return requestToPromise(req);
}
- mutate<T>(store: Store<T>, key: any, f: (x: T) => T | undefined): Promise<void> {
+ mutate<T>(
+ store: Store<T>,
+ key: any,
+ f: (x: T) => T | undefined,
+ ): Promise<void> {
const req = this.tx.objectStore(store.name).openCursor(key);
return applyMutation(req, f);
}
diff --git a/src/util/talerconfig.ts b/src/util/talerconfig.ts
index 61c75574f..ec08c352f 100644
--- a/src/util/talerconfig.ts
+++ b/src/util/talerconfig.ts
@@ -59,8 +59,6 @@ export class ConfigValue<T> {
export class Configuration {
private sectionMap: SectionMap = {};
- constructor() {}
-
loadFromString(s: string): void {
const reComment = /^\s*#.*$/;
const reSection = /^\s*\[\s*([^\]]*)\s*\]\s*$/;
diff --git a/src/util/taleruri-test.ts b/src/util/taleruri-test.ts
index 9efc1846d..1510880c5 100644
--- a/src/util/taleruri-test.ts
+++ b/src/util/taleruri-test.ts
@@ -28,7 +28,7 @@ test("taler pay url parsing: wrong scheme", (t) => {
t.is(r1, undefined);
const url2 = "taler://refund/a/b/c/d/e/f";
- const r2 = parsePayUri(url1);
+ const r2 = parsePayUri(url2);
t.is(r2, undefined);
});
diff --git a/src/util/taleruri.ts b/src/util/taleruri.ts
index 8ad79669f..46cc199f8 100644
--- a/src/util/taleruri.ts
+++ b/src/util/taleruri.ts
@@ -97,7 +97,7 @@ export function classifyTalerUri(s: string): TalerUriType {
return TalerUriType.Unknown;
}
-export function getOrderDownloadUrl(merchantBaseUrl: string, orderId: string) {
+export function getOrderDownloadUrl(merchantBaseUrl: string, orderId: string): string {
const u = new URL("proposal", merchantBaseUrl);
u.searchParams.set("order_id", orderId);
return u.href;
diff --git a/src/util/timer.ts b/src/util/timer.ts
index 18132a812..9d743b8e9 100644
--- a/src/util/timer.ts
+++ b/src/util/timer.ts
@@ -26,7 +26,6 @@
*/
import { Duration } from "./time";
-
/**
* Cancelable timer.
*/