Spaces:
Running
Running
Download frontend/src/lib/format.ts from mishig/openai-math-explorer: direct link, hf CLI and curl.
- Browser
- Download file 680 Bytes
-
https://huggingface.co/spaces/mishig/openai-math-explorer/resolve/main/frontend/src/lib/format.ts
- Command line
-
hf download hf://spaces/mishig/openai-math-explorer/frontend/src/lib/format.ts
-
curl -L -o format.ts https://huggingface.co/spaces/mishig/openai-math-explorer/resolve/main/frontend/src/lib/format.ts
680 Bytes
| const fmt = new Intl.DateTimeFormat("en", { month: "short", day: "numeric", year: "numeric", timeZone: "UTC" }); | |
| export const date = (iso: string | null) => (iso ? fmt.format(new Date(`${iso}T00:00:00Z`)) : ""); | |
| export const plural = (n: number, word: string) => `${n} ${word}${n === 1 ? "" : "s"}`; | |
| // Spread the 17 disciplines around the colour wheel (golden-angle steps). | |
| const hues = new Map<string, number>(); | |
| export function hue(discipline: string, order: string[]): number { | |
| let h = hues.get(discipline); | |
| if (h === undefined) { | |
| const i = Math.max(0, order.indexOf(discipline)); | |
| h = Math.round((i * 137.508 + 225) % 360); | |
| hues.set(discipline, h); | |
| } | |
| return h; | |
| } | |