summaryrefslogtreecommitdiffstats
path: root/src/renderer/runtime/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/runtime/util.ts')
-rw-r--r--src/renderer/runtime/util.ts18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/renderer/runtime/util.ts b/src/renderer/runtime/util.ts
index 5ea0c88..b4cd219 100644
--- a/src/renderer/runtime/util.ts
+++ b/src/renderer/runtime/util.ts
@@ -1,8 +1,7 @@
export function recordToMap<T>(r: Record<string, T>): Map<string, T> {
const ret = new Map();
- for (const k of Object.keys(r))
- ret.set(k, r[k]);
+ for (const k of Object.keys(r)) ret.set(k, r[k]);
return ret;
}
@@ -10,8 +9,7 @@ export function recordToMap<T>(r: Record<string, T>): Map<string, T> {
export function mapValues<K, V1, V2>(f: (v: V1) => V2, map: Map<K, V1>): Map<K, V2> {
const ret: Map<K, V2> = new Map();
- for (const [k, v] of map)
- ret.set(k, f(v));
+ for (const [k, v] of map) ret.set(k, f(v));
return ret;
}
@@ -19,8 +17,7 @@ export function mapValues<K, V1, V2>(f: (v: V1) => V2, map: Map<K, V1>): Map<K,
export async function mapValuesAsync<K, V1, V2>(f: (v: V1) => Promise<V2>, map: Map<K, V1>): Promise<Map<K, V2>> {
const ret: Map<K, V2> = new Map();
- for (const [k, v] of mapValues(f, map))
- ret.set(k, await v);
+ for (const [k, v] of mapValues(f, map)) ret.set(k, await v);
return ret;
}
@@ -28,12 +25,12 @@ export async function mapValuesAsync<K, V1, V2>(f: (v: V1) => Promise<V2>, map:
export function nextPowerOf2(n: number): number {
let i = 1;
- while (i < n)
- i *= 2;
+ while (i < n) i *= 2;
return i;
}
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export class Listenable<T extends any[]> {
private readonly listeners: Array<(...args: T) => void> = [];
@@ -46,10 +43,9 @@ export class Listenable<T extends any[]> {
}
}
-export async function getJSON(url: string): Promise<any> {
+export async function getJSON(url: string): Promise<unknown> {
const res = await window.fetch(url);
- if (res.status < 200 || res.status >= 300)
- throw new Error(res.statusText);
+ if (res.status < 200 || res.status >= 300) throw new Error(res.statusText);
return await res.json();
}