zeed
    Preparing search index...

    Function ensureKeyAsync

    • Call a create function if key does not yet exist on an object. Returns the found or created object. Example:

      async function fetchItem(id, cache) { ... }
      let data = await ensureKey(cache, id, fetchItem)

      Type Parameters

      • T

      Parameters

      • obj: Record<string, T>
      • key: string
      • createFn: (key?: string, obj?: Record<string, T>) => Promise<T>

      Returns Promise<T>