Function getExistingElseThrow

  • Gets the value of a map entry by its key, throwing if the map does not contain the key.

    Since

    13.0.0

    Returns

    The corresponding value.

    Throws

    TypeError if map does not contain key.

    Example

    getExistingElseThrow(new Map([["key", 1]]), "key")
    // => 1

    getExistingElseThrow(new Map([["key", 1]]), "foo")
    // => throws TypeError

    Type Parameters

    • TKey

    • UValue

    Parameters

    • map: ReadonlyMap<TKey, UValue>

      Map to check against.

    • key: TKey

      Key to get the value for.

    Returns UValue

Generated using TypeDoc