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.
The array to augment
The lookup function for non-numeric keys
Whether the array should be read-only (default: true)
The augmented array with record-like string indexing
const arr = indexedArray([{ id: 'a' }], key => list.find(x => x.id === key));arr['a']; // { id: 'a' } Copy
const arr = indexedArray([{ id: 'a' }], key => list.find(x => x.id === key));arr['a']; // { id: 'a' }
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.