• Add the value to the Map if it doesn't already have an entry with the same key

    Mutation

    Example

    Set a Map entry if the key is absent

    const map = new Map();
    setIfAbsent(map, 1, 2);
    console.log(map); // Map([[1, 2]])

    Type Parameters

    • K

      the Map key type

    • V

      the Map value type

    Parameters

    • map: Map<K, V>

      the Map to set the entry

    Returns ((key: K, value: V) => void)

      • (key: K, value: V): void
      • Parameters

        • key: K
        • value: V

        Returns void

Generated using TypeDoc