2022-01-19 20:19:13 -05:00
|
|
|
export const TERMS = ["winter", "spring", "fall"] as const;
|
|
|
|
export type Term = typeof TERMS[number];
|
|
|
|
|
|
|
|
// https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
|
|
|
|
export function isTerm(x: string): x is Term {
|
|
|
|
return TERMS.some((term) => x === term);
|
|
|
|
}
|
|
|
|
|
2021-08-28 15:52:45 -04:00
|
|
|
export function capitalize(str: string) {
|
|
|
|
return str.slice(0, 1).toUpperCase() + str.slice(1);
|
|
|
|
}
|