logical.HINT_DAYSconstno test imports itconst HINT_DAYS: 7How long a hint stays quiet after it was shown.
The cadence of hints as a pure function (commons headless 0003-headless-output FR-009): an optional feature that is merely off is a hint, not a problem, and the same hint is shown at most once in seven days. Given when each hint was last shown and the time now, which are due and when each is remembered to have been shown; reading and writing that memory is the surface's.
import { hintsDue, HINT_DAYS } from "./hints.ts";
const day = 86_400_000;
hintsDue({ a: 0 }, [{ id: "a", message: "A is off" }], HINT_DAYS * day - 1).due.length; // 0
hintsDue({ a: 0 }, [{ id: "a", message: "A is off" }], HINT_DAYS * day).due.length; // 1logical.HINT_DAYSconstno test imports itconst HINT_DAYS: 7How long a hint stays quiet after it was shown.
logical.HintMemorytypeno test imports ittype HintMemory = Readonly<Record<string, number>>;When each hint was last shown, by id, in milliseconds.
logical.HintsDuetypeno test imports ittype HintsDue = { readonly due: readonly Hint[]; readonly memory: HintMemory };The hints that are due, and the memory once they are shown.
logical.hintsDuefunctionno test imports itfunction hintsDue(memory: Readonly<Record<string, number>>, hints: readonly Hint[], now: number): HintsDueThe hints due at now: those never shown, or shown seven days ago or more; each hint once even if a run raised it twice. The memory is the one given with the due hints set to now, and is the same object where none is due (so that nothing is written for nothing).
logical.distinctHintsfunctionno test imports itfunction distinctHints(hints: readonly Hint[]): readonly Hint[]The hints with a repeated id once, the first of each (what verbose mode shows: every hint, every time, but not twice in one run).
HINT_DAYSconstconst HINT_DAYS: 7How long a hint stays quiet after it was shown.
HintMemorytypeno test imports ittype HintMemory = Readonly<Record<string, number>>;When each hint was last shown, by id, in milliseconds.
HintsDuetypeno test imports ittype HintsDue = { readonly due: readonly Hint[]; readonly memory: HintMemory };The hints that are due, and the memory once they are shown.
hintsDuefunctionfunction hintsDue(memory: Readonly<Record<string, number>>, hints: readonly Hint[], now: number): HintsDueThe hints due at now: those never shown, or shown seven days ago or more; each hint once even if a run raised it twice. The memory is the one given with the due hints set to now, and is the same object where none is due (so that nothing is written for nothing).
distinctHintsfunctionfunction distinctHints(hints: readonly Hint[]): readonly Hint[]The hints with a repeated id once, the first of each (what verbose mode shows: every hint, every time, but not twice in one run).