import { StringNumber } from "../types/main.js"; export function getObjectValue(obj: unknown, key: string) { if (!(obj instanceof Object)) return; const i = Object.keys(obj).indexOf(key); return Object.values(obj)[i]; } export function Void() { return; } export function unique(val: T[]) { return [...new Set([...val])]; } export function prettyJson(val?: unknown) { try { return JSON.stringify(val, null, 2); } catch (e) { return ""; } } export class EnumReader { private readonly $keys: T[]; private readonly $values: V[]; constructor(list: { [key in T]: V }) { this.$keys = Object.keys(list) as T[]; this.$values = Object.values(list); } keys() { return [...this.$keys]; } values() { return [...this.$values]; } value

(key: P) { const index = this.$keys.indexOf(key); return this.$values[index]; } key

(value: P) { const index = this.$values.indexOf(value); return this.$keys[index]; } }