Library API
    Preparing search index...

    Function indexedArray

    • Augments a standard array with a Proxy-based lookup delegate. Allows index/enumerable array methods to function natively (e.g., map, filter, length), while redirecting non-numeric string keys to a custom finder function to lookup items.

      Type Parameters

      • T extends object

      Parameters

      • list: T[]

        The array to augment

      • finder: (key: string) => T | undefined

        The lookup function for non-numeric keys

      • readonly: boolean = true

        Whether the array should be read-only (default: true)

      Returns T[] & Record<string, T>

      The augmented array with record-like string indexing

      const arr = indexedArray([{ id: 'a' }], key => list.find(x => x.id === key));
      arr['a']; // { id: 'a' }