static function flatMap(\CharlotteDunois\Phoebe\Pool $pool, array $array, callable $function) {
        $promises = array();
        
        $howMany = (int) \ceil((\count($array) / $pool->getSize()));
        $chunks = \array_chunk($array, $howMany);
        
        $newFun = function ($value) use ($function) {
            return \array_reduce($value, $function, array()); // @codeCoverageIgnore
        };
        
        foreach($chunks as $arg) {
            $promises[] = static::parallelize($pool, $newFun, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($function) {
            return \array_reduce(static::convertResult($result), $function, array());
        });
    }