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

This function is available as Keyset\map() in Facebook's www repository.

Returns a new keyset where each value is the result of calling the given function on the original value

namespace HH\Lib\Keyset;

function map<Tv1, Tv2 as arraykey>(
  Traversable<Tv1> $traversable,
  (function(Tv1): Tv2) $value_func,
): keyset<Tv2>;

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



  • keyset<Tv2>