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

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

Returns a new keyset containing only the values for which the given async predicate returns true

namespace HH\Lib\Keyset;

function filter_async<Tv as arraykey>(
  Container<Tv> $traversable,
  (function(Tv): Awaitable<bool>) $value_predicate,
): Awaitable<keyset<Tv>>;

For non-async predicates, see Keyset\filter().

Time complexity: O(n * p), where p is the complexity of $value_predicate Space complexity: O(n)