javascript-collections-framework
    Preparing search index...

    Type Alias KeyOf<T>

    KeyOf: (
        value: T,
    ) => string | number | bigint | boolean | symbol | null | undefined

    A function that gives each value the primitive key it should be found by, for a hashed collection's key option. Keys compare with SameValueZero, like native Map keys.

    The key is derived once when a value is stored; it is not derived again if the value changes later. Returning an object or a function is an error, because a new object on each call could never match a stored one.

    Type Parameters

    • T

    Type Declaration

      • (value: T): string | number | bigint | boolean | symbol | null | undefined
      • Parameters

        • value: T

        Returns string | number | bigint | boolean | symbol | null | undefined

    const byId: KeyOf<{ id: number }> = (user) => user.id
    const byPoint: KeyOf<{ x: number; y: number }> = (p) => `${p.x},${p.y}`