HH\Lib\Dict\chunk
Requires the Hack Standard Library to be installed.
Facebook Engineer?
This function is available as Dict\chunk()
in Facebook's www repository.
Returns a vec containing the original dict split into chunks of the given size
namespace HH\Lib\Dict;
function chunk<Tk as arraykey, Tv>(
KeyedTraversable<Tk, Tv> $traversable,
int $size,
): vec<dict<Tk, Tv>>;
If the original dict doesn't divide evenly, the final chunk will be smaller.
Time complexity: O(n) Space complexity: O(n)
Parameters
KeyedTraversable<Tk, Tv> $traversable
int $size
Returns
vec<dict<Tk, Tv>>