Optional ReadonlyclockClock used for TTL stamps and expiry checks. A test hook — the default is
Date.now.
ReadonlydefaultValue returned by get() when nothing is stored yet, the entry has
expired, or migration/validation failed.
Optional ReadonlylegacyKeys this value may have lived under before a rename. When the primary key is empty, they are read in order; the first hit is migrated/validated as usual, re-persisted under the primary key, and the legacy entry is removed only after that write succeeded.
delete() clears the legacy keys too. Deleting only the primary key would
let the next read resurrect the value from a legacy key that had not been
migrated yet.
Optional ReadonlymigrationsMigration steps keyed by the version they migrate from. On read, steps
apply in order from the stored version up to (but excluding) version.
A plain value written before this kit was adopted (not wrapped in the
storage envelope) reads as version 0: provide migrations[0] to
convert it, or leave it out and the value flows into validation unchanged.
Either way it is re-persisted in envelope form after the first read.
A gap (a version with no registered step) stops the chain early: the value as of that point goes straight to validation instead of guessing. If it validates, it is persisted at the declared current version; a gap is therefore an explicit decision that the intermediate value is already acceptable, not a deferred migration.
Optional ReadonlyschemaOptional Standard Schema validator, run against the (possibly migrated)
stored value on every read. Accepts the dependency-free s.* builders or
any Standard-Schema-compatible library with a synchronous validate.
Optional ReadonlyttlTime-to-live in milliseconds from the moment a value is written. Once expired, the entry reads back exactly as if it had never been set.
Optional ReadonlyversionCurrent schema version.
Options for creating a typed storage.