HH\Lib\Dict\map_with_key

Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Dict\map_with_key() in Facebook's www repository.

Returns a new dict where each value is the result of calling the given function on the original value and key

namespace HH\Lib\Dict;

function map_with_key<Tk as arraykey, Tv1, Tv2>(
  KeyedTraversable<Tk, Tv1> $traversable,
  (function(Tk, Tv1): Tv2) $value_func,
): dict<Tk, Tv2>;

Time complexity: O(n * f), where f is the complexity of $value_func Space complexity: O(n)

Parameters

Returns

  • dict<Tk, Tv2>