Trim filters, fix some issues with feed loaders

This commit is contained in:
Jon Staab
2024-05-22 10:30:29 -07:00
parent eca11b4fb2
commit fdce131d27
3 changed files with 35 additions and 10 deletions
+20
View File
@@ -63,6 +63,26 @@ export function* range(a: number, b: number, step = 1) {
}
}
export const mapKeys = <T extends Record<string, any>>(f: (v: string) => string, x: T) => {
const r: Record<string, any> = {}
for (const [k, v] of Object.entries(x)) {
r[f(k)] = v
}
return r as T
}
export const mapVals = <T extends Record<string, any>>(f: (v: any) => any, x: T) => {
const r: Record<string, any> = {}
for (const [k, v] of Object.entries(x)) {
r[k] = f(v)
}
return r as T
}
export const between = (low: number, high: number, n: number) => n > low && n < high
export const randomId = (): string => Math.random().toString().slice(2)