minor fixes

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-10-28 21:57:43 +02:00
parent aa2939f302
commit c8c86d8c23
9 changed files with 78 additions and 76 deletions

View File

@@ -19,4 +19,15 @@ export const intervals = {
month: "Month",
};
export const alphabetIds = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] as const;
export const alphabetIds = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] as const;
export const timeRanges = {
'today': 'Today',
1: '24 hours',
7: '7 days',
14: '14 days',
30: '30 days',
90: '3 months',
180: '6 months',
365: '1 year',
}

View File

@@ -1,16 +1,24 @@
export function toDots(obj: Record<string, unknown>, path = ''): Record<string, number | string | boolean> {
export function toDots(
obj: Record<string, unknown>,
path = "",
): Record<string, number | string | boolean> {
return Object.entries(obj).reduce((acc, [key, value]) => {
if(typeof value === 'object' && value !== null) {
if (typeof value === "object" && value !== null) {
return {
...acc,
...toDots(value as Record<string, unknown>, `${path}${key}.`)
}
...toDots(value as Record<string, unknown>, `${path}${key}.`),
};
}
return {
...acc,
[`${path}${key}`]: value,
}
}, {})
}
};
}, {});
}
export function entries<K extends string | number | symbol, V>(
obj: Record<K, V>,
): [K, V][] {
return Object.entries(obj) as [K, V][];
}