src/precore/util/Iterables.php
public static function limit(IteratorAggregate $iterable, int $limitSize) : IteratorAggregate
    {
        return new CallableIterable(
            function () use ($iterable, $limitSize) {
                return Iterators::limit(Iterators::from($iterable->getIterator()), $limitSize);
            }
        );
    }
public static function limit(IteratorAggregate $iterable, int $limitSize) : IteratorAggregate
    {
        return new CallableIterable(
            function () use ($iterable, $limitSize) {
                return Iterators::limit(Iterators::from($iterable->getIterator()), $limitSize);
            }
        );
    }
Creates an iterable with the first limitSize elements of the given iterable.
If the original iterable does not contain that many elements,
the returned iterable will have the same behavior as the original iterable.

@param IteratorAggregate $iterable
@param $limitSize
@return IteratorAggregate
@throws \InvalidArgumentException if $limitSize is negative