weekdayOf | (day: string): number | The weekday of a calendar day, 0 Sunday. Computed at noon UTC, which every zone shares as the same date. |
|---|
dayTotals | (entries: SaveEntry[], timeZone: string, allowNegative: boolean): Map<string, number> | Words per local day: typed minus removed, held at zero unless the goal lets a day go negative. |
|---|
writingDaysBetween | (from: string, to: string, writingDays: number[]): number | Writing days from from to to, both included. |
|---|
pace | (input: { projectTarget: number | null; deadline: string; wordsNow: number; wordsToday: number; today: string; writingDays: number[]; }): Pace | The words a day needs to reach the project's target by its deadline: what was left when today began, spread over the writing days from today to the deadline. Today's own words do not lower today's target, so the number holds still while Dustin writes. |
|---|
targetFor | (goal: Goal, today: string, paced: Pace): number | null | Today's target, or null when there is none; a day off has none whatever the goal says. |
|---|
streak | (totals: Map<string, number>, today: string, target: number | null, writingDays: number[]): number | Days in a row the target was met, counting back from today. Today counts once it is met and does not break the run before then. A day off neither breaks the run nor adds to it, unless the target was met on it anyway. The target is today's: Carrel keeps no history of past targets. |
|---|
recentDays | (totals: Map<string, number>, today: string, n: number, writingDays: number[]): { day: string; words: number; writingDay: boolean; }[] | The last n days, newest first, each with its words and whether it was a writing day. |
|---|
parseWritingDays | (stored: string): number[] | "0123456" as stored, to weekday numbers; anything else in the string is dropped. |
|---|
parseDailyTarget | (typed: string): { ok: true; target: number | null; } | { ok: false; error: string; } | A daily target as a person typed it: "1,500", "1 500" and "1500" are the same; empty is no target. Refused when it is not a whole number from 1 to MAX_DAILY_TARGET, with the sentence to show. |
|---|
goalFromForm | (input: { mode: string; dailyTarget: string; writingDays: string[]; allowNegative: boolean; }): { ok: true; goal: Goal; } | { ok: false; error: string; } | A goal as a form posted it, checked: the mode, the target, at least one writing day. |
|---|
untypedCount | (value: unknown): number | An untyped count a form posted: a whole number of words, 0 for anything else. |
|---|
untypedTally | (): { add(words: number): void; send(): number; settled(ok: boolean): void; reset(): void; readonly pending: number; } | The words pasted or dropped into an editor and not yet reported: they reach the file but were not typed, so the day's count leaves them out. add on each paste or drop; send when a save posts (the count to send with it); settled(ok) when the save is done, which takes what it carried off only if the server has it; reset when the text is replaced (a discard, an AI draft taken). |
|---|
weekdayName | (day: string): string | The weekday's name of a calendar day. |
|---|
paceLine | (paced: Pace, deadline: string): string | The pace a deadline asks for, or why there is none, in a sentence. |
|---|
weekSentence | (days: readonly { day: string; words: number; writingDay: boolean; }[], target: number | null): string | The sentence that says what the last days' chart shows, with its numbers. Days newest first. |
|---|