proposit-core
    Preparing search index...

    Function createLookup

    • Creates a keyed lookup from an array of items. Items are indexed by a composite string key (typically "id:version"), and the returned object exposes a get(id, version) method that reconstructs the same key internally.

      Use this to build the TClaimLookup required by ArgumentEngine's constructor from flat arrays (e.g. database query results).

      Type Parameters

      • T

      Parameters

      • items: T[]

        The array of items to index.

      • getKey: (item: T) => string

        A function that produces the composite key for each item. Must return a string of the form "id:version" so that the returned get(id, version) method can reconstruct it.

      Returns { get(id: string, version: number): T | undefined }

      An object with a get(id, version) method that looks up items by reconstructing the composite key. Returns undefined if no item matches.

      const claimLookup = createLookup(claims, (c) => `${c.id}:${c.version}`)
      const engine = new ArgumentEngine(arg, claimLookup, ...)