@repo/utils
Shared utility functions for the monorepo.
JSON types
JsonPrimitive—string | number | boolean | nullJsonValue— a JSON primitive, object, or arrayJsonObject— a string-keyed object containing JSON values
Math
average(values: number[]): number | null— arithmetic mean,nullfor empty arraysmedian(values: number[]): number | null— median value,nullfor empty arraysnullMap<T, U>(value: T | null | undefined, fn: (v: T) => U): U | null— applyfnif value is non-null, otherwise returnnull
SvelteKit CORS
createCorsHandle(options)— creates a SvelteKitHandlethat adds CORS headers for configured paths. By default it applies to/api/, echoes explicitly allowed origins, and can useacceptAllfor local development.
String
toPascalCase(value: string): string— convert camelCase and snake_case values to labels