static function filter(\CharlotteDunois\Phoebe\Pool $pool, array $array, ?callable $function = null) {
        if($function === null) {
            $function = function ($value) {
                return ((bool) $value); // @codeCoverageIgnore
            };
        }
        
        $promises = array();
        
        foreach($array as $id => $arg) {
            $promises[$id] = static::parallelize($pool, $function, array($arg))->then(null, function (\Throwable $e) {
                return $e;
            });
        }
        
        return \React\Promise\all($promises)->then(function (array $result) use ($array) {
            $result = static::convertResult($result);
            
            foreach($array as $key => $_) {
                if(!$result[$key]) {
                    unset($array[$key]);
                }
            }
            
            return $array;
        });
    }