IF Commons GitHub

logical/hints

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-headless-output FR-009

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; // 1

Source: commons/headless/src/logical/hints.ts

3 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

logical.HINT_DAYSconstno test imports it
const HINT_DAYS: 7

How long a hint stays quiet after it was shown.

logical.HintMemorytypeno test imports it
type HintMemory = Readonly<Record<string, number>>;

When each hint was last shown, by id, in milliseconds.

logical.HintsDuetypeno test imports it
type HintsDue = { readonly due: readonly Hint[]; readonly memory: HintMemory };

The hints that are due, and the memory once they are shown.

logical.hintsDuefunctionno test imports it
function hintsDue(memory: Readonly<Record<string, number>>, hints: readonly Hint[], now: number): HintsDue

The 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 it
function 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_DAYSconst
const HINT_DAYS: 7

How long a hint stays quiet after it was shown.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

HintMemorytypeno test imports it
type HintMemory = Readonly<Record<string, number>>;

When each hint was last shown, by id, in milliseconds.

HintsDuetypeno test imports it
type HintsDue = { readonly due: readonly Hint[]; readonly memory: HintMemory };

The hints that are due, and the memory once they are shown.

hintsDuefunction
function hintsDue(memory: Readonly<Record<string, number>>, hints: readonly Hint[], now: number): HintsDue

The 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).

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

distinctHintsfunction
function 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).

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.