isguard-ts
    Preparing search index...

    Function isMap

    • Creates a MapTypeGuard that checks that the value is a Map and all its keys and values are of the correct type.

      Type Parameters

      • K

        The type of keys in the map

      • V

        The type of values in the map

      Parameters

      Returns MapTypeGuard<K, V>

      A type guard for Map<K, V>

      const isStringToNumberMap = isMap(isString, isNumber);

      isStringToNumberMap(new Map([["a", 1], ["b", 2]])); // true
      isStringToNumberMap(new Map([[1, "a"]])); // false