app/lib/kind-words.ts
16 lines and 3 functions in DrDustinEdwards/carrel, at commit d5d5e82 on 2026-10-24. This file on GitHub.
Functions
| Function | Lines | Complexity | Covered | CRAP | Mutation |
|---|---|---|---|---|---|
| kindWord | 5 to 8 | 2 | 100% | OkCRAP 2 | No data: mutation testing has not run on this repo yet |
| kindPlural | 11 to 16 | 3 | 67% | OkCRAP 3.3 | No data: mutation testing has not run on this repo yet |
| kindNoun | 19 to 19 | 2 | 100% | OkCRAP 2 | No data: mutation testing has not run on this repo yet |
Imports
It imports no other module of this repo. Imported by app/components/editor/frontmatter-fields.tsx, app/lib/writing/binder.ts, app/routes/editor.tsx, app/routes/history.tsx, app/routes/project.tsx.
Source
// The words for a kind the site reports, so a phage is called a phage and not a post. Carrel has no
// list of kinds: these are made from the site's own kind name, whatever it is.
/** The kind as a heading word: "phage" is "Phage". An item with no kind is a post. */
export function kindWord(kind: string | null | undefined): string {
const k = kind || "post";
return `${k.charAt(0).toUpperCase()}${k.slice(1)}`;
}
/** The kind in the plural, as a heading word: "Posts", "Dictionaries", "Addresses". */
export function kindPlural(kind: string | null | undefined): string {
const word = kindWord(kind);
if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;
if (/(s|x|z|ch|sh)$/i.test(word)) return `${word}es`;
return `${word}s`;
}
/** The kind inside a sentence: "this phage". */
export const kindNoun = (kind: string | null | undefined) => (kind || "post").toLowerCase();