Maps the provided map into an array using the provided mapping function.

  • Type Parameters

    • K
    • V
    • T

    Parameters

    • map: Map<K, V>

      Map to be entered into an array

    • fn: ((key: K, value: V) => T)

      A mapping function to transform each pair into an item

        • (key, value): T
        • Parameters

          • key: K
          • value: V

          Returns T

    Returns T[]

    console.log(map); // Map(5) { 0 => 5, 1 => 4, 2 => 3, 3 => 2, 4 => 1 }

    const arr = mapToArray(map, (_, value) => value);

    console.log(arr); // [5, 4, 3, 2, 1]