spb/company-atlas
Public
Python 66.3%
TypeScript 22.7%
JavaScript 8.6%
HTML 1.4%
CSS 0.7%
1/** Next 16 search params arrive as `Promise<Record<string, string | string[] | undefined>>`; these helpers read them safely. */2export type SP = Record<string, string | string[] | undefined>;34export function str(v: string | string[] | undefined): string | undefined {5 if (Array.isArray(v)) return v[0];6 return v === '' ? undefined : v;7}8export function int(v: string | string[] | undefined, fallback: number, min = 1, max = 100000): number {9 const n = Number(str(v));10 if (!Number.isFinite(n)) return fallback;11 return Math.min(max, Math.max(min, Math.floor(n)));12}13export function bool(v: string | string[] | undefined): boolean {14 const s = str(v);15 return s === '1' || s === 'true';16}17/** Current params as a flat string record (for `withParams`). */18export function flat(sp: SP): Record<string, string | undefined> {19 const out: Record<string, string | undefined> = {};20 for (const [k, v] of Object.entries(sp)) out[k] = str(v);21 return out;22}23