Skip to main content

Interface: UseFrecencyOptions

Defined in: use-frecency.ts:31

Options for useFrecency.

Properties​

halfLifeMs?​

optional halfLifeMs?: number

Defined in: use-frecency.ts:38

How long it takes a score to halve, in milliseconds. A shorter half-life favors what was used recently, a longer one favors what was used often. Zero, negative and non-finite values fall back to the default. Default is 7 days.


maxItems?​

optional maxItems?: number

Defined in: use-frecency.ts:47

The most items to keep. When record adds an item beyond this limit, the items with the lowest scores are removed, never the item that was just recorded. Use Infinity to keep everything. Values below 1 fall back to the default, and fractions are rounded down. Lowering the limit takes effect on the next record. Default is 100.


now?​

optional now?: () => number

Defined in: use-frecency.ts:54

Returns the current time in milliseconds. Inject it to make scores deterministic in tests, or to use a server-synchronized clock. It is read every time a score is recorded or read, so passing a new function on a later render is fine. Default is Date.now.

Returns​

number


storage?​

optional storage?: PersistedStateStorage

Defined in: use-frecency.ts:60

Where to persist the scores. Defaults to localStorage. Use sessionStorage to forget them when the tab closes, or any object with getItem and setItem (see PersistedStateStorage).