init
This commit is contained in:
commit
6250d23297
53 changed files with 6381 additions and 0 deletions
18
lib/weather/describe.ts
Normal file
18
lib/weather/describe.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import type { AlertSeverity, Condition } from "./types";
|
||||
|
||||
/** Fallback wording for providers that only give us a numeric code. */
|
||||
export const CONDITION_LABELS: Record<Condition, string> = {
|
||||
clear: "clear skies",
|
||||
clouds: "cloudy",
|
||||
rain: "rain",
|
||||
storm: "thunderstorm",
|
||||
snow: "snow",
|
||||
fog: "fog",
|
||||
};
|
||||
|
||||
/** Maps any provider's severity word ("Severe", "severe", "Moderate"…) onto ours. */
|
||||
export function toSeverity(word: string | null | undefined): AlertSeverity {
|
||||
const normalized = (word ?? "").toLowerCase();
|
||||
const known: AlertSeverity[] = ["extreme", "severe", "moderate", "minor"];
|
||||
return known.find((s) => normalized.includes(s)) ?? "unknown";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue