idb-ts
    Preparing search index...

    Class KeyGenerators

    Built-in key generation utilities used by the KeyPath generator option and available for direct use in application code.

    import { KeyGenerators } from 'idb-ts';

    const id = KeyGenerators.uuid(); // "a1b2c3d4-..."
    const timestamp = KeyGenerators.timestamp(); // 1696118400000
    const random = KeyGenerators.random(); // "xyz789abc123"
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Generates a short random alphanumeric string derived from Math.random().toString(36).

      Returns string

      A random string of approximately 13 characters, e.g., "xyz789abc123".

    • Returns the current Unix timestamp in milliseconds (Date.now()).

      Returns number

      A numeric timestamp, e.g., 1696118400000.

    • Generates a RFC 4122 UUID v4 string. The implementation does not rely on any external dependency.

      Returns string

      A UUID v4 string, e.g., "a1b2c3d4-e5f6-4789-abcd-ef1234567890".