MonoStack

@repo/utils

Shared utility functions for the monorepo.

JSON types

  • JsonPrimitive — string | number | boolean | null
  • JsonValue — a JSON primitive, object, or array
  • JsonObject — a string-keyed object containing JSON values

Math

  • average(values: number[]): number | null — arithmetic mean, null for empty arrays
  • median(values: number[]): number | null — median value, null for empty arrays
  • nullMap<T, U>(value: T | null | undefined, fn: (v: T) => U): U | null — apply fn if value is non-null, otherwise return null

SvelteKit CORS

  • createCorsHandle(options) — creates a SvelteKit Handle that adds CORS headers for configured paths. By default it applies to /api/, echoes explicitly allowed origins, and can use acceptAll for local development.

String

  • toPascalCase(value: string): string — convert camelCase and snake_case values to labels

On this page