@kkdev92/vscode-ext-kit - v4.1.1
    Preparing search index...

    Interface StorageOptions<T>

    Options for creating a typed storage.

    interface StorageOptions<T> {
        clock?: () => number;
        defaultValue: T;
        legacyKeys?: readonly string[];
        migrations?: Readonly<Record<number, (old: unknown) => unknown>>;
        schema?: StandardSchemaV1<unknown, T>;
        ttlMs?: number;
        version?: number;
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index
    clock?: () => number

    Clock used for TTL stamps and expiry checks. A test hook — the default is Date.now.

    defaultValue: T

    Value returned by get() when nothing is stored yet, the entry has expired, or migration/validation failed.

    legacyKeys?: readonly string[]

    Keys 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.

    migrations?: Readonly<Record<number, (old: unknown) => unknown>>

    Migration 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.

    schema?: StandardSchemaV1<unknown, T>

    Optional 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.

    ttlMs?: number

    Time-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.

    version?: number

    Current schema version.

    1