One JSON value under one storage key: the read-with-fallback / write / remove trio that
PlayerStats, RunHistory and NewsSeenTracker each hand-rolled, with slightly
different falsy-vs-null edges per copy. The one here treats any missing or empty read as
absent (the raw ? ... : fallback rule two of the three already followed); corrupt JSON
or a forbidden key throws a named error (parseInbound), since silently inventing a value would hide a real bug.
Public so a game can keep its own progress (a level list, a best score) as structured JSON
under one key, with defaultStorage() as the storage. Multi-key shapes (Collection's
prefix scan, SaveSystem's slots) do not fit it and keep their own code.
One JSON value under one storage key: the read-with-fallback / write / remove trio that
PlayerStats,RunHistoryandNewsSeenTrackereach hand-rolled, with slightly different falsy-vs-null edges per copy. The one here treats any missing or empty read as absent (theraw ? ... : fallbackrule two of the three already followed); corrupt JSON or a forbidden key throws a named error (parseInbound), since silently inventing a value would hide a real bug.Public so a game can keep its own progress (a level list, a best score) as structured JSON under one key, with
defaultStorage()as the storage. Multi-key shapes (Collection's prefix scan,SaveSystem's slots) do not fit it and keep their own code.Example